aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2016-02-26 04:31:49 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-03-18 13:23:59 -0400
commit73cdf0c6ea9c597894924f3b91ad636389555c1b (patch)
treebe2f6c4e3cb8756029419e1cabdba3f1a8c7c684 /tools/perf
parentca70c24fb17b161a6096c584238cf81f664db45d (diff)
perf symbols: Record text offset in dso to calculate objdump address
Store DSO's .text offset into DSO, used for VDSOs and will also be used for other needs, like handling kernel modules. Signed-off-by: Wang Nan <wangnan0@huawei.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexei Starovoitov <ast@kernel.org> 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: Peter Zijlstra <peterz@infradead.org> Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1456479154-136027-2-git-send-email-wangnan0@huawei.com [ Extracted from larger patch ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/dso.h1
-rw-r--r--tools/perf/util/symbol-elf.c12
2 files changed, 7 insertions, 6 deletions
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 45ec4d0a50ed..ef3dbc989013 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -162,6 +162,7 @@ struct dso {
162 u8 loaded; 162 u8 loaded;
163 u8 rel; 163 u8 rel;
164 u8 build_id[BUILD_ID_SIZE]; 164 u8 build_id[BUILD_ID_SIZE];
165 u64 text_offset;
165 const char *short_name; 166 const char *short_name;
166 const char *long_name; 167 const char *long_name;
167 u16 long_name_len; 168 u16 long_name_len;
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index b1dd68f358fc..bc229a74c6a9 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -793,6 +793,7 @@ int dso__load_sym(struct dso *dso, struct map *map,
793 uint32_t idx; 793 uint32_t idx;
794 GElf_Ehdr ehdr; 794 GElf_Ehdr ehdr;
795 GElf_Shdr shdr; 795 GElf_Shdr shdr;
796 GElf_Shdr tshdr;
796 Elf_Data *syms, *opddata = NULL; 797 Elf_Data *syms, *opddata = NULL;
797 GElf_Sym sym; 798 GElf_Sym sym;
798 Elf_Scn *sec, *sec_strndx; 799 Elf_Scn *sec, *sec_strndx;
@@ -832,6 +833,9 @@ int dso__load_sym(struct dso *dso, struct map *map,
832 sec = syms_ss->symtab; 833 sec = syms_ss->symtab;
833 shdr = syms_ss->symshdr; 834 shdr = syms_ss->symshdr;
834 835
836 if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
837 dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
838
835 if (runtime_ss->opdsec) 839 if (runtime_ss->opdsec)
836 opddata = elf_rawdata(runtime_ss->opdsec, NULL); 840 opddata = elf_rawdata(runtime_ss->opdsec, NULL);
837 841
@@ -880,12 +884,8 @@ int dso__load_sym(struct dso *dso, struct map *map,
880 * Handle any relocation of vdso necessary because older kernels 884 * Handle any relocation of vdso necessary because older kernels
881 * attempted to prelink vdso to its virtual address. 885 * attempted to prelink vdso to its virtual address.
882 */ 886 */
883 if (dso__is_vdso(dso)) { 887 if (dso__is_vdso(dso))
884 GElf_Shdr tshdr; 888 map->reloc = map->start - dso->text_offset;
885
886 if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
887 map->reloc = map->start - tshdr.sh_addr + tshdr.sh_offset;
888 }
889 889
890 dso->adjust_symbols = runtime_ss->adjust_symbols || ref_reloc(kmap); 890 dso->adjust_symbols = runtime_ss->adjust_symbols || ref_reloc(kmap);
891 /* 891 /*