aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 7f0537d1add8..e0e6a075489e 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -401,3 +401,49 @@ bool perf_session__has_traces(struct perf_session *self, const char *msg)
401 401
402 return true; 402 return true;
403} 403}
404
405int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
406 const char *symbol_name,
407 u64 addr)
408{
409 char *bracket;
410
411 self->ref_reloc_sym.name = strdup(symbol_name);
412 if (self->ref_reloc_sym.name == NULL)
413 return -ENOMEM;
414
415 bracket = strchr(self->ref_reloc_sym.name, ']');
416 if (bracket)
417 *bracket = '\0';
418
419 self->ref_reloc_sym.addr = addr;
420 return 0;
421}
422
423static u64 map__reloc_map_ip(struct map *map, u64 ip)
424{
425 return ip + (s64)map->pgoff;
426}
427
428static u64 map__reloc_unmap_ip(struct map *map, u64 ip)
429{
430 return ip - (s64)map->pgoff;
431}
432
433void perf_session__reloc_vmlinux_maps(struct perf_session *self,
434 u64 unrelocated_addr)
435{
436 enum map_type type;
437 s64 reloc = unrelocated_addr - self->ref_reloc_sym.addr;
438
439 if (!reloc)
440 return;
441
442 for (type = 0; type < MAP__NR_TYPES; ++type) {
443 struct map *map = self->vmlinux_maps[type];
444
445 map->map_ip = map__reloc_map_ip;
446 map->unmap_ip = map__reloc_unmap_ip;
447 map->pgoff = reloc;
448 }
449}