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

Showing the changes to scripts (2 of 5 files). Show all

Unified · Split

2 files
  1. scripts/Makefile.modpost +14 −1
  2. scripts/mod/modpost.c +1 −14
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