Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf probe: Fix to adjust symbol address with correct reloc_sym address

'perf probe' uses ref_reloc_sym to adjust symbol offset address from
debuginfo address or ref_reloc_sym based address, but that is misusing
reloc_sym->addr and reloc_sym->unrelocated_addr. If map is not
relocated (map->reloc == 0), we can use reloc_sym->addr as unrelocated
address instead of reloc_sym->unrelocated_addr.

This usually does not happen. If we have a non-stripped ELF binary, we
will use it for map and debuginfo, if not, we use only kallsyms without
debuginfo. Thus, the map is always relocated (ELF and DWARF binary) or
not relocated (kallsyms).

However, if we allow the combination of debuginfo and kallsyms based map
(like using debuginfod), we have to check the map->reloc and choose the
collect address of reloc_sym.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Reviewed-by: Frank Ch. Eigler <fche@redhat.com>
Cc: Aaron Merey <amerey@redhat.com>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Link: http://lore.kernel.org/lkml/160041609047.912668.14314639291419159274.stgit@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Masami Hiramatsu and committed by
Arnaldo Carvalho de Melo
ac7a75d1 7d537a8d

+5 -3
+5 -3
tools/perf/util/probe-event.c
··· 129 129 struct map *map; 130 130 131 131 /* ref_reloc_sym is just a label. Need a special fix*/ 132 - reloc_sym = kernel_get_ref_reloc_sym(NULL); 132 + reloc_sym = kernel_get_ref_reloc_sym(&map); 133 133 if (reloc_sym && strcmp(name, reloc_sym->name) == 0) 134 - *addr = (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr; 134 + *addr = (!map->reloc || reloc) ? reloc_sym->addr : 135 + reloc_sym->unrelocated_addr; 135 136 else { 136 137 sym = machine__find_kernel_symbol_by_name(host_machine, name, &map); 137 138 if (!sym) ··· 796 795 free(tevs[i].point.symbol); 797 796 tevs[i].point.symbol = tmp; 798 797 tevs[i].point.offset = tevs[i].point.address - 799 - reloc_sym->unrelocated_addr; 798 + (map->reloc ? reloc_sym->unrelocated_addr : 799 + reloc_sym->addr); 800 800 } 801 801 return skipped; 802 802 }