History

kbuild: generate Module.symvers only when vmlinux exists

The external module build shows the following warning if Module.symvers is missing in the kernel tree. WARNING: Symbol version dump "Module.symvers" is missing. Modules may not have dependencies or modversions. I think this is an important heads-up because the resulting modules may not work as expected. This happens when you did not build the entire kernel tree, for example, you might have prepared the minimal setups for external modules by 'make defconfig && make modules_preapre'. A problem is that 'make modules' creates Module.symvers even without vmlinux. In this case, that warning is suppressed since Module.symvers already exists in spite of its incomplete content. The incomplete (i.e. invalid) Module.symvers should not be created. This commit changes the second pass of modpost to dump symbols into modules-only.symvers. The final Module.symvers is created by concatenating vmlinux.symvers and modules-only.symvers if both exist. Module.symvers is supposed to collect symbols from both vmlinux and modules. It might be a bit confusing, and I am not quite sure if it is an official interface, but presumably it is difficult to rename it because some tools (e.g. kmod) parse it.

Masahiro Yamada committed 5 years ago

Commit 69bc8d31 parent 987fdfe5 files · +18 −16Browse files

Unified · Split

5 files
  1. .gitignore +1 −0
  2. Documentation/dontdiff +1 −0
  3. Makefile +1 −1
  4. scripts/Makefile.modpost +14 −1
  5. scripts/mod/modpost.c +1 −14
.gitignore+1−0
@@ -57,6 +57,7 @@ modules.order · 56 unmodified lines
5757 /tags
5858 /TAGS
5959 /linux
60+/modules-only.symvers
6061 /vmlinux
6162 /vmlinux.32
6263 /vmlinux.map
Documentation/dontdiff+1−0
@@ -178,6 +178,7 @@ mktables · 177 unmodified lines
178178 mktree
179179 mkutf8data
180180 modpost
181+modules-only.symvers
181182 modules.builtin
182183 modules.builtin.modinfo
183184 modules.nsdeps
Makefile+1−1
@@ -1532,7 +1532,7 @@ endif # CONFIG_MODULES · 1531 unmodified lines
15321532 # make distclean Remove editor backup files, patch leftover files and the like
15331533
15341534 # Directories & files removed with 'make clean'
1535−CLEAN_FILES += include/ksym vmlinux.symvers \
1535+CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
15361536 modules.builtin modules.builtin.modinfo modules.nsdeps \
15371537 compile_commands.json .thinlto-cache
15381538
scripts/Makefile.modpost+14−1
@@ -68,7 +68,20 @@ else · 67 unmodified lines
6868 ifeq ($(KBUILD_EXTMOD),)
6969
7070 input-symdump := vmlinux.symvers
71−output-symdump := Module.symvers
71+output-symdump := modules-only.symvers
72+
73+quiet_cmd_cat = GEN $@
74+ cmd_cat = cat $(real-prereqs) > $@
75+
76+ifneq ($(wildcard vmlinux.symvers),)
77+
78+__modpost: Module.symvers
79+Module.symvers: vmlinux.symvers modules-only.symvers FORCE
80+ $(call if_changed,cat)
81+
82+targets += Module.symvers
83+
84+endif
7285
7386 else
7487
scripts/mod/modpost.c+1−14
@@ -2423,19 +2423,6 @@ fail: · 2422 unmodified lines
24232423 fatal("parse error in symbol dump file\n");
24242424 }
24252425
2426−/* For normal builds always dump all symbols.
2427− * For external modules only dump symbols
2428− * that are not read from kernel Module.symvers.
2429− **/
2430−static int dump_sym(struct symbol *sym)
2431−{
2432− if (!external_module)
2433− return 1;
2434− if (sym->module->from_dump)
2435− return 0;
2436− return 1;
2437−}
2438−
24392426 static void write_dump(const char *fname)
24402427 {
24412428 struct buffer buf = { };
@@ -2446,7 +2433,7 @@ static void write_dump(const char *fname) · 4 unmodified lines
24462433 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
24472434 symbol = symbolhash[n];
24482435 while (symbol) {
2449− if (dump_sym(symbol)) {
2436+ if (!symbol->module->from_dump) {
24502437 namespace = symbol->namespace;
24512438 buf_printf(&buf, "0x%08x\t%s\t%s\t%s\t%s\n",
24522439 symbol->crc, symbol->name,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t