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=1793362540; b=Ih8sl4Q6qB4V3ovyRwpBVGH8iAM9cdpDegM4Y0KATayzYN/tbKL+d3QgcoCxnimgQBIl 7VBsC5U6t8WIW/f/xsCx/yKmD+RcDpDLPCXpNBC/PS+HKM49zAjQjJi3NkxvfYgpDIaZ7 WmTAawI77cwTYisFGnlaAlRh062xLkSHlCAB9ir9STGFllzOGVAIgaZq4qHvevx5ZPcrC HysjNABDefI//oOPgrBVzQh46N0Uj4rGTQLkGyN/Rh0mN4N6tzUBRCWfi6UF7nw+gSr4y GyTjS1JzW0dX6ucx+XrkEo6gf24AnSdyZqFEnwO2Ig5yt4/MIw3hd85Q0Yve+XZZ19g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793362540; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=+ChWnRDfm75DU6tFeqkpqunSUflt5Kc60va/+iNuvBw=; b=lqoztwwk+bjXT+amTx+6iVkYJcLHkZjizFyxlR9lGGB67VFKmaedYTBP/7Xz6xah1rIR opLyqqc4d6+GRsQP+1xPQkpfwAGTbinDumed/a+jLjX4eS4E9o9vGZO7KCLTcAAragiX+ PLEI3kVZ7lI5ZUT9b5qHlHK3Jr290O0awUzJtxXiXkX06RuxtTH0JxVKs8Aek+d9mEbSv QzS5zJU/EI6b7vU0/QteaBM8zzr6Fj/a4tJd2B37D4xI0jCFFINbo9uTIZN/Y0CRNCyWP MKTTrooQw2ri+vmFA9RWzj4YnFjfWinBSbW42nrEjis0VSYgvIi3BbwmJVXLkGKtfBg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2CyvzfRi; 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 35538606A31D; Fri, 30 Oct 2026 12:15:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2CyvzfRi Received: by smtp.kernel.org (Postfix) with ESMTPSA id 305361F000C1; Fri, 30 Oct 2026 12:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793362539; bh=+ChWnRDfm75DU6tFeqkpqunSUflt5Kc60va/+iNuvBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2CyvzfRieCpry3VGBSMyOKsYi0wCdqAleEp6FIUxGDN0nVf+I4SwNW4u1PQWPeKwj b1MrPZXAbF0Pdkhz2z+e38/pQRe0td8g9rI7kH0fOflRaJu6anMSBqk4AAkdxutAgp NuX8/6aGSXqwK8wtbFUDFBOUR4o7LnyHfpViXqJg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Andr=C3=A9=20Draszik?= , Nathan Chancellor , Nicolas Schier , Sasha Levin Subject: [PATCH 7.2 07/10] kbuild: link-vmlinux.sh: improve detection of third pass requirement Date: Fri, 30 Oct 2026 13:15:08 +0100 Message-ID: <20261030121255.437290861@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261030121255.257615100@linuxfoundation.org> References: <20261030121255.257615100@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: André Draszik [ Upstream commit 14b8b4bf2d7bd5d58c17adbeed0edfda1dfc1a7f ] It can happen that symbol sizes within .tmp_vmlinux1.kallsyms.o and .tmp_vmlinux2.kallsyms.o differ, without affecting file size on disk because of section alignment and/or padding emitted by the assembler. link-vmlinux.sh doesn't detect this case currently and keeps using .tmp_vmlinux2.kallsyms.o to link the final vmlinux. Due to the different symbol sizes, other symbols are shifted within the final image compared to .tmp_vmlinux2, and the final comparison of System.map against "${kallsyms_sysmap}" fails with the message: Inconsistent kallsyms data Try "make KALLSYMS_EXTRA_PASS=1" as a workaround This can happen in particular if the linker emits additional symbols that might have different names between our (re-)linking steps, e.g. because those names depend on the virtual address of the symbol. Linker stubs for ARM errata work-arounds are one such case. These changed symbol names can cause the output of the token compression of kallsyms.c to change due to the changed symbol substring count, which in turn can change the size of the kallsyms_names symbol itself, causing the potential shift of subsequent symbol addresses in .tmp_vmlinux2.kallsyms.o and therefore the final image. Update link-vmlinux.sh to not rely on file size of .tmp_vmlinux?.kallsyms.o alone but to also consider symbol offsets within to resolve this, and do a third pass if required. Signed-off-by: André Draszik Tested-by: Nathan Chancellor Reviewed-by: Nicolas Schier Signed-off-by: Nicolas Schier Signed-off-by: Sasha Levin --- scripts/link-vmlinux.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index f99e196abeea4..a032560eda0e8 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -106,6 +106,18 @@ vmlinux_link() ${kallsymso} ${btf_vmlinux_bin_o} ${arch_vmlinux_o} ${ldlibs} } +# Check if kallsymso_prev and kallsymso differ +# If symbol sizes within ${kallsymso} change, any symbols within vmlinux are +# likely to shift, invalidating ${kallsymso}. +# Since file size can remain unchanged even if symbol sizes change, compare the +# actual symbols instead of relying on file size only. +kallsymso_changed() +{ + ${NM} -n "${kallsymso_prev}" > "${kallsymso_prev}.sym" + ${NM} -n "${kallsymso}" > "${kallsymso}.sym" + ! cmp -s "${kallsymso_prev}.sym" "${kallsymso}.sym" +} + # Create ${2}.o file with all symbols from the ${1} object file kallsyms() { @@ -126,6 +138,7 @@ kallsyms() ${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \ ${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} -c -o "${2}.o" "${2}.S" + kallsymso_prev="${kallsymso:-}" kallsymso=${2}.o } @@ -255,7 +268,12 @@ if is_enabled CONFIG_KALLSYMS; then sysmap_and_kallsyms .tmp_vmlinux2 size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso}) - if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then + # Due to alignment, file size of the kallsymso object file might remain + # unchanged even if individual symbols within change size. Changed + # symbol sizes can still shift other symbols, though. Therefore, don't + # rely on file size alone. + if [ $size1 -ne $size2 ] || kallsymso_changed || \ + [ -n "${KALLSYMS_EXTRA_PASS}" ]; then vmlinux_link .tmp_vmlinux3 sysmap_and_kallsyms .tmp_vmlinux3 fi -- 2.53.0