diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2014-07-22 15:17:59 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-07-23 22:36:36 +0200 |
commit | 2b5b8bb27b9ec899cfba686dabec113ea0d4cbda (patch) | |
tree | 1dbb729e798b6a42829c2c83de667eb07f3c3094 /tools/perf/util/symbol-minimal.c | |
parent | perf tools: Separate the VDSO map name from the VDSO dso name (diff) | |
download | linux-2b5b8bb27b9ec899cfba686dabec113ea0d4cbda.tar.xz linux-2b5b8bb27b9ec899cfba686dabec113ea0d4cbda.zip |
perf tools: Add dso__type()
dso__type() determines wheather a dso is 32-bit, x32 (32-bit with 64-bit
registers) or 64-bit.
dso__type() will be used to determine the VDSO a program maps.
Reviewed-by: Jiri Olsa <jolsa@redhat.com>
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/1406035081-14301-51-git-send-email-adrian.hunter@intel.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.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c index 101f55d407d0..c9541fea9514 100644 --- a/tools/perf/util/symbol-minimal.c +++ b/tools/perf/util/symbol-minimal.c @@ -305,6 +305,27 @@ static int fd__is_64_bit(int fd) return e_ident[EI_CLASS] == ELFCLASS64; } +enum dso_type dso__type_fd(int fd) +{ + Elf64_Ehdr ehdr; + int ret; + + ret = fd__is_64_bit(fd); + if (ret < 0) + return DSO__TYPE_UNKNOWN; + + if (ret) + return DSO__TYPE_64BIT; + + if (readn(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) + return DSO__TYPE_UNKNOWN; + + if (ehdr.e_machine == EM_X86_64) + return DSO__TYPE_X32BIT; + + return DSO__TYPE_32BIT; +} + int dso__load_sym(struct dso *dso, struct map *map __maybe_unused, struct symsrc *ss, struct symsrc *runtime_ss __maybe_unused, |