[lkml]   [2011]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] fix perf Annotation of Thumb code
In ARM's Thumb mode the bottom bit of the symbol address is set to mark
the function as Thumb; the instructions are in reality 2 or 4 byte on 2
byte alignments, and when the +1 address is used in annotate it causes
objdump to disassemble invalid instructions.

The patch removes that bottom bit during symbol loading.
This patch is against current linus's git, (2b1caf.....).
Many thinks to Dave Martin for comments on an initial version of the patch.


(For reference this corresponds to this bug )

Signed-off-by: Dr. David Alan Gilbert <>

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 15ccfba..36e76c1 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1161,6 +1161,13 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,

section_name = elf_sec__name(&shdr, secstrs);

+ /* On ARM, symbols for thumb functions have 1 added to
+ * the symbol address as a flag - remove it */
+ if ((ehdr.e_machine == EM_ARM) &&
+ (map->type == MAP__FUNCTION) &&
+ (sym.st_value & 1))
+ sym.st_value-=1;
if (self->kernel != DSO_TYPE_USER || kmodule) {
char dso_name[PATH_MAX];

 \ /
  Last update: 2011-01-21 17:43    [W:0.050 / U:0.808 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site