aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol-minimal.c
diff options
context:
space:
mode:
authorCody P Schafer <cody@linux.vnet.ibm.com>2012-08-10 18:22:57 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-13 13:31:44 -0400
commitb68e2f919c6d3a0422239c98673c35ff503e52fb (patch)
treee960118f1892c52efe58ebdb8c605cefe81706d7 /tools/perf/util/symbol-minimal.c
parent21ea4539b4d1b26de7f2eb227b5d1a092b32cc19 (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-minimal.c')
-rw-r--r--tools/perf/util/symbol-minimal.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c
index bd8720b6780c..1b16c2729a36 100644
--- a/tools/perf/util/symbol-minimal.c
+++ b/tools/perf/util/symbol-minimal.c
@@ -241,6 +241,31 @@ out:
241 return ret; 241 return ret;
242} 242}
243 243
244int symsrc__init(struct symsrc *ss, struct dso *dso __used, const char *name,
245 enum dso_binary_type type)
246{
247 int fd = open(name, O_RDONLY);
248 if (fd < 0)
249 return -1;
250
251 ss->name = strdup(name);
252 if (!ss->name)
253 goto out_close;
254
255 ss->type = type;
256
257 return 0;
258out_close:
259 close(fd);
260 return -1;
261}
262
263void symsrc__destroy(struct symsrc *ss)
264{
265 free(ss->name);
266 close(ss->fd);
267}
268
244int dso__synthesize_plt_symbols(struct dso *dso __used, char *name __used, 269int dso__synthesize_plt_symbols(struct dso *dso __used, char *name __used,
245 struct map *map __used, 270 struct map *map __used,
246 symbol_filter_t filter __used) 271 symbol_filter_t filter __used)
@@ -248,14 +273,13 @@ int dso__synthesize_plt_symbols(struct dso *dso __used, char *name __used,
248 return 0; 273 return 0;
249} 274}
250 275
251int dso__load_sym(struct dso *dso, struct map *map __used, 276int dso__load_sym(struct dso *dso, struct map *map __used, struct symsrc *ss,
252 const char *name, int fd __used,
253 symbol_filter_t filter __used, int kmodule __used, 277 symbol_filter_t filter __used, int kmodule __used,
254 int want_symtab __used) 278 int want_symtab __used)
255{ 279{
256 unsigned char *build_id[BUILD_ID_SIZE]; 280 unsigned char *build_id[BUILD_ID_SIZE];
257 281
258 if (filename__read_build_id(name, build_id, BUILD_ID_SIZE) > 0) { 282 if (filename__read_build_id(ss->name, build_id, BUILD_ID_SIZE) > 0) {
259 dso__set_build_id(dso, build_id); 283 dso__set_build_id(dso, build_id);
260 return 1; 284 return 1;
261 } 285 }