Commit 52a09bc2 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf map: Add map__objdump_2rip()

Sometimes we want to convert an address in objdump output to
map-relative address to match with a sample data.  Let's add
map__objdump_2rip() for that.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240319055115.4063940-6-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 7a838c2f
...@@ -587,6 +587,23 @@ u64 map__objdump_2mem(struct map *map, u64 ip) ...@@ -587,6 +587,23 @@ u64 map__objdump_2mem(struct map *map, u64 ip)
return ip + map__reloc(map); return ip + map__reloc(map);
} }
/* convert objdump address to relative address. (To be removed) */
u64 map__objdump_2rip(struct map *map, u64 ip)
{
const struct dso *dso = map__dso(map);
if (!dso->adjust_symbols)
return ip;
if (dso->rel)
return ip + map__pgoff(map);
if (dso->kernel == DSO_SPACE__USER)
return ip - dso->text_offset;
return map__map_ip(map, ip + map__reloc(map));
}
bool map__contains_symbol(const struct map *map, const struct symbol *sym) bool map__contains_symbol(const struct map *map, const struct symbol *sym)
{ {
u64 ip = map__unmap_ip(map, sym->start); u64 ip = map__unmap_ip(map, sym->start);
......
...@@ -132,6 +132,9 @@ u64 map__rip_2objdump(struct map *map, u64 rip); ...@@ -132,6 +132,9 @@ u64 map__rip_2objdump(struct map *map, u64 rip);
/* objdump address -> memory address */ /* objdump address -> memory address */
u64 map__objdump_2mem(struct map *map, u64 ip); u64 map__objdump_2mem(struct map *map, u64 ip);
/* objdump address -> rip */
u64 map__objdump_2rip(struct map *map, u64 ip);
struct symbol; struct symbol;
struct thread; struct thread;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment