diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2014-07-14 06:02:41 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-07-16 16:57:35 -0400 |
commit | c6d8f2a4a0c5e366330a6a2a94c06b652f4ca554 (patch) | |
tree | da95c3e4ad89bb6ff6096c3015ccc20dacadaa00 /tools | |
parent | 5173fbb8a11b2857aeec9e5f4e9568d4e1b84dbd (diff) |
perf symbols: Record whether a dso is 64-bit
Add a flag to 'struct dso' to record if the dso is 64-bit or not.
Update the flag when reading the ELF.
This is needed for instruction decoding. For example, x86 instruction
decoding depends on whether or not the 64-bit instruction set is used.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1405332185-4050-18-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/dso.c | 1 | ||||
-rw-r--r-- | tools/perf/util/dso.h | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol-elf.c | 3 | ||||
-rw-r--r-- | tools/perf/util/symbol-minimal.c | 22 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 1 |
6 files changed, 29 insertions, 0 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 819f10414f08..fc006fed8877 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -703,6 +703,7 @@ struct dso *dso__new(const char *name) | |||
703 | dso->data.fd = -1; | 703 | dso->data.fd = -1; |
704 | dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND; | 704 | dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND; |
705 | dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND; | 705 | dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND; |
706 | dso->is_64_bit = (sizeof(void *) == 8); | ||
706 | dso->loaded = 0; | 707 | dso->loaded = 0; |
707 | dso->rel = 0; | 708 | dso->rel = 0; |
708 | dso->sorted_by_name = 0; | 709 | dso->sorted_by_name = 0; |
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index ad553ba257bf..c239e86541a3 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h | |||
@@ -90,6 +90,7 @@ struct dso { | |||
90 | u8 annotate_warned:1; | 90 | u8 annotate_warned:1; |
91 | u8 short_name_allocated:1; | 91 | u8 short_name_allocated:1; |
92 | u8 long_name_allocated:1; | 92 | u8 long_name_allocated:1; |
93 | u8 is_64_bit:1; | ||
93 | u8 sorted_by_name; | 94 | u8 sorted_by_name; |
94 | u8 loaded; | 95 | u8 loaded; |
95 | u8 rel; | 96 | u8 rel; |
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index dce5ccf61f11..cef8f426356e 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
@@ -599,6 +599,8 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, | |||
599 | goto out_elf_end; | 599 | goto out_elf_end; |
600 | } | 600 | } |
601 | 601 | ||
602 | ss->is_64_bit = (gelf_getclass(elf) == ELFCLASS64); | ||
603 | |||
602 | ss->symtab = elf_section_by_name(elf, &ehdr, &ss->symshdr, ".symtab", | 604 | ss->symtab = elf_section_by_name(elf, &ehdr, &ss->symshdr, ".symtab", |
603 | NULL); | 605 | NULL); |
604 | if (ss->symshdr.sh_type != SHT_SYMTAB) | 606 | if (ss->symshdr.sh_type != SHT_SYMTAB) |
@@ -699,6 +701,7 @@ int dso__load_sym(struct dso *dso, struct map *map, | |||
699 | bool remap_kernel = false, adjust_kernel_syms = false; | 701 | bool remap_kernel = false, adjust_kernel_syms = false; |
700 | 702 | ||
701 | dso->symtab_type = syms_ss->type; | 703 | dso->symtab_type = syms_ss->type; |
704 | dso->is_64_bit = syms_ss->is_64_bit; | ||
702 | dso->rel = syms_ss->ehdr.e_type == ET_REL; | 705 | dso->rel = syms_ss->ehdr.e_type == ET_REL; |
703 | 706 | ||
704 | /* | 707 | /* |
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c index bd15f490d04f..101f55d407d0 100644 --- a/tools/perf/util/symbol-minimal.c +++ b/tools/perf/util/symbol-minimal.c | |||
@@ -288,6 +288,23 @@ int dso__synthesize_plt_symbols(struct dso *dso __maybe_unused, | |||
288 | return 0; | 288 | return 0; |
289 | } | 289 | } |
290 | 290 | ||
291 | static int fd__is_64_bit(int fd) | ||
292 | { | ||
293 | u8 e_ident[EI_NIDENT]; | ||
294 | |||
295 | if (lseek(fd, 0, SEEK_SET)) | ||
296 | return -1; | ||
297 | |||
298 | if (readn(fd, e_ident, sizeof(e_ident)) != sizeof(e_ident)) | ||
299 | return -1; | ||
300 | |||
301 | if (memcmp(e_ident, ELFMAG, SELFMAG) || | ||
302 | e_ident[EI_VERSION] != EV_CURRENT) | ||
303 | return -1; | ||
304 | |||
305 | return e_ident[EI_CLASS] == ELFCLASS64; | ||
306 | } | ||
307 | |||
291 | int dso__load_sym(struct dso *dso, struct map *map __maybe_unused, | 308 | int dso__load_sym(struct dso *dso, struct map *map __maybe_unused, |
292 | struct symsrc *ss, | 309 | struct symsrc *ss, |
293 | struct symsrc *runtime_ss __maybe_unused, | 310 | struct symsrc *runtime_ss __maybe_unused, |
@@ -295,6 +312,11 @@ int dso__load_sym(struct dso *dso, struct map *map __maybe_unused, | |||
295 | int kmodule __maybe_unused) | 312 | int kmodule __maybe_unused) |
296 | { | 313 | { |
297 | unsigned char *build_id[BUILD_ID_SIZE]; | 314 | unsigned char *build_id[BUILD_ID_SIZE]; |
315 | int ret; | ||
316 | |||
317 | ret = fd__is_64_bit(ss->fd); | ||
318 | if (ret >= 0) | ||
319 | dso->is_64_bit = ret; | ||
298 | 320 | ||
299 | if (filename__read_build_id(ss->name, build_id, BUILD_ID_SIZE) > 0) { | 321 | if (filename__read_build_id(ss->name, build_id, BUILD_ID_SIZE) > 0) { |
300 | dso__set_build_id(dso, build_id); | 322 | dso__set_build_id(dso, build_id); |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 2e6a2e219eb9..ae2e4464afa7 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1065,6 +1065,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map, | |||
1065 | &is_64_bit); | 1065 | &is_64_bit); |
1066 | if (err) | 1066 | if (err) |
1067 | goto out_err; | 1067 | goto out_err; |
1068 | dso->is_64_bit = is_64_bit; | ||
1068 | 1069 | ||
1069 | if (list_empty(&md.maps)) { | 1070 | if (list_empty(&md.maps)) { |
1070 | err = -EINVAL; | 1071 | err = -EINVAL; |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index a81877b1dee0..436169dd1d84 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -216,6 +216,7 @@ struct symsrc { | |||
216 | GElf_Shdr dynshdr; | 216 | GElf_Shdr dynshdr; |
217 | 217 | ||
218 | bool adjust_symbols; | 218 | bool adjust_symbols; |
219 | bool is_64_bit; | ||
219 | #endif | 220 | #endif |
220 | }; | 221 | }; |
221 | 222 | ||