linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Jessica Yu <jeyu@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Michal Marek <michal.lkml@markovi.net>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 20/29] modpost: generate vmlinux.symvers and reuse it for the second modpost
Date: Sun, 17 May 2020 18:48:50 +0900	[thread overview]
Message-ID: <20200517094859.2376211-21-masahiroy@kernel.org> (raw)
In-Reply-To: <20200517094859.2376211-1-masahiroy@kernel.org>

The full build runs modpost twice, first for vmlinux.o and second for
modules.

The first pass dumps all the vmlinux symbols into Module.symvers, but
the second pass parses vmlinux again instead of reusing the dump file,
presumably because it needs to avoid accumulating stale symbols.

Loading symbol info from a dump file is faster than parsing an ELF object.
Besides, modpost deals with various issues to parse vmlinux in the second
pass.

A solution is to make the first pass dumps symbols into a separate file,
vmlinux.symvers. The second pass reads it, and parses module .o files.
The merged symbol information is dumped into Module.symvers as before.

This makes further modpost cleanups possible.

Also, it fixes the problem of 'make vmlinux', which previously overwrote
Module.symvers, throwing away module symbols.

I slightly touched scripts/link-vmlinux.sh so that vmlinux is re-linked
when you cross this commit. Otherwise, vmlinux.symvers would not be
generated.

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

 .gitignore               |  1 +
 Makefile                 |  2 +-
 scripts/Makefile.modpost | 11 +++++++----
 scripts/link-vmlinux.sh  |  2 --
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
index 2258e906f01c..87b9dd8a163b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,7 @@ modules.order
 /linux
 /vmlinux
 /vmlinux.32
+/vmlinux.symvers
 /vmlinux-gdb.py
 /vmlinuz
 /System.map
diff --git a/Makefile b/Makefile
index 27e8a0522a3c..43988ce4e17e 100644
--- a/Makefile
+++ b/Makefile
@@ -1405,7 +1405,7 @@ endif # CONFIG_MODULES
 # make distclean Remove editor backup files, patch leftover files and the like
 
 # Directories & files removed with 'make clean'
-CLEAN_FILES += include/ksym \
+CLEAN_FILES += include/ksym vmlinux.symvers \
 	       modules.builtin modules.builtin.modinfo modules.nsdeps
 
 # Directories & files removed with 'make mrproper'
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index d14143b30b7a..1c597999b6a0 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -43,17 +43,17 @@ __modpost:
 include include/config/auto.conf
 include scripts/Kbuild.include
 
-kernelsymfile := $(objtree)/Module.symvers
-
 MODPOST = scripts/mod/modpost								\
 	$(if $(CONFIG_MODVERSIONS),-m)							\
 	$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a)					\
-	$(if $(KBUILD_EXTMOD),,-o $(kernelsymfile))					\
 	$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E)					\
 	$(if $(KBUILD_MODPOST_WARN),-w)
 
 ifdef MODPOST_VMLINUX
 
+# modpost options for vmlinux.o
+MODPOST += -o vmlinux.symvers
+
 quiet_cmd_modpost = MODPOST vmlinux.o
       cmd_modpost = $(MODPOST) vmlinux.o
 
@@ -68,7 +68,10 @@ MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s \
 	$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))
 
 ifeq ($(KBUILD_EXTMOD),)
-MODPOST += $(wildcard vmlinux)
+
+# modpost options for in-kernel modules
+MODPOST += -i vmlinux.symvers -o Module.symvers
+
 else
 
 # set src + obj - they may be used in the modules's Makefile
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index d09ab4afbda4..d5af6be50b50 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -218,8 +218,6 @@ on_signals()
 }
 trap on_signals HUP INT QUIT TERM
 
-#
-#
 # Use "make V=1" to debug this script
 case "${KBUILD_VERBOSE}" in
 *1*)
-- 
2.25.1


  parent reply	other threads:[~2020-05-17  9:50 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17  9:48 [PATCH 00/29] modpost: various fixes, cleanups, optimizations Masahiro Yamada
2020-05-17  9:48 ` [PATCH 01/29] modpost: drop RCS/CVS $Revision handling in MODULE_VERSION() Masahiro Yamada
2020-05-17  9:48 ` [PATCH 02/29] modpost: do not call get_modinfo() for vmlinux Masahiro Yamada
2020-05-17  9:48 ` [PATCH 03/29] modpost: add read_text_file() and get_line() helpers Masahiro Yamada
2020-05-19 10:21   ` Peter Zijlstra
2020-05-20 12:17     ` Masahiro Yamada
2020-05-20 12:29       ` Peter Zijlstra
2020-05-23  4:18         ` Masahiro Yamada
2020-05-17  9:48 ` [PATCH 04/29] modpost: fix potential mmap'ed file overrun in get_src_version() Masahiro Yamada
2020-05-17  9:48 ` [PATCH 05/29] modpost: re-add warning about missing *.mod file Masahiro Yamada
2020-05-17  9:48 ` [PATCH 06/29] modpost: avoid false-positive file open error Masahiro Yamada
2020-05-17  9:48 ` [PATCH 07/29] modpost: use read_text_file() and get_line() for reading text files Masahiro Yamada
2020-05-17  9:48 ` [PATCH 08/29] modpost: remove get_next_text() and make {grab,release_}file static Masahiro Yamada
2020-05-17  9:48 ` [PATCH 09/29] kbuild: disallow multi-word in M= or KBUILD_EXTMOD Masahiro Yamada
2020-05-17 12:33   ` David Laight
2020-05-21  3:57     ` Masahiro Yamada
2020-05-17  9:48 ` [PATCH 10/29] modpost: move -T option close to the modpost command Masahiro Yamada
2020-05-17  9:48 ` [PATCH 11/29] modpost: pass -N option only for modules modpost Masahiro Yamada
2020-05-17  9:48 ` [PATCH 12/29] modpost: move external module options Masahiro Yamada
2020-05-17  9:48 ` [PATCH 13/29] modpost: load KBUILD_EXTRA_SYMBOLS files in order Masahiro Yamada
2020-05-17  9:48 ` [PATCH 14/29] modpost: track if the symbol origin is a dump file or ELF object Masahiro Yamada
2020-05-17  9:48 ` [PATCH 15/29] modpost: allow to pass -i option multiple times remove -e option Masahiro Yamada
2020-05-17  9:48 ` [PATCH 16/29] modpost: rename ext_sym_list to dump_list Masahiro Yamada
2020-05-17  9:48 ` [PATCH 17/29] modpost: re-add -e to set external_module flag Masahiro Yamada
2020-05-17  9:48 ` [PATCH 18/29] modpost: show warning if vmlinux is not found when processing modules Masahiro Yamada
2020-05-17  9:48 ` [PATCH 19/29] modpost: show warning if it fails to read symbol dump file Masahiro Yamada
2020-05-17  9:48 ` Masahiro Yamada [this message]
2020-05-17  9:48 ` [PATCH 21/29] modpost: remove -s option Masahiro Yamada
2020-05-17  9:48 ` [PATCH 22/29] modpost: remove mod->is_dot_o struct member Masahiro Yamada
2020-05-17  9:48 ` [PATCH 23/29] modpost: remove is_vmlinux() call in check_for_{gpl_usage,unused}() Masahiro Yamada
2020-05-17  9:48 ` [PATCH 24/29] modpost: add mod->is_vmlinux struct member Masahiro Yamada
2020-05-17  9:48 ` [PATCH 25/29] modpost: remove mod->skip " Masahiro Yamada
2020-05-17  9:48 ` [PATCH 26/29] modpost: set have_vmlinux in new_module() Masahiro Yamada
2020-05-17  9:48 ` [PATCH 27/29] modpost: strip .o from modname before calling new_module() Masahiro Yamada
2020-05-17  9:48 ` [PATCH 28/29] modpost: remove is_vmlinux() helper Masahiro Yamada
2020-05-17  9:48 ` [PATCH 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=20200517094859.2376211-21-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=jeyu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).