summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Martin <dave.martin@linaro.org>2010-08-03 11:49:01 +0100
committerWill Deacon <will.deacon@arm.com>2010-08-03 14:12:09 +0100
commit224a2106f63943b3194b2080bdf938ea94fe8d22 (patch)
tree40c06c9c792ea564cd13e32a38e57aafdd0c0a30
parent17c507ba926e4272d9ef077b6bfa256b7a85324a (diff)
perf symbols: work around incorrect ET_EXEC symbol adjustment
Workaround to adjust .text symbols from ET_EXEC images correctly. This is not a complete fix, but addresses the common case and does not create additional assumptions beyond those which perf already makes. ELF images with a weird link map may still be processed incorrectly (as at present) -- that will require a separate fix. The workaround allows correct symbol offsets to be generated for ET_EXEC executables on systems with separated debug info (where section sh_offset fields from the debug image may bear no relation to the layout of the executable image). The cover note accompanying this patch contains a more detailed explanation. Signed-off-by: Dave Martin <dave.martin@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--tools/perf/util/symbol.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index d80346d0d05..c991525908b 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1093,7 +1093,15 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
"sh_addr: %#Lx sh_offset: %#Lx\n", __func__,
(u64)sym.st_value, (u64)shdr.sh_addr,
(u64)shdr.sh_offset);
- sym.st_value -= shdr.sh_addr - shdr.sh_offset;
+ /* Assumptions:
+ * a) shdr.sh_addr - shdr.sh_offset ==
+ * map->start - map->pgoff
+ * b) map->pgoff == 0
+ * These are true iff we are looking at a function
+ * symbol in the main executable segment _and_
+ * the main executable segment starts at the start of
+ * the ELF image (normally true). */
+ sym.st_value -= map->start;
}
/*
* We need to figure out if the object was created from C++ sources