Lexi Shao
unread,Oct 29, 2021, 2:51:27 AM10/29/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to linux-...@vger.kernel.org, linux-pe...@vger.kernel.org, james...@arm.com, ac...@kernel.org, alexander...@linux.intel.com, jo...@redhat.com, mark.r...@arm.com, mi...@redhat.com, namh...@kernel.org, nixia...@huawei.com, pet...@infradead.org, qiu...@huawei.com, shao...@huawei.com, wang...@huawei.com, je...@kernel.org, a...@kernel.org, dan...@iogearbox.net, and...@kernel.org, ka...@fb.com, songliu...@fb.com, y...@fb.com, john.fa...@gmail.com, kps...@kernel.org, natecha...@gmail.com, ndesau...@google.com, b...@vger.kernel.org, clang-bu...@googlegroups.com
Arm modules contains mapping symbols(e.g. $a $d) which are ignored in
module_kallsyms_on_each_symbol. However, these symbols are still
displayed when catting /proc/kallsyms. This confuses tools(e.g. perf)
that resolves kernel symbols with address using information from
/proc/kallsyms. See discussion in Link:
https://lore.kernel.org/all/c7dfbd17-85fd-b914...@arm.com/
Being left out in vmlinux(see scripts/kallsyms.c is_ignored_symbol) and
kernelspace API implies that these symbols are not used in any cases.
So we can ignore them in the first place by not adding them to module
kallsyms.
Signed-off-by: Lexi Shao <
shao...@huawei.com>
---
kernel/module.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/kernel/module.c b/kernel/module.c
index 5c26a76e800b..b30cbbe144c7 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2662,16 +2662,22 @@ static char elf_type(const Elf_Sym *sym, const struct load_info *info)
return '?';
}
-static bool is_core_symbol(const Elf_Sym *src, const Elf_Shdr *sechdrs,
- unsigned int shnum, unsigned int pcpundx)
+static inline int is_arm_mapping_symbol(const char *str);
+static bool is_core_symbol(const Elf_Sym *src, const struct load_info *info)
{
const Elf_Shdr *sec;
+ const Elf_Shdr *sechdrs = info->sechdrs;
+ unsigned int shnum = info->hdr->e_shnum;
+ unsigned int pcpundx = info->index.pcpu;
if (src->st_shndx == SHN_UNDEF
|| src->st_shndx >= shnum
|| !src->st_name)
return false;
+ if (is_arm_mapping_symbol(&info->strtab[src->st_name]))
+ return false;
+
#ifdef CONFIG_KALLSYMS_ALL
if (src->st_shndx == pcpundx)
return true;
@@ -2714,8 +2720,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
/* Compute total space required for the core symbols' strtab. */
for (ndst = i = 0; i < nsrc; i++) {
if (i == 0 || is_livepatch_module(mod) ||
- is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum,
- info->index.pcpu)) {
+ is_core_symbol(src+i, info)) {
strtab_size += strlen(&info->strtab[src[i].st_name])+1;
ndst++;
}
@@ -2778,8 +2783,7 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
for (ndst = i = 0; i < mod->kallsyms->num_symtab; i++) {
mod->kallsyms->typetab[i] = elf_type(src + i, info);
if (i == 0 || is_livepatch_module(mod) ||
- is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum,
- info->index.pcpu)) {
+ is_core_symbol(src+i, info)) {
mod->core_kallsyms.typetab[ndst] =
mod->kallsyms->typetab[i];
dst[ndst] = src[i];
@@ -4246,8 +4250,7 @@ static const char *find_kallsyms_symbol(struct module *mod,
* We ignore unnamed symbols: they're uninformative
* and inserted at a whim.
*/
- if (*kallsyms_symbol_name(kallsyms, i) == '\0'
- || is_arm_mapping_symbol(kallsyms_symbol_name(kallsyms, i)))
+ if (*kallsyms_symbol_name(kallsyms, i) == '\0')
continue;
if (thisval <= addr && thisval > bestval) {
--
2.12.3