Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] MIPS: vmlinux.lds.S: Keep .sbss in every vmlinux link
@ 2026-11-30 15:10 Imre Kaloz
  0 siblings, 0 replies; only message in thread
From: Imre Kaloz @ 2026-11-30 15:10 UTC (permalink / raw)
  To: Thomas Bogendoerfer, linux-mips
  Cc: Nathan Chancellor, Nicolas Schier, Nicolas Schier,
	Lorenzo Stoakes (ARM), Kees Cook, linux-kbuild

Since commit 8050568e0a46 ("kbuild: only emit vmlinux relocations when
required"), MIPS CONFIG_RELOCATABLE builds with zero-sized local
objects, such as a lock_class_key without LOCKDEP, fail with
"Inconsistent kallsyms data".

gas puts a local common in .sbss when its size is at most -G, so with
-G 0 every zero-sized one lands there. ld drops an empty .sbss and its
symbols, except in the final link that emits relocations.

Keep .sbss in every link with ". = .", which means open-coding
BSS_SECTION(). A non-relocatable vmlinux gains an empty .sbss.

Fixes: 8050568e0a46 ("kbuild: only emit vmlinux relocations when required")
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
---
Reproducer: a MIPS build with CONFIG_RELOCATABLE=y and zero-sized
local objects in .sbss, for example malta_defconfig plus
CONFIG_RELOCATABLE=y without LOCKDEP, fails at the System.map check
since v7.4-rc1.

Build-tested with gcc 13.3.0 and binutils 2.44: relocatable malta, and
64r2el with CONFIG_RELOCATION_TABLE_SIZE=0x200000, link again,
System.map matches the last kallsyms pass, and the final vmlinux link
output does not change. Non-relocatable malta builds still link.

Boot-tested on QEMU Malta: 32-bit and 64-bit relocatable kernels with
and without KASLR, and non-relocatable before and after the change.
Not tested with ld.lld.

 arch/mips/kernel/vmlinux.lds.S | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 579b2cc1995a..aa855a67847e 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -198,7 +198,22 @@ SECTIONS
 	 * Force .bss to 64K alignment so that .bss..swapper_pg_dir
 	 * gets that alignment.	 .sbss should be empty, so there will be
 	 * no holes after __init_end. */
-	BSS_SECTION(0, 0x10000, 8)
+	__bss_start = .;
+	.sbss : AT(ADDR(.sbss) - LOAD_OFFSET) {
+		*(.dynsbss)
+		*(SBSS_MAIN)
+		*(.scommon)
+		/*
+		 * gas puts zero-sized local objects in .sbss even with -G 0.
+		 * ld drops an empty .sbss and the symbols in it, except in
+		 * the --emit-relocs link, so the kallsyms passes would not
+		 * match the final symbol table. Keep it in every link.
+		 */
+		. = .;
+	}
+	BSS(0x10000)
+	. = ALIGN(8);
+	__bss_stop = .;
 
 	_end = . ;
 

base-commit: 4f069ab1ec243e6b60dc438772905855c60774e8
-- 
2.47.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-30 15:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 15:10 [PATCH] MIPS: vmlinux.lds.S: Keep .sbss in every vmlinux link Imre Kaloz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox