linux/include
Sasha Levin a98db74187
kbuild: keep .modinfo when vmlinux is linked with --gc-sections
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.

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.

Found by KernelCI builds of the linus-next tree.

Fixes: 39cfd5b121 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped")
Fixes: 5fe4dd5966 ("kbuild: do not allocate .modinfo in vmlinux")
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@kernel.org>
Link: https://patch.msgid.link/20260927161227.1179863-1-sashal@kernel.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-09-27 20:35:12 +02:00
..
acpi ACPI: bus: Drop two fields from struct acpi_device_pnp 2026-09-01 21:45:50 +02:00
asm-generic kbuild: keep .modinfo when vmlinux is linked with --gc-sections 2026-09-27 20:35:12 +02:00
clocksource hyperv-next for v7.3-rc1 2026-08-26 16:47:40 -07:00
crypto
cxl
drm Merge drm/drm-fixes into drm-misc-fixes 2026-09-01 09:38:51 +02:00
dt-bindings sound fixes for 7.3-rc1 2026-08-28 10:01:02 -07:00
hyperv
keys tpm: Initial step to reorganize TPM public headers 2026-08-25 18:13:35 +03:00
kunit
kvm KVM/arm64 changes for 7.3 2026-08-24 12:42:07 -04:00
linux tracing fixes for v7.3: 2026-09-06 14:21:24 -07:00
math-emu
media
memory
misc
net ipv6: mcast: use copy-on-write RCU updates in ip6_mc_source() 2026-08-31 17:54:45 -07:00
pcmcia
ras
rdma
rv mm.git review status for linus..mm-stable 2026-08-27 09:17:06 -07:00
scsi SCSI updates for 7.3 2026-08-29 11:55:36 -07:00
soc Mostly the usual clk driver updates and new SoC additions plus non-critical 2026-08-26 11:14:30 -07:00
sound ALSA: rawmidi: Another workaround for false-positive mutex lockdep warning 2026-08-25 15:55:37 +02:00
target
trace Including fixes from bluetooth. 2026-09-03 10:18:12 -07:00
uapi integrity-v7.3-rc2 2026-09-04 19:36:11 -07:00
ufs
vdso
video
xen
Kbuild