summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorCody P Schafer <cody@linux.vnet.ibm.com>2012-08-10 15:22:57 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-13 14:31:44 -0300
commitb68e2f919c6d3a0422239c98673c35ff503e52fb (patch)
treee960118f1892c52efe58ebdb8c605cefe81706d7 /tools/perf/util/symbol.c
parent21ea4539b4d1b26de7f2eb227b5d1a092b32cc19 (diff)
downloadblackbird-op-linux-b68e2f919c6d3a0422239c98673c35ff503e52fb.tar.gz
blackbird-op-linux-b68e2f919c6d3a0422239c98673c35ff503e52fb.zip
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.c')
-rw-r--r--tools/perf/util/symbol.c22
1 files changed, 11 insertions, 11 deletions
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);
OpenPOWER on IntegriCloud