kallsyms: Omit unnamed local symbols from System.map and kallsyms
PATCH 1/1 kallsyms: Omit unnamed local symbols from System.map and kallsyms
From: Ard Biesheuvel <[email protected]>
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
--- scripts/kallsyms-sysmap.c | 4 ++++ 1 file changed, 4 insertions(+)
scripts/kallsyms-sysmap.c +4 -0
@@ -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;
Signature · 1 line
2.56.1.839.g22a8290db9-goog