From: Masami Hiramatsu <mhiramat@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: "Frank Ch . Eigler" <fche@redhat.com>,
Aaron Merey <amerey@redhat.com>,
Daniel Thompson <daniel.thompson@linaro.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] perf probe: Fix to adjust symbol address with correct reloc_sym address
Date: Thu, 17 Sep 2020 01:44:43 +0900 [thread overview]
Message-ID: <160027468295.803747.2704860727122011684.stgit@devnote2> (raw)
In-Reply-To: <160027467316.803747.10741549521899847231.stgit@devnote2>
Perf probe uses ref_reloc_sym to adjust symbol offset address
from debuginfo address or ref_reloc_sym based address, but
that is misused the 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 may 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 will 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>
---
tools/perf/util/probe-event.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 99d36ac77c08..17831f186ab5 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -129,9 +129,10 @@ static int kernel_get_symbol_address_by_name(const char *name, u64 *addr,
struct map *map;
/* ref_reloc_sym is just a label. Need a special fix*/
- reloc_sym = kernel_get_ref_reloc_sym(NULL);
+ reloc_sym = kernel_get_ref_reloc_sym(&map);
if (reloc_sym && strcmp(name, reloc_sym->name) == 0)
- *addr = (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr;
+ *addr = (!map->reloc || reloc) ? reloc_sym->addr :
+ reloc_sym->unrelocated_addr;
else {
sym = machine__find_kernel_symbol_by_name(host_machine, name, &map);
if (!sym)
@@ -795,7 +796,8 @@ post_process_kernel_probe_trace_events(struct probe_trace_event *tevs,
free(tevs[i].point.symbol);
tevs[i].point.symbol = tmp;
tevs[i].point.offset = tevs[i].point.address -
- reloc_sym->unrelocated_addr;
+ (map->reloc ? reloc_sym->unrelocated_addr :
+ reloc_sym->addr);
}
return skipped;
}
next prev parent reply other threads:[~2020-09-16 20:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 16:44 [PATCH 0/2] perf probe: Support debuginfod client Masami Hiramatsu
2020-09-16 16:44 ` Masami Hiramatsu [this message]
2020-09-16 16:44 ` [PATCH 2/2] perf probe: Fall back to debuginfod query if debuginfo and source not found Masami Hiramatsu
2020-09-18 0:40 ` Arnaldo Carvalho de Melo
2020-09-18 2:47 ` Masami Hiramatsu
2020-09-18 12:26 ` Arnaldo Carvalho de Melo
2020-09-16 18:13 ` [PATCH 0/2] perf probe: Support debuginfod client Frank Ch. Eigler
2020-09-16 18:52 ` Arnaldo Carvalho de Melo
2020-09-16 20:17 ` Frank Ch. Eigler
2020-09-17 3:07 ` Masami Hiramatsu
2020-09-17 13:54 ` Frank Ch. Eigler
2020-09-17 19:56 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=160027468295.803747.2704860727122011684.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=amerey@redhat.com \
--cc=daniel.thompson@linaro.org \
--cc=fche@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox