diff options
author | Cody P Schafer <cody@linux.vnet.ibm.com> | 2012-08-10 18:22:57 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-13 13:31:44 -0400 |
commit | b68e2f919c6d3a0422239c98673c35ff503e52fb (patch) | |
tree | e960118f1892c52efe58ebdb8c605cefe81706d7 /tools/perf/util/symbol.h | |
parent | 21ea4539b4d1b26de7f2eb227b5d1a092b32cc19 (diff) |
perf symbols: Introduce symsrc structure.
Factors opening of certain sections & tracking certain elf info into an
external structure.
The goal here is to keep multiple elfs (and their looked up
sections/indexes) around during the symbol generation process (in
dso__load()).
We need this to properly resolve symbols on PPC due to the use of
function descriptors & the .opd section (ie: symbols which are functions
don't point to their actual location, they point to their function
descriptor in .opd which contains their actual location.
It would be possible to just keep the (Elf *) around, but then we'd end
up with duplicate code for looking up the same sections and checking for
the existence of an important section wouldn't be as clean (and we need
to keep the Elf stuff confined to symtab-elf.c).
Utilized by the later patch
"perf symbols: Use both runtime and debug images"
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Cc: David Hansen <dave@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Matt Hellsley <matthltc@us.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1344637382-22789-12-git-send-email-cody@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/symbol.h')
-rw-r--r-- | tools/perf/util/symbol.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 37f1ea146c16..dd9e8678b355 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -11,6 +11,12 @@ | |||
11 | #include <stdio.h> | 11 | #include <stdio.h> |
12 | #include <byteswap.h> | 12 | #include <byteswap.h> |
13 | 13 | ||
14 | #ifndef NO_LIBELF_SUPPORT | ||
15 | #include <libelf.h> | ||
16 | #include <gelf.h> | ||
17 | #include <elf.h> | ||
18 | #endif | ||
19 | |||
14 | #ifdef HAVE_CPLUS_DEMANGLE | 20 | #ifdef HAVE_CPLUS_DEMANGLE |
15 | extern char *cplus_demangle(const char *, int); | 21 | extern char *cplus_demangle(const char *, int); |
16 | 22 | ||
@@ -219,6 +225,34 @@ struct dso { | |||
219 | char name[0]; | 225 | char name[0]; |
220 | }; | 226 | }; |
221 | 227 | ||
228 | struct symsrc { | ||
229 | char *name; | ||
230 | int fd; | ||
231 | enum dso_binary_type type; | ||
232 | |||
233 | #ifndef NO_LIBELF_SUPPORT | ||
234 | Elf *elf; | ||
235 | GElf_Ehdr ehdr; | ||
236 | |||
237 | Elf_Scn *opdsec; | ||
238 | size_t opdidx; | ||
239 | GElf_Shdr opdshdr; | ||
240 | |||
241 | Elf_Scn *symtab; | ||
242 | GElf_Shdr symshdr; | ||
243 | |||
244 | Elf_Scn *dynsym; | ||
245 | size_t dynsym_idx; | ||
246 | GElf_Shdr dynshdr; | ||
247 | |||
248 | bool adjust_symbols; | ||
249 | #endif | ||
250 | }; | ||
251 | |||
252 | void symsrc__destroy(struct symsrc *ss); | ||
253 | int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, | ||
254 | enum dso_binary_type type); | ||
255 | |||
222 | #define DSO__SWAP(dso, type, val) \ | 256 | #define DSO__SWAP(dso, type, val) \ |
223 | ({ \ | 257 | ({ \ |
224 | type ____r = val; \ | 258 | type ____r = val; \ |
@@ -334,7 +368,7 @@ ssize_t dso__data_read_addr(struct dso *dso, struct map *map, | |||
334 | struct machine *machine, u64 addr, | 368 | struct machine *machine, u64 addr, |
335 | u8 *data, ssize_t size); | 369 | u8 *data, ssize_t size); |
336 | int dso__test_data(void); | 370 | int dso__test_data(void); |
337 | int dso__load_sym(struct dso *dso, struct map *map, const char *name, int fd, | 371 | int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *ss, |
338 | symbol_filter_t filter, int kmodule, int want_symtab); | 372 | symbol_filter_t filter, int kmodule, int want_symtab); |
339 | int dso__synthesize_plt_symbols(struct dso *dso, char *name, struct map *map, | 373 | int dso__synthesize_plt_symbols(struct dso *dso, char *name, struct map *map, |
340 | symbol_filter_t filter); | 374 | symbol_filter_t filter); |