Commit 82164161 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Ingo Molnar

perf symbols: Call the symbol filter in dso__synthesize_plt_symbols()

We need to pass the symbol to the filter so that, for instance,
'perf top' can do filtering and also set the private area it
manages, setting the ->map pointer, etc.

I found this while running 'perf top' on a machine where hits
happened on PLT symbols, where ->map wasn't being set up and
segfaults thus happened.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <1258386491-20278-1-git-send-email-acme@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 559fdc3c
...@@ -281,6 +281,11 @@ static int kernel_maps__load_all_kallsyms(void) ...@@ -281,6 +281,11 @@ static int kernel_maps__load_all_kallsyms(void)
if (sym == NULL) if (sym == NULL)
goto out_delete_line; goto out_delete_line;
/*
* We will pass the symbols to the filter later, in
* kernel_maps__split_kallsyms, when we have split the
* maps per module
*/
dso__insert_symbol(kernel_map->dso, sym); dso__insert_symbol(kernel_map->dso, sym);
} }
...@@ -555,7 +560,8 @@ static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, ...@@ -555,7 +560,8 @@ static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
* And always look at the original dso, not at debuginfo packages, that * And always look at the original dso, not at debuginfo packages, that
* have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS). * have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS).
*/ */
static int dso__synthesize_plt_symbols(struct dso *self) static int dso__synthesize_plt_symbols(struct dso *self, struct map *map,
symbol_filter_t filter)
{ {
uint32_t nr_rel_entries, idx; uint32_t nr_rel_entries, idx;
GElf_Sym sym; GElf_Sym sym;
...@@ -643,8 +649,12 @@ static int dso__synthesize_plt_symbols(struct dso *self) ...@@ -643,8 +649,12 @@ static int dso__synthesize_plt_symbols(struct dso *self)
if (!f) if (!f)
goto out_elf_end; goto out_elf_end;
dso__insert_symbol(self, f); if (filter && filter(map, f))
++nr; symbol__delete(f);
else {
dso__insert_symbol(self, f);
++nr;
}
} }
} else if (shdr_rel_plt.sh_type == SHT_REL) { } else if (shdr_rel_plt.sh_type == SHT_REL) {
GElf_Rel pos_mem, *pos; GElf_Rel pos_mem, *pos;
...@@ -661,8 +671,12 @@ static int dso__synthesize_plt_symbols(struct dso *self) ...@@ -661,8 +671,12 @@ static int dso__synthesize_plt_symbols(struct dso *self)
if (!f) if (!f)
goto out_elf_end; goto out_elf_end;
dso__insert_symbol(self, f); if (filter && filter(map, f))
++nr; symbol__delete(f);
else {
dso__insert_symbol(self, f);
++nr;
}
} }
} }
...@@ -1050,7 +1064,7 @@ int dso__load(struct dso *self, struct map *map, symbol_filter_t filter) ...@@ -1050,7 +1064,7 @@ int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
goto more; goto more;
if (ret > 0) { if (ret > 0) {
int nr_plt = dso__synthesize_plt_symbols(self); int nr_plt = dso__synthesize_plt_symbols(self, map, filter);
if (nr_plt > 0) if (nr_plt > 0)
ret += nr_plt; ret += nr_plt;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment