From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Sasha Levin <sashal@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
Alexey Gladkov <legion@kernel.org>,
Masahiro Yamada <masahiroy@kernel.org>,
Kees Cook <kees@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH] kbuild: keep .modinfo when vmlinux is linked with --gc-sections
Date: Mon, 28 Sep 2026 12:15:46 +0100 [thread overview]
Message-ID: <arpLoeLVATRCXm5E@gremlin> (raw)
In-Reply-To: <20260927161227.1179863-1-sashal@kernel.org>
On Sun, Sep 27, 2026 at 12:12:27PM -0400, Sasha Levin wrote:
> Builds with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y, such as arm
> allmodconfig, now fail while extracting modules.builtin.modinfo:
>
> arm-linux-gnueabihf-objcopy: vmlinux.unstripped: can't dump section
> '.modinfo' - it does not exist: file format not recognized
> /bin/sh: 1: cannot open modules.builtin.modinfo: No such file
>
> or, with LLVM:
>
> llvm-objcopy: error: 'vmlinux.unstripped': section '.modinfo' not
> found
>
> Nothing references the MODULE_INFO() strings, so --gc-sections
> discards every .modinfo input section and vmlinux.unstripped ends up
> with no .modinfo data. This is not new: ever since
> modules.builtin.modinfo started being extracted from
> vmlinux.unstripped, these builds have silently produced an empty
> file, losing the modinfo of every built-in module. An arm
> multi_v7_defconfig build with LD_DEAD_CODE_DATA_ELIMINATION on current
> mainline yields a 0 byte modules.builtin.modinfo. The switch to
> --dump-section only turned that into a build error.
Yikes, so an existing bug but now exposed by my series.
>
> Wrap the input section in KEEP() so that the linker retains it. The
> output section is still (INFO), so nothing is allocated for it. With
> the same arm config, modules.builtin.modinfo now has 14119 entries,
> and on x86_64 defconfig, where nothing is garbage collected, it is
> byte-identical before and after this change.
Sounds reasonable.
>
> Found by KernelCI builds of the linus-next tree.
>
> Fixes: 39cfd5b12160 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped")
> Fixes: 5fe4dd596641 ("kbuild: do not allocate .modinfo in vmlinux")
> Assisted-by: LLM
> Signed-off-by: Sasha Levin <sashal@kernel.org>
Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Nathan - do you want me to fold this into the 1st patch of my series on respin
or fine to treat separately?
> ---
> include/asm-generic/vmlinux.lds.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index a6730d34e8c67..7a3e9f00d6283 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -855,7 +855,7 @@
> KLP_SYMID
>
> #define MODINFO \
> - .modinfo (INFO) : { *(.modinfo) }
> + .modinfo (INFO) : { KEEP(*(.modinfo)) }
>
> #ifdef CONFIG_GENERIC_BUG
> #define BUG_TABLE \
> --
> 2.53.0
>
--
Cheers, Lorenzo
next prev parent reply other threads:[~2026-09-28 11:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 16:12 Sasha Levin
2026-09-28 11:15 ` Lorenzo Stoakes (ARM) [this message]
2026-09-28 11:56 ` Nathan Chancellor
2026-09-28 12:16 ` Lorenzo Stoakes (ARM)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=arpLoeLVATRCXm5E@gremlin \
--to=ljs@kernel.org \
--cc=arnd@arndb.de \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=legion@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@kernel.org \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nsc@kernel.org \
--cc=sashal@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®