Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH] kallsyms: Omit unnamed local symbols from System.map and kallsyms
@ 2026-11-26 16:57 Ard Biesheuvel
  0 siblings, 0 replies; only message in thread
From: Ard Biesheuvel @ 2026-11-26 16:57 UTC (permalink / raw)
  To: llvm
  Cc: Ard Biesheuvel, Nathan Chancellor, Nicolas Schier,
	Nick Desaulniers, Bill Wendling, Justin Stitt, linux-kbuild

From: Ard Biesheuvel <ardb@kernel.org>

Since LLVM PR #223686 [1] ("[LLD][ELF] AArch64 Errata patch use
STT_NOTYPE for symbols"), ld.lld --fix-cortex-a53-843419 (enabled on
arm64 by CONFIG_ARM64_ERRATUM_843419, which defaults to y) synthesizes
an unnamed (st_name == 0, "") STT_NOTYPE local symbol for every
executable InputSection that lacks an STT_SECTION symbol in its input
object, such as empty .text sections in data-only or .init.text
translation units, or per-function sections under -ffunction-sections.

elf_symbol_type() classifies these unnamed STT_NOTYPE local symbols in
executable sections as 't' (matching GNU nm and llvm-nm), and
sysmap_omits() does not filter empty names. As a result, nameless 't'
entries are emitted into System.map and compressed into the kernel's
kallsyms tables.

Beyond bloating the kallsyms tables with useless nameless entries, this
causes CONFIG_KALLSYMS_SELFTEST to fail at boot ("Test for Nth symbol
failed: ()"), because kallsyms_lookup_name("") explicitly rejects empty
strings and returns 0.

Omit symbols with an empty name in sysmap_omits() so they are excluded
from both System.map and kallsyms.

[1] https://github.com/llvm/llvm-project/commit/5da7779afdf3

Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nsc@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 scripts/kallsyms-sysmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/kallsyms-sysmap.c b/scripts/kallsyms-sysmap.c
index a482968eba51..1cb3b1775157 100644
--- a/scripts/kallsyms-sysmap.c
+++ b/scripts/kallsyms-sysmap.c
@@ -96,6 +96,10 @@ static bool sysmap_omits(const char *name, char type)
 {
 	size_t i;
 
+	/* Unnamed symbols (st_name == 0). */
+	if (!*name)
+		return true;
+
 	/* Absolute, undefined and debugging symbols. */
 	if (type == 'a' || type == 'N' || type == 'U' || type == 'w')
 		return true;
-- 
2.56.1.839.g22a8290db9-goog


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

only message in thread, other threads:[~2026-11-26 16:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 16:57 [PATCH] kallsyms: Omit unnamed local symbols from System.map and kallsyms Ard Biesheuvel

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