Skip to content

Commit

Permalink
modpost: generate vmlinux.symvers and reuse it for the second modpost
Browse files Browse the repository at this point in the history
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 in the same
way 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 <[email protected]>
  • Loading branch information
masahir0y committed Jun 6, 2020
1 parent f1005b3 commit 269a535
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ modules.order
/linux
/vmlinux
/vmlinux.32
/vmlinux.symvers
/vmlinux-gdb.py
/vmlinuz
/System.map
Expand Down
1 change: 1 addition & 0 deletions Documentation/dontdiff
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ vmlinux-*
vmlinux.aout
vmlinux.bin.all
vmlinux.lds
vmlinux.symvers
vmlinuz
voffset.h
vsyscall.lds
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,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'
Expand Down
7 changes: 4 additions & 3 deletions scripts/Makefile.modpost
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,19 @@ ifdef MODPOST_VMLINUX
quiet_cmd_modpost = MODPOST $@
cmd_modpost = $(MODPOST) $<

Module.symvers: vmlinux.o
vmlinux.symvers: vmlinux.o
$(call cmd,modpost)

__modpost: Module.symvers
__modpost: vmlinux.symvers

else

MODPOST += -s \
$(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))

ifeq ($(KBUILD_EXTMOD),)
MODPOST += $(wildcard vmlinux)

input-symdump := vmlinux.symvers
output-symdump := Module.symvers

else
Expand Down
2 changes: 0 additions & 2 deletions scripts/link-vmlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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*)
Expand Down

0 comments on commit 269a535

Please sign in to comment.