~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/arch/powerpc/util/sym-handling.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  *
  4  * Copyright (C) 2015 Naveen N. Rao, IBM Corporation
  5  */
  6 
  7 #include "dso.h"
  8 #include "symbol.h"
  9 #include "map.h"
 10 #include "probe-event.h"
 11 #include "probe-file.h"
 12 
 13 int arch__choose_best_symbol(struct symbol *syma,
 14                              struct symbol *symb __maybe_unused)
 15 {
 16         char *sym = syma->name;
 17 
 18 #if !defined(_CALL_ELF) || _CALL_ELF != 2
 19         /* Skip over any initial dot */
 20         if (*sym == '.')
 21                 sym++;
 22 #endif
 23 
 24         /* Avoid "SyS" kernel syscall aliases */
 25         if (strlen(sym) >= 3 && !strncmp(sym, "SyS", 3))
 26                 return SYMBOL_B;
 27         if (strlen(sym) >= 10 && !strncmp(sym, "compat_SyS", 10))
 28                 return SYMBOL_B;
 29 
 30         return SYMBOL_A;
 31 }
 32 
 33 #if !defined(_CALL_ELF) || _CALL_ELF != 2
 34 /* Allow matching against dot variants */
 35 int arch__compare_symbol_names(const char *namea, const char *nameb)
 36 {
 37         /* Skip over initial dot */
 38         if (*namea == '.')
 39                 namea++;
 40         if (*nameb == '.')
 41                 nameb++;
 42 
 43         return strcmp(namea, nameb);
 44 }
 45 
 46 int arch__compare_symbol_names_n(const char *namea, const char *nameb,
 47                                  unsigned int n)
 48 {
 49         /* Skip over initial dot */
 50         if (*namea == '.')
 51                 namea++;
 52         if (*nameb == '.')
 53                 nameb++;
 54 
 55         return strncmp(namea, nameb, n);
 56 }
 57 
 58 const char *arch__normalize_symbol_name(const char *name)
 59 {
 60         /* Skip over initial dot */
 61         if (name && *name == '.')
 62                 name++;
 63         return name;
 64 }
 65 #endif
 66 
 67 #if defined(_CALL_ELF) && _CALL_ELF == 2
 68 
 69 #ifdef HAVE_LIBELF_SUPPORT
 70 void arch__sym_update(struct symbol *s, GElf_Sym *sym)
 71 {
 72         s->arch_sym = sym->st_other;
 73 }
 74 #endif
 75 
 76 #define PPC64LE_LEP_OFFSET      8
 77 
 78 void arch__fix_tev_from_maps(struct perf_probe_event *pev,
 79                              struct probe_trace_event *tev, struct map *map,
 80                              struct symbol *sym)
 81 {
 82         int lep_offset;
 83 
 84         /*
 85          * When probing at a function entry point, we normally always want the
 86          * LEP since that catches calls to the function through both the GEP and
 87          * the LEP. Hence, we would like to probe at an offset of 8 bytes if
 88          * the user only specified the function entry.
 89          *
 90          * However, if the user specifies an offset, we fall back to using the
 91          * GEP since all userspace applications (objdump/readelf) show function
 92          * disassembly with offsets from the GEP.
 93          */
 94         if (pev->point.offset || !map || !sym)
 95                 return;
 96 
 97         /* For kretprobes, add an offset only if the kernel supports it */
 98         if (!pev->uprobes && pev->point.retprobe) {
 99 #ifdef HAVE_LIBELF_SUPPORT
100                 if (!kretprobe_offset_is_supported())
101 #endif
102                         return;
103         }
104 
105         lep_offset = PPC64_LOCAL_ENTRY_OFFSET(sym->arch_sym);
106 
107         if (map__dso(map)->symtab_type == DSO_BINARY_TYPE__KALLSYMS)
108                 tev->point.offset += PPC64LE_LEP_OFFSET;
109         else if (lep_offset) {
110                 if (pev->uprobes)
111                         tev->point.address += lep_offset;
112                 else
113                         tev->point.offset += lep_offset;
114         }
115 }
116 
117 #ifdef HAVE_LIBELF_SUPPORT
118 void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
119                                            int ntevs)
120 {
121         struct probe_trace_event *tev;
122         struct map *map;
123         struct symbol *sym = NULL;
124         struct rb_node *tmp;
125         int i = 0;
126 
127         map = get_target_map(pev->target, pev->nsi, pev->uprobes);
128         if (!map || map__load(map) < 0)
129                 return;
130 
131         for (i = 0; i < ntevs; i++) {
132                 tev = &pev->tevs[i];
133                 map__for_each_symbol(map, sym, tmp) {
134                         if (map__unmap_ip(map, sym->start) == tev->point.address) {
135                                 arch__fix_tev_from_maps(pev, tev, map, sym);
136                                 break;
137                         }
138                 }
139         }
140 }
141 #endif /* HAVE_LIBELF_SUPPORT */
142 
143 #endif
144 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php