]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - tools/perf/arch/powerpc/util/sym-handling.c
Merge remote-tracking branch 'linusw-gpio/for-next' into devm_gpiochip
[mirror_ubuntu-hirsute-kernel.git] / tools / perf / arch / powerpc / util / sym-handling.c
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 #include "map.h"
12 #include "probe-event.h"
13
14 #ifdef HAVE_LIBELF_SUPPORT
15 bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)
16 {
17 return ehdr.e_type == ET_EXEC ||
18 ehdr.e_type == ET_REL ||
19 ehdr.e_type == ET_DYN;
20 }
21
22 #if defined(_CALL_ELF) && _CALL_ELF == 2
23 void arch__elf_sym_adjust(GElf_Sym *sym)
24 {
25 sym->st_value += PPC64_LOCAL_ENTRY_OFFSET(sym->st_other);
26 }
27 #endif
28 #endif
29
30 #if !defined(_CALL_ELF) || _CALL_ELF != 2
31 int arch__choose_best_symbol(struct symbol *syma,
32 struct symbol *symb __maybe_unused)
33 {
34 char *sym = syma->name;
35
36 /* Skip over any initial dot */
37 if (*sym == '.')
38 sym++;
39
40 /* Avoid "SyS" kernel syscall aliases */
41 if (strlen(sym) >= 3 && !strncmp(sym, "SyS", 3))
42 return SYMBOL_B;
43 if (strlen(sym) >= 10 && !strncmp(sym, "compat_SyS", 10))
44 return SYMBOL_B;
45
46 return SYMBOL_A;
47 }
48
49 /* Allow matching against dot variants */
50 int arch__compare_symbol_names(const char *namea, const char *nameb)
51 {
52 /* Skip over initial dot */
53 if (*namea == '.')
54 namea++;
55 if (*nameb == '.')
56 nameb++;
57
58 return strcmp(namea, nameb);
59 }
60 #endif
61
62 #if defined(_CALL_ELF) && _CALL_ELF == 2
63 bool arch__prefers_symtab(void)
64 {
65 return true;
66 }
67
68 #define PPC64LE_LEP_OFFSET 8
69
70 void arch__fix_tev_from_maps(struct perf_probe_event *pev,
71 struct probe_trace_event *tev, struct map *map)
72 {
73 /*
74 * ppc64 ABIv2 local entry point is currently always 2 instructions
75 * (8 bytes) after the global entry point.
76 */
77 if (!pev->uprobes && map->dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS) {
78 tev->point.address += PPC64LE_LEP_OFFSET;
79 tev->point.offset += PPC64LE_LEP_OFFSET;
80 }
81 }
82 #endif