From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796051453; b=uBIwTDq78GstZQ9CF5+QBKSfdulqvxIZf3RlpJMI97D3z41RUjHkwQ9F2Yj9SZRJw+w6 dxXU1qDWXlOw0KHjTOKGnMo9lWtgoEcN5ngfQ+M6aK57HCiC+liSRFsX7eIXPytYycvbJ fJU3TSLDscu6SlXJ/Vl78vHQ2/UrOm/yAjwe30qUoUw0WE0wvi7Ol/pdziCNKXdce4cBv nIjvJEOvvwSysdA+/L/lAIz84wmI20wioSv1f5MViqg8ceKvvhC1tNAxyWjAtHc8n7YHk lcDgBWxS/Al7lf4HPsKLt5O5jfNvzfWHijGP9mnPZ3/7c2Jvjv/yhE/RSJju8i8BvBg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796051453; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=CZWthIRyrZuvbZbPcYiMFTceZfJ2RXWudU4F1ju8/Hk=; b=g3yvCOKZqww3/P9wvFvW+VJmAisLTIIjToAFtcCblFrIpUgtflK/NY6Ase7ayPE+kKlu t2haABQbF6AGpOGJh2mzhwiTuYcB0P/3PJ4t2yoe6BFC/DrMVciZtW5jK92Xia0DKA2vB Pt4EwSO2l9ACfUef31khyDfArKST6FkjYsgX5PyXoSXebQSBpLx0IKZbw5PeRQxvg8bDx y6MW6fhnuOf48BAx4BwBPsrQHfNbaOsCSTBHd1l8sHXzd2WfgZMlsxXaH2aLTb5oMVWgP 00fVJiRRjdP3jltvmmMVd1UIqh6aMw6Q//Cb/08uuMrzooU6R+LmkFIXNWF71WFHqJA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QbJeiSJf; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CB3D606A31C; Mon, 30 Nov 2026 15:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QbJeiSJf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79E0E1F00897; Mon, 30 Nov 2026 15:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796051452; bh=CZWthIRyrZuvbZbPcYiMFTceZfJ2RXWudU4F1ju8/Hk=; h=From:To:Cc:Subject:Date; b=QbJeiSJf3F/ILkfx/G5i8oRtsXkF1fwaU9OOusCTefcf1GL/9hn4lSZm1cKCOn2WD Vgs3UB4sBelN/6T7ctkhLn5Ffzg3GGGw2NFa0VFMuvJqOaSaiJPinLTvwUwolGKGW1 mUFMvfL1XJWw4Q4jARkM6f1/z3688Mv2gr0dNTF6eklSnFCZ7d7zN9EsQyYKuOYTJ0 kGGwWpJsymipaKB/E+rBaRt5DcEWIVGPBaDRwVDMST45Smp9CHGJ7UFefodCSWOcp/ lwUUi9yoN9sb6jVtOxKkSicOztKGKm/Zj03Q/ubgkJdIli/YbNmKc+d/KH1aNQ6Wyv ccj32C0l/JbZA== From: Imre Kaloz To: Thomas Bogendoerfer , linux-mips@vger.kernel.org Cc: Nathan Chancellor , Nicolas Schier , Nicolas Schier , "Lorenzo Stoakes (ARM)" , Kees Cook , 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 Message-ID: <20261130151047.14743-1-kaloz@kernel.org> X-Mailer: git-send-email 2.47.3 X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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