The compiler toolchains generate local and mapping symbols on certain architectures like LoongArch for optimizations and relocations.
While the symbols are already filtered out during runtime lookups via find_kallsyms_symbol(), they still leak into /proc/kallsyms for loaded modules because layout_symtab() and add_kallsyms() do not filter them during load time. Consequently, tracing tools like bpftrace (which do not perform internal filtering, unlike perf) resolve identical addresses into confusing local labels instead of actual clear C function names. Fix this by integrating the is_local_mapping_symbol() check directly into the newly introduced is_kept_symbol() helper. This ensures these unneeded symbols are stripped during module load time, keeping /proc/kallsyms clean and resulting in accurate call stacks. Signed-off-by: Tiezhu Yang <[email protected]> --- kernel/module/kallsyms.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index ff8d904afe56..cc2a68956e43 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -89,6 +89,9 @@ static bool is_kept_symbol(struct module *mod, const struct load_info *info, !src->st_name) return false; + if (is_local_mapping_symbol(&info->strtab[src->st_name])) + return false; + #ifdef CONFIG_KALLSYMS_ALL if (src->st_shndx == info->index.pcpu) return true; -- 2.42.0

