[PATCH] fix perf Annotation of Thumb code

Subsystems: performance events subsystem, the rest

STALE5723d

5 messages, 3 authors, 2011-01-21 · open the first message on its own page

[PATCH] fix perf Annotation of Thumb code

From: Dr. David Alan Gilbert <hidden>
Date: 2011-01-21 16:40:32

Hi,
  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.
  
 
Dave

(For reference this corresponds to this bug
https://bugs.launchpad.net/linux-linaro/+bug/677547 )

        Signed-off-by: Dr. David Alan Gilbert [off-list ref]  
---
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];
 

Re: [PATCH] fix perf Annotation of Thumb code

From: Arnaldo Carvalho de Melo <hidden>
Date: 2011-01-21 17:13:27

Em Fri, Jan 21, 2011 at 04:40:19PM +0000, Dr. David Alan Gilbert escreveu:
Hi,
  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.
Thanks, adding it to perf/urgent.

- Arnaldo
   
quoted hunk
 
Dave

(For reference this corresponds to this bug
https://bugs.launchpad.net/linux-linaro/+bug/677547 )

        Signed-off-by: Dr. David Alan Gilbert [off-list ref]  
---
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];
 

Re: [PATCH] fix perf Annotation of Thumb code

From: Sergei Shtylyov <hidden>
Date: 2011-01-21 17:18:43

Hello.

Dr. David Alan Gilbert wrote:
  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.
Dave
(For reference this corresponds to this bug
https://bugs.launchpad.net/linux-linaro/+bug/677547 )
        Signed-off-by: Dr. David Alan Gilbert [off-list ref]
    Hm, I think there should be no spaces/tabs before signoff...
---
quoted hunk
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;
   The coding style used suggests spaces around -=.

WBR, Sergei

Re: [PATCH] fix perf Annotation of Thumb code

From: Arnaldo Carvalho de Melo <hidden>
Date: 2011-01-21 17:41:10

Em Fri, Jan 21, 2011 at 08:17:18PM +0300, Sergei Shtylyov escreveu:
quoted
(For reference this corresponds to this bug
https://bugs.launchpad.net/linux-linaro/+bug/677547 )
quoted
       Signed-off-by: Dr. David Alan Gilbert [off-list ref]
   Hm, I think there should be no spaces/tabs before signoff...
quoted
+			sym.st_value-=1;
  The coding style used suggests spaces around -=.

WBR, Sergei
I noticed both issues and will fix them up when applying the patch.

Thanks

- Arnaldo

Re: [PATCH] fix perf Annotation of Thumb code

From: David Gilbert <hidden>
Date: 2011-01-21 17:50:06

On 21 January 2011 17:40, Arnaldo Carvalho de Melo
[off-list ref] wrote:
Em Fri, Jan 21, 2011 at 08:17:18PM +0300, Sergei Shtylyov escreveu:
quoted
quoted
(For reference this corresponds to this bug
https://bugs.launchpad.net/linux-linaro/+bug/677547 )
quoted
? ? ? ?Signed-off-by: Dr. David Alan Gilbert [off-list ref]
? ?Hm, I think there should be no spaces/tabs before signoff...
quoted
+ ? ? ? ? ? ? ? ? ? ?sym.st_value-=1;
? The coding style used suggests spaces around -=.

WBR, Sergei
I noticed both issues and will fix them up when applying the patch.
Oops, sorry about those.  Thanks Sergei, Arnaldo.

Dave
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help