All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Michal Marek <michal.lkml@markovi.net>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 14/29] modpost: track if the symbol origin is a dump file or ELF object
Date: Mon, 25 May 2020 00:42:20 +0900	[thread overview]
Message-ID: <20200524154235.380482-15-masahiroy@kernel.org> (raw)
In-Reply-To: <20200524154235.380482-1-masahiroy@kernel.org>

The meaning of sym->kernel is obscure; it is set for in-kernel symbols
loaded from Modules.symver. This happens only when we are building
external modules, and it is used to determine whether to dump symbols
to $(KBUILD_EXTMOD)/Modules.symver

It is clearer to remember whether the symbol or module came from a dump
file or ELF object.

This changes the KBUILD_EXTRA_SYMBOLS behavior. Previously, symbols
loaded from KBUILD_EXTRA_SYMBOLS are accumulated into the current
$(KBUILD_EXTMOD)/Modules.symver

Going forward, they will be only used to check symbol references, but
not dumped into the current $(KBUILD_EXTMOD)/Modules.symver. I believe
this makes more sense.

sym->vmlinux will have no user. Remove it too.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2: None

 scripts/mod/modpost.c | 15 +++++----------
 scripts/mod/modpost.h |  1 +
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 2f5fab40d859..76599dd44bae 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -207,9 +207,6 @@ struct symbol {
 	int crc_valid;
 	char *namespace;
 	unsigned int weak:1;
-	unsigned int vmlinux:1;    /* 1 if symbol is defined in vmlinux */
-	unsigned int kernel:1;     /* 1 if symbol is from kernel
-				    *  (only for external modules) **/
 	unsigned int is_static:1;  /* 1 if symbol is not global */
 	enum export  export;       /* Type of export */
 	char name[];
@@ -441,8 +438,6 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod,
 	}
 
 	s->module = mod;
-	s->vmlinux   = is_vmlinux(mod->name);
-	s->kernel    = 0;
 	s->export    = export;
 	return s;
 }
@@ -2440,7 +2435,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
 /* parse Module.symvers file. line format:
  * 0x12345678<tab>symbol<tab>module<tab>export<tab>namespace
  **/
-static void read_dump(const char *fname, unsigned int kernel)
+static void read_dump(const char *fname)
 {
 	char *buf, *pos, *line;
 
@@ -2479,9 +2474,9 @@ static void read_dump(const char *fname, unsigned int kernel)
 				have_vmlinux = 1;
 			mod = new_module(modname);
 			mod->skip = 1;
+			mod->from_dump = 1;
 		}
 		s = sym_add_exported(symname, mod, export_no(export));
-		s->kernel    = kernel;
 		s->is_static = 0;
 		sym_set_crc(symname, crc);
 		sym_update_namespace(symname, namespace);
@@ -2501,7 +2496,7 @@ static int dump_sym(struct symbol *sym)
 {
 	if (!external_module)
 		return 1;
-	if (sym->vmlinux || sym->kernel)
+	if (sym->module->from_dump)
 		return 0;
 	return 1;
 }
@@ -2620,11 +2615,11 @@ int main(int argc, char **argv)
 	}
 
 	if (kernel_read)
-		read_dump(kernel_read, 1);
+		read_dump(kernel_read);
 	while (extsym_start) {
 		struct ext_sym_list *tmp;
 
-		read_dump(extsym_start->file, 0);
+		read_dump(extsym_start->file);
 		tmp = extsym_start->next;
 		free(extsym_start);
 		extsym_start = tmp;
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 232a0e11fcaa..aaf3c4ad5d60 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -119,6 +119,7 @@ struct module {
 	const char *name;
 	int gpl_compatible;
 	struct symbol *unres;
+	int from_dump;  /* 1 if module was loaded from *.symver */
 	int seen;
 	int skip;
 	int has_init;
-- 
2.25.1


  parent reply	other threads:[~2020-05-24 15:43 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-24 15:42 [PATCH v2 00/29] modpost: various fixes, cleanups, optimizations Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 01/29] modpost: drop RCS/CVS $Revision handling in MODULE_VERSION() Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 02/29] modpost: do not call get_modinfo() for vmlinux Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 03/29] modpost: add read_text_file() and get_line() helpers Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 04/29] modpost: fix potential mmap'ed file overrun in get_src_version() Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 05/29] modpost: re-add warning about missing *.mod file Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 06/29] modpost: avoid false-positive file open error Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 07/29] modpost: use read_text_file() and get_line() for reading text files Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 08/29] modpost: remove get_next_text() and make {grab,release_}file static Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 09/29] kbuild: disallow multi-word in M= or KBUILD_EXTMOD Masahiro Yamada
2020-05-31 18:31   ` Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 10/29] modpost: move -T option close to the modpost command Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 11/29] modpost: pass -N option only for modules modpost Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 12/29] modpost: move external module options Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 13/29] modpost: load KBUILD_EXTRA_SYMBOLS files in order Masahiro Yamada
2020-05-24 15:42 ` Masahiro Yamada [this message]
2020-05-24 15:42 ` [PATCH v2 15/29] modpost: allow to pass -i option multiple times remove -e option Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 16/29] modpost: rename ext_sym_list to dump_list Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 17/29] modpost: re-add -e to set external_module flag Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 18/29] modpost: show warning if vmlinux is not found when processing modules Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 19/29] modpost: show warning if it fails to read symbol dump file Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 20/29] modpost: generate vmlinux.symvers and reuse it for the second modpost Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 21/29] modpost: remove -s option Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 22/29] modpost: remove mod->is_dot_o struct member Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 23/29] modpost: remove is_vmlinux() call in check_for_{gpl_usage,unused}() Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 24/29] modpost: add mod->is_vmlinux struct member Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 25/29] modpost: remove mod->skip " Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 26/29] modpost: set have_vmlinux in new_module() Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 27/29] modpost: strip .o from modname before calling new_module() Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 28/29] modpost: remove is_vmlinux() helper Masahiro Yamada
2020-05-24 15:42 ` [PATCH v2 29/29] modpost: change elf_info->size to size_t Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200524154235.380482-15-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.