From: Imre Kaloz <kaloz@kernel.org>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
linux-mips@vger.kernel.org
Cc: Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
Nicolas Schier <n.schier@fritz.com>,
"Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
Kees Cook <kees@kernel.org>,
linux-kbuild@vger.kernel.org
Subject: [PATCH] MIPS: vmlinux.lds.S: Keep .sbss in every vmlinux link
Date: Mon, 30 Nov 2026 16:10:45 +0100 [thread overview]
Message-ID: <20261130151047.14743-1-kaloz@kernel.org> (raw)
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
next reply other threads:[~2026-11-30 15:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 15:10 Imre Kaloz [this message]
2026-12-05 13:40 ` [PATCH] MIPS: vmlinux.lds.S: Keep .sbss in every vmlinux link Thomas Bogendoerfer
2026-12-05 15:02 ` Imre Kaloz
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=20261130151047.14743-1-kaloz@kernel.org \
--to=kaloz@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=n.schier@fritz.com \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=tsbogend@alpha.franken.de \
/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 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.