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
68ifeq ($(KBUILD_EXTMOD),)68ifeq ($(KBUILD_EXTMOD),)
69 69
70input-symdump := vmlinux.symvers70input-symdump := vmlinux.symvers
71output-symdump := Module.symvers71output-symdump := modules-only.symvers
72
73quiet_cmd_cat = GEN $@
74 cmd_cat = cat $(real-prereqs) > $@
75
76ifneq ($(wildcard vmlinux.symvers),)
77
78__modpost: Module.symvers
79Module.symvers: vmlinux.symvers modules-only.symvers FORCE
80 $(call if_changed,cat)
81
82targets += Module.symvers
83
84endif
72 85
73else86else
74 87
scripts/mod/modpost.c+1−14
@@ -2423,19 +2423,6 @@ fail: · 2422 unmodified lines
2423 fatal("parse error in symbol dump file\n");2423 fatal("parse error in symbol dump file\n");
2424}2424}
2425 2425
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 **/
2430static 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
2439static void write_dump(const char *fname)2426static void write_dump(const char *fname)
2440{2427{
2441 struct buffer buf = { };2428 struct buffer buf = { };
@@ -2446,7 +2433,7 @@ static void write_dump(const char *fname) · 4 unmodified lines
2446 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {2433 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
2447 symbol = symbolhash[n];2434 symbol = symbolhash[n];
2448 while (symbol) {2435 while (symbol) {
2449 if (dump_sym(symbol)) {2436 if (!symbol->module->from_dump) {
2450 namespace = symbol->namespace;2437 namespace = symbol->namespace;
2451 buf_printf(&buf, "0x%08x\t%s\t%s\t%s\t%s\n",2438 buf_printf(&buf, "0x%08x\t%s\t%s\t%s\t%s\n",
2452 symbol->crc, symbol->name,2439 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