* [PATCH] MIPS: vmlinux.lds.S: Keep .sbss in every vmlinux link
@ 2026-11-30 15:10 Imre Kaloz
2026-12-05 13:40 ` Thomas Bogendoerfer
0 siblings, 1 reply; 3+ messages 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] 3+ messages in thread* Re: [PATCH] MIPS: vmlinux.lds.S: Keep .sbss in every vmlinux link
2026-11-30 15:10 [PATCH] MIPS: vmlinux.lds.S: Keep .sbss in every vmlinux link Imre Kaloz
@ 2026-12-05 13:40 ` Thomas Bogendoerfer
2026-12-05 15:02 ` Imre Kaloz
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Bogendoerfer @ 2026-12-05 13:40 UTC (permalink / raw)
To: Imre Kaloz
Cc: linux-mips, Nathan Chancellor, Nicolas Schier, Nicolas Schier,
Lorenzo Stoakes (ARM), Kees Cook, linux-kbuild
On Mon, Nov 30, 2026 at 04:10:45PM +0100, Imre Kaloz wrote:
> 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")
is this a problem in MIPS gas or with the commit ?
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] MIPS: vmlinux.lds.S: Keep .sbss in every vmlinux link
2026-12-05 13:40 ` Thomas Bogendoerfer
@ 2026-12-05 15:02 ` Imre Kaloz
0 siblings, 0 replies; 3+ messages in thread
From: Imre Kaloz @ 2026-12-05 15:02 UTC (permalink / raw)
To: Thomas Bogendoerfer
Cc: linux-mips, Nathan Chancellor, Nicolas Schier, Nicolas Schier,
Lorenzo Stoakes (ARM), Kees Cook, linux-kbuild
Hi Thomas,
On Sat, Dec 5, 2026, at 14:40, Thomas Bogendoerfer wrote:
> On Mon, Nov 30, 2026 at 04:10:45PM +0100, Imre Kaloz wrote:
>> 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")
>
> is this a problem in MIPS gas or with the commit ?
A bit of both. The commit relies on the trial links and the final
link producing the same symbols, with --emit-relocs only on the final
one. On MIPS that flag decides whether an empty .sbss survives.
gas puts a local common in .sbss whenever its size is at most -G
(bss_alloc() in gas/read.c), and gcc emits a zero-sized static as a
plain .local/.comm pair, so even at -G 0 it lands in .sbss. When .sbss
holds nothing else, ld drops the empty output section together with
those symbols, unless --emit-relocs is given. Before 8050568e0a46
every link of a relocatable vmlinux had --emit-relocs, so it never
showed.
gas could keep zero-sized commons out of .sbss, but that would only
help with a new binutils, and the same test is in 2.30, the kernel's
minimum. Keeping .sbss in the linker script needs no assembler change
and leaves the final link output unchanged.
Thanks,
Imre
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-05 15:02 UTC | newest]
Thread overview: 3+ messages (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
2026-12-05 13:40 ` Thomas Bogendoerfer
2026-12-05 15:02 ` Imre Kaloz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.