Skip to content

Commit 5b8a9a8

Browse files
committed
modpost: fix module versioning when a symbol lacks valid CRC
Since commit 7b45371 ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS"), module versioning is broken on some architectures. Loading a module fails with "disagrees about version of symbol module_layout". On such architectures (e.g. ARCH=sparc build with sparc64_defconfig), modpost shows a warning, like follows: WARNING: modpost: EXPORT symbol "_mcount" [vmlinux] version generation failed, symbol will not be versioned. Is "_mcount" prototyped in <asm/asm-prototypes.h>? Previously, it was a harmless warning (CRC check was just skipped), but now wrong CRCs are used for comparison because invalid CRCs are just skipped. $ sparc64-linux-gnu-nm -n vmlinux [snip] 0000000000c2cea0 r __ksymtab__kstrtol 0000000000c2ceb8 r __ksymtab__kstrtoul 0000000000c2ced0 r __ksymtab__local_bh_enable 0000000000c2cee8 r __ksymtab__mcount 0000000000c2cf00 r __ksymtab__printk 0000000000c2cf18 r __ksymtab__raw_read_lock 0000000000c2cf30 r __ksymtab__raw_read_lock_bh [snip] 0000000000c53b34 D __crc__kstrtol 0000000000c53b38 D __crc__kstrtoul 0000000000c53b3c D __crc__local_bh_enable 0000000000c53b40 D __crc__printk 0000000000c53b44 D __crc__raw_read_lock 0000000000c53b48 D __crc__raw_read_lock_bh Please notice __crc__mcount is missing here. When the module subsystem looks up a CRC that comes after, it results in reading out a wrong address. For example, when __crc__printk is needed, the module subsystem reads 0xc53b44 instead of 0xc53b40. All CRC entries must be output for correct index accessing. Invalid CRCs will be unused, but are needed to keep the one-to-one mapping between __ksymtab_* and __crc_*. The best is to fix all modpost warnings, but several warnings are still remaining on less popular architectures. Fixes: 7b45371 ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") Reported-by: matoro <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Tested-by: matoro <[email protected]>
1 parent 568035b commit 5b8a9a8

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

scripts/mod/modpost.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,13 +2021,11 @@ static void add_exported_symbols(struct buffer *buf, struct module *mod)
20212021
/* record CRCs for exported symbols */
20222022
buf_printf(buf, "\n");
20232023
list_for_each_entry(sym, &mod->exported_symbols, list) {
2024-
if (!sym->crc_valid) {
2024+
if (!sym->crc_valid)
20252025
warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n"
20262026
"Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n",
20272027
sym->name, mod->name, mod->is_vmlinux ? "" : ".ko",
20282028
sym->name);
2029-
continue;
2030-
}
20312029

20322030
buf_printf(buf, "SYMBOL_CRC(%s, 0x%08x, \"%s\");\n",
20332031
sym->name, sym->crc, sym->is_gpl_only ? "_gpl" : "");

0 commit comments

Comments
 (0)