[PATCH v4 3/3] module/kallsyms: Ignore local labels and mapping symbols during module load
Tiezhu Yang <[email protected]>
| Newsgroups | org.kernel.vger.linux-modules,dev.linux.lists.loongarch |
|---|---|
| Message-ID | <[email protected]> |
The compiler toolchains may generate local labels and mapping symbols on certain architectures like LoongArch for optimizations and relocations. While these local labels and mapping symbols are already ignored during runtime lookups via find_kallsyms_symbol(), they still leak into kallsyms for loaded modules because layout_symtab() and add_kallsyms() don't ignore 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_ignored_kernel_symbol() check directly into is_core_symbol(). 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]> Reviewed-by: Huacai Chen <[email protected]> Reviewed-by: Petr Pavlu <[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 d75c9f60d360..1ff8ce857d92 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -89,6 +89,9 @@ static bool is_core_symbol(struct module *mod, const struct load_info *info, !src->st_name) return false; + if (is_ignored_kernel_symbol(&info->strtab[src->st_name])) + return false; + #ifdef CONFIG_KALLSYMS_ALL if (src->st_shndx == info->index.pcpu) return true; -- 2.42.0