summaryrefslogtreecommitdiff
path: root/scripts/mod
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2021-03-25 21:54:09 +0300
committerMasahiro Yamada <masahiroy@kernel.org>2021-04-24 23:17:02 +0300
commit69bc8d386aebbd91a6bb44b6d33f77c8dfa9ed8c (patch)
treed3f29eb4a12db432954a82a46a1b3b324e82f88b /scripts/mod
parent987fdfec24102a151c032c467e51c7f0d6d18af9 (diff)
downloadlinux-69bc8d386aebbd91a6bb44b6d33f77c8dfa9ed8c.tar.xz
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. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/mod')
-rw-r--r--scripts/mod/modpost.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 24725e50c7b4..10c3fba26f03 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2423,19 +2423,6 @@ fail:
fatal("parse error in symbol dump file\n");
}
-/* For normal builds always dump all symbols.
- * For external modules only dump symbols
- * that are not read from kernel Module.symvers.
- **/
-static int dump_sym(struct symbol *sym)
-{
- if (!external_module)
- return 1;
- if (sym->module->from_dump)
- return 0;
- return 1;
-}
-
static void write_dump(const char *fname)
{
struct buffer buf = { };
@@ -2446,7 +2433,7 @@ static void write_dump(const char *fname)
for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
symbol = symbolhash[n];
while (symbol) {
- if (dump_sym(symbol)) {
+ if (!symbol->module->from_dump) {
namespace = symbol->namespace;
buf_printf(&buf, "0x%08x\t%s\t%s\t%s\t%s\n",
symbol->crc, symbol->name,