From b68e2f919c6d3a0422239c98673c35ff503e52fb Mon Sep 17 00:00:00 2001 From: Cody P Schafer Date: Fri, 10 Aug 2012 15:22:57 -0700 Subject: 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 Cc: David Hansen Cc: Ingo Molnar Cc: Matt Hellsley Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Sukadev Bhattiprolu Link: http://lkml.kernel.org/r/1344637382-22789-12-git-send-email-cody@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tools/perf/util/symbol.c') diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 8f5cabbfc8bd..afec3f048a94 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1026,7 +1026,7 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) { char *name; int ret = -1; - int fd; + struct symsrc ss; u_int i; struct machine *machine; char *root_dir = (char *) ""; @@ -1086,13 +1086,12 @@ restart: continue; /* Name is now the name of the next image to try */ - fd = open(name, O_RDONLY); - if (fd < 0) + if (symsrc__init(&ss, dso, name, dso->symtab_type) < 0) continue; - ret = dso__load_sym(dso, map, name, fd, filter, 0, + ret = dso__load_sym(dso, map, &ss, filter, 0, want_symtab); - close(fd); + symsrc__destroy(&ss); /* * Some people seem to have debuginfo files _WITHOUT_ debug @@ -1359,22 +1358,23 @@ out_failure: int dso__load_vmlinux(struct dso *dso, struct map *map, const char *vmlinux, symbol_filter_t filter) { - int err = -1, fd; + int err = -1; + struct symsrc ss; char symfs_vmlinux[PATH_MAX]; snprintf(symfs_vmlinux, sizeof(symfs_vmlinux), "%s%s", symbol_conf.symfs, vmlinux); - fd = open(symfs_vmlinux, O_RDONLY); - if (fd < 0) - return -1; if (dso->kernel == DSO_TYPE_GUEST_KERNEL) dso->symtab_type = DSO_BINARY_TYPE__GUEST_VMLINUX; else dso->symtab_type = DSO_BINARY_TYPE__VMLINUX; - err = dso__load_sym(dso, map, symfs_vmlinux, fd, filter, 0, 0); - close(fd); + if (symsrc__init(&ss, dso, symfs_vmlinux, dso->symtab_type)) + return -1; + + err = dso__load_sym(dso, map, &ss, filter, 0, 0); + symsrc__destroy(&ss); if (err > 0) { dso__set_long_name(dso, (char *)vmlinux); -- cgit v1.2.3