Skip to content

Commit d233209

Browse files
rnavacmel
authored andcommitted
perf probe ppc: Fix symbol fixup issues due to ELF type
If using the symbol table, symbol addresses are not being fixed up properly, resulting in probes being placed at wrong addresses: # perf probe do_fork Added new event: probe:do_fork (on do_fork) You can now use it in all perf tools, such as: perf record -e probe:do_fork -aR sleep 1 # cat /sys/kernel/debug/tracing/kprobe_events p:probe/do_fork _text+635952 # printf "%x" 635952 9b430 # grep do_fork /boot/System.map c0000000000ab430 T .do_fork Fix by checking for ELF type ET_DYN used by ppc64 kernels. Signed-off-by: Naveen N. Rao <[email protected]> Reviewed-by: Srikar Dronamraju <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Sukadev Bhattiprolu <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/41392bb856ef62d929995e0b61967689b7915207.1430217967.git.naveen.n.rao@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent b64aa55 commit d233209

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

tools/perf/arch/powerpc/util/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
libperf-y += header.o
2+
libperf-y += sym-handling.o
23

34
libperf-$(CONFIG_DWARF) += dwarf-regs.o
45
libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License, version 2, as
4+
* published by the Free Software Foundation.
5+
*
6+
* Copyright (C) 2015 Naveen N. Rao, IBM Corporation
7+
*/
8+
9+
#include "debug.h"
10+
#include "symbol.h"
11+
12+
#ifdef HAVE_LIBELF_SUPPORT
13+
bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)
14+
{
15+
return ehdr.e_type == ET_EXEC ||
16+
ehdr.e_type == ET_REL ||
17+
ehdr.e_type == ET_DYN;
18+
}
19+
#endif

tools/perf/util/symbol-elf.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ void symsrc__destroy(struct symsrc *ss)
630630
close(ss->fd);
631631
}
632632

633+
bool __weak elf__needs_adjust_symbols(GElf_Ehdr ehdr)
634+
{
635+
return ehdr.e_type == ET_EXEC || ehdr.e_type == ET_REL;
636+
}
637+
633638
int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
634639
enum dso_binary_type type)
635640
{
@@ -711,8 +716,7 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
711716
".gnu.prelink_undo",
712717
NULL) != NULL);
713718
} else {
714-
ss->adjust_symbols = ehdr.e_type == ET_EXEC ||
715-
ehdr.e_type == ET_REL;
719+
ss->adjust_symbols = elf__needs_adjust_symbols(ehdr);
716720
}
717721

718722
ss->name = strdup(name);

tools/perf/util/symbol.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,8 @@ int setup_list(struct strlist **list, const char *list_str,
303303
int setup_intlist(struct intlist **list, const char *list_str,
304304
const char *list_name);
305305

306+
#ifdef HAVE_LIBELF_SUPPORT
307+
bool elf__needs_adjust_symbols(GElf_Ehdr ehdr);
308+
#endif
309+
306310
#endif /* __PERF_SYMBOL */

0 commit comments

Comments
 (0)