diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2014-01-29 09:14:36 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-31 15:21:47 -0500 |
commit | 9176753d1ed56951a6ee2a0f0a3f367904e35567 (patch) | |
tree | 6f1bfc17c4d5bb52eff0fec288d2d82833bc0868 /tools | |
parent | 6a02652df511029127406cf8fa89cdf5e987f963 (diff) |
perf symbols: Fix symbol annotation for relocated kernel
Kernel maps map memory addresses to file offsets.
For symbol annotation, objdump needs the object VMA addresses. For an
unrelocated kernel, that is the same as the memory address.
The addresses passed to objdump for symbol annotation did not take into
account kernel relocation.
This patch fixes that.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Jiri Olsa <jolsa@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1391004884-10334-2-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/map.c | 5 | ||||
-rw-r--r-- | tools/perf/util/map.h | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol-elf.c | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 3b97513f0e77..39cd2d0faff6 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -39,6 +39,7 @@ void map__init(struct map *map, enum map_type type, | |||
39 | map->start = start; | 39 | map->start = start; |
40 | map->end = end; | 40 | map->end = end; |
41 | map->pgoff = pgoff; | 41 | map->pgoff = pgoff; |
42 | map->reloc = 0; | ||
42 | map->dso = dso; | 43 | map->dso = dso; |
43 | map->map_ip = map__map_ip; | 44 | map->map_ip = map__map_ip; |
44 | map->unmap_ip = map__unmap_ip; | 45 | map->unmap_ip = map__unmap_ip; |
@@ -288,7 +289,7 @@ u64 map__rip_2objdump(struct map *map, u64 rip) | |||
288 | if (map->dso->rel) | 289 | if (map->dso->rel) |
289 | return rip - map->pgoff; | 290 | return rip - map->pgoff; |
290 | 291 | ||
291 | return map->unmap_ip(map, rip); | 292 | return map->unmap_ip(map, rip) - map->reloc; |
292 | } | 293 | } |
293 | 294 | ||
294 | /** | 295 | /** |
@@ -311,7 +312,7 @@ u64 map__objdump_2mem(struct map *map, u64 ip) | |||
311 | if (map->dso->rel) | 312 | if (map->dso->rel) |
312 | return map->unmap_ip(map, ip + map->pgoff); | 313 | return map->unmap_ip(map, ip + map->pgoff); |
313 | 314 | ||
314 | return ip; | 315 | return ip + map->reloc; |
315 | } | 316 | } |
316 | 317 | ||
317 | void map_groups__init(struct map_groups *mg) | 318 | void map_groups__init(struct map_groups *mg) |
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 18068c6b71c1..257e513205ce 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
@@ -36,6 +36,7 @@ struct map { | |||
36 | bool erange_warned; | 36 | bool erange_warned; |
37 | u32 priv; | 37 | u32 priv; |
38 | u64 pgoff; | 38 | u64 pgoff; |
39 | u64 reloc; | ||
39 | u32 maj, min; /* only valid for MMAP2 record */ | 40 | u32 maj, min; /* only valid for MMAP2 record */ |
40 | u64 ino; /* only valid for MMAP2 record */ | 41 | u64 ino; /* only valid for MMAP2 record */ |
41 | u64 ino_generation;/* only valid for MMAP2 record */ | 42 | u64 ino_generation;/* only valid for MMAP2 record */ |
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 8f12f0f5101d..3e9f336740fa 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
@@ -751,6 +751,8 @@ int dso__load_sym(struct dso *dso, struct map *map, | |||
751 | if (strcmp(elf_name, kmap->ref_reloc_sym->name)) | 751 | if (strcmp(elf_name, kmap->ref_reloc_sym->name)) |
752 | continue; | 752 | continue; |
753 | kmap->ref_reloc_sym->unrelocated_addr = sym.st_value; | 753 | kmap->ref_reloc_sym->unrelocated_addr = sym.st_value; |
754 | map->reloc = kmap->ref_reloc_sym->addr - | ||
755 | kmap->ref_reloc_sym->unrelocated_addr; | ||
754 | break; | 756 | break; |
755 | } | 757 | } |
756 | } | 758 | } |