Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)

From: matoro
Date: Mon Aug 08 2022 - 14:43:25 EST


That patch doesn't apply to the v5.19 stable tag, so I just manually edited and it worked perfect! Thank you!!

Sorry I didn't mention that warning - I did see it, but it still showed up even on the old kernel, so I thought it was irrelevant. Much appreciated!

-------- Original Message --------
Subject: Re: [PATCH v6 00/10] kbuild: yet another series of cleanups (modpost, LTO, MODULE_REL_CRCS, export.h)
Date: 2022-08-08 13:36
From: Masahiro Yamada <masahiroy@xxxxxxxxxx>
To: matoro <matoro_mailinglist_kernel@xxxxxxxxx>

On Mon, Aug 8, 2022 at 10:27 PM matoro
<matoro_mailinglist_kernel@xxxxxxxxx> wrote:

I have real hardware for all these arches in my collection. I use it
for testing the latest kernel and toolchains on as many of the
less-popular arches as possible, exactly to find issues like this one :)

Specifically we support all of these in Gentoo. To double-check this
wasn't a config issue, I asked another user who also runs sparc to try
building 5.19 with his config (not copying mine), and he observed the
same problem. You can reach us in #gentoo-sparc on Libera.

As for testing, I make all this hardware available on an as-needed
basis. So if you can't or don't want to fiddle with qemu, just let me
know (email or IRC, same username on Libera), and I will get you direct
access to my hardware. Thanks!!


I found the root cause.

When I build the sparc kernel, I see a warning

WARNING: modpost: EXPORT symbol "_mcount" [vmlinux] version generation
failed, symbol will not be versioned.


Then, modpost missed to write out the entry.

With the following patch, you will be able to load the module.

I will send a patch with a proper commit log tomorrow. I need some sleep now.



diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 29474cee10b1..337bd36a890a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2206,13 +2206,11 @@ static void add_exported_symbols(struct buffer
*buf, struct module *mod)
/* record CRCs for exported symbols */
buf_printf(buf, "\n");
list_for_each_entry(sym, &mod->exported_symbols, list) {
- if (!sym->crc_valid) {
+ if (!sym->crc_valid)
warn("EXPORT symbol \"%s\" [%s%s] version
generation failed, symbol will not be versioned.\n"
"Is \"%s\" prototyped in
<asm/asm-prototypes.h>?\n",
sym->name, mod->name, mod->is_vmlinux ? "" : ".ko",
sym->name);
- continue;
- }

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