Fix ARM objdump mapping symbols bug with multiple sections
Joseph S. Myers
joseph@codesourcery.com
Mon Mar 30 14:43:00 GMT 2009
When objdump searches for mapping symbols on ARM EABI to determine
whether to treat bytes being disassembled as code or as data, it has
both a forwards and a backwards search for mapping symbols from a
current symbol table location.
The forwards search makes sure that mapping symbols for other sections
are ignored. The backwards search is missing this check. Thus in
cases with multiple sections with mapping symbols, as shown in the
included testcase, disassembly can be incorrect; in this testcase the
last instruction of f1 (the instruction after symbol f1a) is wrongly
disassembled as data without this patch. This patch adds the same
check on the section to the backwards search as in the forwards
search.
Tested with no regressions with cross to arm-none-eabi. Approved
off-list by Daniel; committed to mainline.
gas/testsuite:
2009-03-30 Joseph Myers <joseph@codesourcery.com>
* gas/arm/mapsecs.d, gas/arm/mapsecs.s: New.
opcodes:
2009-03-30 Joseph Myers <joseph@codesourcery.com>
* arm-dis.c (print_insn): Also check section matches in backwards
search for mapping symbol.
Index: gas/testsuite/gas/arm/mapsecs.d
===================================================================
RCS file: gas/testsuite/gas/arm/mapsecs.d
diff -N gas/testsuite/gas/arm/mapsecs.d
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/mapsecs.d 30 Mar 2009 14:38:02 -0000
@@ -0,0 +1,45 @@
+#as: -EL
+#objdump: --syms --special-syms -d
+#name: ARM Mapping Symbols with multiple sections
+# This test is only valid on EABI based ports.
+#target: *-*-*eabi *-*-symbianelf *-*-linux-* *-*-elf
+#source: mapsecs.s
+
+
+.*: +file format .*arm.*
+
+SYMBOL TABLE:
+0+00 l d .text 00000000 .text
+0+00 l d .data 00000000 .data
+0+00 l d .bss 00000000 .bss
+0+00 l d .text.f1 00000000 .text.f1
+0+00 l F .text.f1 00000000 f1
+0+00 l .text.f1 00000000 \$a
+0+08 l .text.f1 00000000 f1a
+0+00 l d .text.f2 00000000 .text.f2
+0+00 l F .text.f2 00000000 f2
+0+00 l .text.f2 00000000 \$a
+0+04 l .text.f2 00000000 \$d
+0+08 l .text.f2 00000000 f2a
+0+08 l .text.f2 00000000 \$a
+0+00 l d .ARM.attributes 00000000 .ARM.attributes
+
+
+
+Disassembly of section .text.f1:
+
+00000000 <f1>:
+ 0: e1a00000 nop \(mov r0,r0\)
+ 4: e1a00000 nop \(mov r0,r0\)
+
+00000008 <f1a>:
+ 8: e1a00000 nop \(mov r0,r0\)
+
+Disassembly of section .text.f2:
+
+00000000 <f2>:
+ 0: e1a00000 nop \(mov r0,r0\)
+ 4: 00000001 .word 0x00000001
+
+00000008 <f2a>:
+ 8: e1a00000 nop \(mov r0,r0\)
Index: gas/testsuite/gas/arm/mapsecs.s
===================================================================
RCS file: gas/testsuite/gas/arm/mapsecs.s
diff -N gas/testsuite/gas/arm/mapsecs.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/arm/mapsecs.s 30 Mar 2009 14:38:02 -0000
@@ -0,0 +1,15 @@
+ .text
+ .section .text.f1,"ax",%progbits
+ .type f1, %function
+f1:
+ nop
+ nop
+f1a:
+ nop
+ .section .text.f2,"ax",%progbits
+ .type f2, %function
+f2:
+ nop
+ .word 1
+f2a:
+ nop
Index: opcodes/arm-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/arm-dis.c,v
retrieving revision 1.93
diff -u -r1.93 arm-dis.c
--- opcodes/arm-dis.c 23 Feb 2009 14:58:34 -0000 1.93
+++ opcodes/arm-dis.c 30 Mar 2009 14:38:04 -0000
@@ -4041,7 +4041,9 @@
for a preceeding one. */
for (; n >= 0; n--)
{
- if (get_sym_code_type (info, n, &type))
+ if ((info->section == NULL
+ || info->section == info->symtab[n]->section)
+ && get_sym_code_type (info, n, &type))
{
last_sym = n;
found = TRUE;
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Binutils
mailing list