LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] fix perf Annotation of Thumb code
@ 2011-01-21 16:40 Dr. David Alan Gilbert
2011-01-21 17:13 ` Arnaldo Carvalho de Melo
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Dr. David Alan Gilbert @ 2011-01-21 16:40 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, acme, mingo; +Cc: dave.martin
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 <david.gilbert@linaro.org>
---
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];
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] fix perf Annotation of Thumb code
2011-01-21 16:40 [PATCH] fix perf Annotation of Thumb code Dr. David Alan Gilbert
@ 2011-01-21 17:13 ` Arnaldo Carvalho de Melo
2011-01-21 17:17 ` Sergei Shtylyov
2011-01-22 15:19 ` [tip:perf/urgent] perf symbols: Fix annotation of thumb code tip-bot for Dr. David Alan Gilbert
2 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-01-21 17:13 UTC (permalink / raw)
To: Dr. David Alan Gilbert; +Cc: linux-kernel, linux-arm-kernel, mingo, dave.martin
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
>
> Dave
>
> (For reference this corresponds to this bug
> https://bugs.launchpad.net/linux-linaro/+bug/677547 )
>
> Signed-off-by: Dr. David Alan Gilbert <david.gilbert@linaro.org>
> ---
>
> 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];
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fix perf Annotation of Thumb code
2011-01-21 16:40 [PATCH] fix perf Annotation of Thumb code Dr. David Alan Gilbert
2011-01-21 17:13 ` Arnaldo Carvalho de Melo
@ 2011-01-21 17:17 ` Sergei Shtylyov
2011-01-21 17:40 ` Arnaldo Carvalho de Melo
2011-01-22 15:19 ` [tip:perf/urgent] perf symbols: Fix annotation of thumb code tip-bot for Dr. David Alan Gilbert
2 siblings, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2011-01-21 17:17 UTC (permalink / raw)
To: Dr. David Alan Gilbert
Cc: linux-kernel, linux-arm-kernel, acme, mingo, dave.martin
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 <david.gilbert@linaro.org>
Hm, I think there should be no spaces/tabs before signoff...
> ---
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fix perf Annotation of Thumb code
2011-01-21 17:17 ` Sergei Shtylyov
@ 2011-01-21 17:40 ` Arnaldo Carvalho de Melo
2011-01-21 17:50 ` David Gilbert
0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-01-21 17:40 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Dr. David Alan Gilbert, linux-kernel, linux-arm-kernel, mingo,
dave.martin
Em Fri, Jan 21, 2011 at 08:17:18PM +0300, Sergei Shtylyov escreveu:
> >(For reference this corresponds to this bug
> >https://bugs.launchpad.net/linux-linaro/+bug/677547 )
>
> > Signed-off-by: Dr. David Alan Gilbert <david.gilbert@linaro.org>
>
> Hm, I think there should be no spaces/tabs before signoff...
>
> >+ 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fix perf Annotation of Thumb code
2011-01-21 17:40 ` Arnaldo Carvalho de Melo
@ 2011-01-21 17:50 ` David Gilbert
0 siblings, 0 replies; 6+ messages in thread
From: David Gilbert @ 2011-01-21 17:50 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Sergei Shtylyov, linux-kernel, linux-arm-kernel, mingo, dave.martin
On 21 January 2011 17:40, Arnaldo Carvalho de Melo
<acme@ghostprotocols.net> wrote:
> Em Fri, Jan 21, 2011 at 08:17:18PM +0300, Sergei Shtylyov escreveu:
>> >(For reference this corresponds to this bug
>> >https://bugs.launchpad.net/linux-linaro/+bug/677547 )
>>
>> > Signed-off-by: Dr. David Alan Gilbert <david.gilbert@linaro.org>
>>
>> Hm, I think there should be no spaces/tabs before signoff...
>>
>> >+ 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip:perf/urgent] perf symbols: Fix annotation of thumb code
2011-01-21 16:40 [PATCH] fix perf Annotation of Thumb code Dr. David Alan Gilbert
2011-01-21 17:13 ` Arnaldo Carvalho de Melo
2011-01-21 17:17 ` Sergei Shtylyov
@ 2011-01-22 15:19 ` tip-bot for Dr. David Alan Gilbert
2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Dr. David Alan Gilbert @ 2011-01-22 15:19 UTC (permalink / raw)
To: linux-tip-commits
Cc: acme, linux-kernel, dave.martin, hpa, mingo, david.gilbert, tglx, mingo
Commit-ID: b2f8fb237e9cc407a02aca401369c15babae35dd
Gitweb: http://git.kernel.org/tip/b2f8fb237e9cc407a02aca401369c15babae35dd
Author: Dr. David Alan Gilbert <david.gilbert@linaro.org>
AuthorDate: Fri, 21 Jan 2011 16:40:19 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 21 Jan 2011 16:32:18 -0200
perf symbols: Fix 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.
Many thinks to Dave Martin for comments on an initial version of the
patch.
(For reference this corresponds to this bug
https://bugs.launchpad.net/linux-linaro/+bug/677547 )
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Dave Martin <dave.martin@linaro.org>
LKML-Reference: <20110121163922.GA31398@davesworkthinkpad>
Signed-off-by: Dr. David Alan Gilbert <david.gilbert@linaro.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/symbol.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 15ccfba..e32478e 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;
+
if (self->kernel != DSO_TYPE_USER || kmodule) {
char dso_name[PATH_MAX];
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-01-22 15:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-21 16:40 [PATCH] fix perf Annotation of Thumb code Dr. David Alan Gilbert
2011-01-21 17:13 ` Arnaldo Carvalho de Melo
2011-01-21 17:17 ` Sergei Shtylyov
2011-01-21 17:40 ` Arnaldo Carvalho de Melo
2011-01-21 17:50 ` David Gilbert
2011-01-22 15:19 ` [tip:perf/urgent] perf symbols: Fix annotation of thumb code tip-bot for Dr. David Alan Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).