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.
6 * Copyright (C) 2015 Naveen N. Rao, IBM Corporation
12 #include "probe-event.h"
14 #ifdef HAVE_LIBELF_SUPPORT
15 bool elf__needs_adjust_symbols(GElf_Ehdr ehdr
)
17 return ehdr
.e_type
== ET_EXEC
||
18 ehdr
.e_type
== ET_REL
||
19 ehdr
.e_type
== ET_DYN
;
24 #if !defined(_CALL_ELF) || _CALL_ELF != 2
25 int arch__choose_best_symbol(struct symbol
*syma
,
26 struct symbol
*symb __maybe_unused
)
28 char *sym
= syma
->name
;
30 /* Skip over any initial dot */
34 /* Avoid "SyS" kernel syscall aliases */
35 if (strlen(sym
) >= 3 && !strncmp(sym
, "SyS", 3))
37 if (strlen(sym
) >= 10 && !strncmp(sym
, "compat_SyS", 10))
43 /* Allow matching against dot variants */
44 int arch__compare_symbol_names(const char *namea
, const char *nameb
)
46 /* Skip over initial dot */
52 return strcmp(namea
, nameb
);
56 #if defined(_CALL_ELF) && _CALL_ELF == 2
57 bool arch__prefers_symtab(void)
62 #ifdef HAVE_LIBELF_SUPPORT
63 void arch__sym_update(struct symbol
*s
, GElf_Sym
*sym
)
65 s
->arch_sym
= sym
->st_other
;
69 #define PPC64LE_LEP_OFFSET 8
71 void arch__fix_tev_from_maps(struct perf_probe_event
*pev
,
72 struct probe_trace_event
*tev
, struct map
*map
,
78 * When probing at a function entry point, we normally always want the
79 * LEP since that catches calls to the function through both the GEP and
80 * the LEP. Hence, we would like to probe at an offset of 8 bytes if
81 * the user only specified the function entry.
83 * However, if the user specifies an offset, we fall back to using the
84 * GEP since all userspace applications (objdump/readelf) show function
85 * disassembly with offsets from the GEP.
87 * In addition, we shouldn't specify an offset for kretprobes.
89 if (pev
->point
.offset
|| pev
->point
.retprobe
|| !map
|| !sym
)
92 lep_offset
= PPC64_LOCAL_ENTRY_OFFSET(sym
->arch_sym
);
94 if (map
->dso
->symtab_type
== DSO_BINARY_TYPE__KALLSYMS
)
95 tev
->point
.offset
+= PPC64LE_LEP_OFFSET
;
96 else if (lep_offset
) {
98 tev
->point
.address
+= lep_offset
;
100 tev
->point
.offset
+= lep_offset
;