Skip to contentSkip to conversation

perf tools: Fix annotation of vdso

PATCH New Adrian Hunter 2 participants 2 messages Aug 14, 2015 – Aug 20, 2015 perf events

lore
Share & tools
lore

Adrian Hunter

author reviewer
#0 lore raw

PATCH 1/1 perf tools: Fix annotation of vdso

Older kernels attempt to prelink vdso to its virtual address. To permit annotation using objdump, the map__rip_2objdump() calculation must result in that same address which we can infer from the start and offset of the text section.

---
 tools/perf/util/symbol-elf.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/perf/util/symbol-elf.c +11 -0
index b0ad810f04dd..53bb5f59ec58 100644
@@ -875,6 +875,17 @@ int dso__load_sym(struct dso *dso, struct map *map,
 		}
 	}
 
+	/*
+	 * Handle any relocation of vdso necessary because older kernels
+	 * attempted to prelink vdso to its virtual address.
+	 */
+	if (dso__is_vdso(dso)) {
+		GElf_Shdr tshdr;
+
+		if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
+			map->reloc = map->start - tshdr.sh_addr + tshdr.sh_offset;
+	}
+
 	dso->adjust_symbols = runtime_ss->adjust_symbols || ref_reloc(kmap);
 	/*
 	 * Initial kernel and module mappings do not map to the dso.  For
Signature · 1 line
1.9.1
#1 lore raw

[tip:perf/core] perf symbols: Fix annotation of vdso

perf symbols: Fix annotation of vdso
Commit-ID:  f0ee3b467ab7a74ffce75190259eb59dbf30ecad
Gitweb:     http://git.kernel.org/tip/f0ee3b467ab7a74ffce75190259eb59dbf30ecad
Author:     Adrian Hunter <[email protected]>
AuthorDate: Fri, 14 Aug 2015 15:50:06 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 17 Aug 2015 11:07:38 -0300

perf symbols: Fix annotation of vdso

Older kernels attempt to prelink vdso to its virtual address. To permit annotation using objdump, the map__rip_2objdump() calculation must result in that same address which we can infer from the start and offset of the text section.

---
 tools/perf/util/symbol-elf.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/perf/util/symbol-elf.c +11 -0
index b0ad810..53bb5f5 100644
@@ -875,6 +875,17 @@ int dso__load_sym(struct dso *dso, struct map *map,
 		}
 	}
 
+	/*
+	 * Handle any relocation of vdso necessary because older kernels
+	 * attempted to prelink vdso to its virtual address.
+	 */
+	if (dso__is_vdso(dso)) {
+		GElf_Shdr tshdr;
+
+		if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
+			map->reloc = map->start - tshdr.sh_addr + tshdr.sh_offset;
+	}
+
 	dso->adjust_symbols = runtime_ss->adjust_symbols || ref_reloc(kmap);
 	/*
 	 * Initial kernel and module mappings do not map to the dso.  For