From: tip-bot for Wang Nan <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: kirr@nexedi.com, linux-kernel@vger.kernel.org,
hekuang@huawei.com, wangnan0@huawei.com, tglx@linutronix.de,
dev@codyps.com, jolsa@kernel.org, hpa@zytor.com, acme@redhat.com,
mingo@kernel.org, namhyung@kernel.org, lizefan@huawei.com,
masami.hiramatsu.pt@hitachi.com, adrian.hunter@intel.com
Subject: [tip:perf/core] perf symbols: Record text offset in dso to calculate objdump address
Date: Wed, 13 Apr 2016 00:19:44 -0700 [thread overview]
Message-ID: <tip-a58f7033ba892b7d299954b94471450d72623039@git.kernel.org> (raw)
In-Reply-To: <1460024671-64774-2-git-send-email-wangnan0@huawei.com>
Commit-ID: a58f7033ba892b7d299954b94471450d72623039
Gitweb: http://git.kernel.org/tip/a58f7033ba892b7d299954b94471450d72623039
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Thu, 7 Apr 2016 10:24:30 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 8 Apr 2016 09:58:14 -0300
perf symbols: Record text offset in dso to calculate objdump address
In this patch, the offset of '.text' section is stored into dso
and used here to re-calculate address to objdump.
In most of the cases, executable code is in '.text' section, so the
adjustment made to a symbol in dso__load_sym (using
sym.st_value -= shdr.sh_addr - shdr.sh_offset) should equal to
'sym.st_value -= dso->text_offset'. Therefore, adding text_offset back
get objdump address from symbol address (rip). However, it is not true
for kernel and kernel module since there could be multiple executable
sections with different offset. Exclude kernel for this reason.
After this patch, even dso->adjust_symbols is set to true for shared
objects, map__rip_2objdump() and map__objdump_2mem() would return
correct result, so perf behavior of annotate won't be changed.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1460024671-64774-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/map.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 171b6d1..02c3186 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -431,6 +431,13 @@ u64 map__rip_2objdump(struct map *map, u64 rip)
if (map->dso->rel)
return rip - map->pgoff;
+ /*
+ * kernel modules also have DSO_TYPE_USER in dso->kernel,
+ * but all kernel modules are ET_REL, so won't get here.
+ */
+ if (map->dso->kernel == DSO_TYPE_USER)
+ return rip + map->dso->text_offset;
+
return map->unmap_ip(map, rip) - map->reloc;
}
@@ -454,6 +461,13 @@ u64 map__objdump_2mem(struct map *map, u64 ip)
if (map->dso->rel)
return map->unmap_ip(map, ip + map->pgoff);
+ /*
+ * kernel modules also have DSO_TYPE_USER in dso->kernel,
+ * but all kernel modules are ET_REL, so won't get here.
+ */
+ if (map->dso->kernel == DSO_TYPE_USER)
+ return map->unmap_ip(map, ip - map->dso->text_offset);
+
return ip + map->reloc;
}
next prev parent reply other threads:[~2016-04-13 7:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 10:24 [RESEND PATCH 0/2] perf tools: Fix Android symbol resolution Wang Nan
2016-04-07 10:24 ` [RESEND PATCH 1/2] perf tools: Record text offset in dso to calculate objdump address Wang Nan
2016-04-13 7:19 ` tip-bot for Wang Nan [this message]
2016-04-07 10:24 ` [RESEND PATCH 2/2] perf tools: Adjust symbol for shared objects Wang Nan
2016-04-07 20:06 ` Arnaldo Carvalho de Melo
2016-04-13 7:20 ` [tip:perf/core] perf symbols: " tip-bot for Wang Nan
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=tip-a58f7033ba892b7d299954b94471450d72623039@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=dev@codyps.com \
--cc=hekuang@huawei.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=kirr@nexedi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=wangnan0@huawei.com \
/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
Powered by JetHome