aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2019-03-25 12:08:53 +0000
committerTamar Christina <tamar.christina@arm.com>2019-03-25 15:05:53 +0000
commit53b2f36bf6aa939feab6f82f05d7dad52f82660d (patch)
tree3ea5018d4dee6a17be4eae4bacbcb70f0bbbbb51 /binutils
parent9a93502fa81734d39f213ccb33b497bc40e1423d (diff)
downloadgdb-53b2f36bf6aa939feab6f82f05d7dad52f82660d.zip
gdb-53b2f36bf6aa939feab6f82f05d7dad52f82660d.tar.gz
gdb-53b2f36bf6aa939feab6f82f05d7dad52f82660d.tar.bz2
AArch64: Fix disassembler bug with out-of-order sections
The AArch64 disassembler has an optimization that it uses to reduce the amount it has to search for mapping symbols during disassembly. This optimization assumes that sections are listed in the section header in monotonic increasing VMAs. However this is not a requirement for the ELF specification. Because of this when such "out of order" sections occur the disassembler would pick the wrong mapping symbol to disassemble the section with. This fixes it by explicitly passing along the stop offset for the current disassembly glob and when this changes compared to the previous one we've seen the optimization won't be performed. In effect this restarts the search from a well defined starting point. Usually the symbol's address. The existing stop_vma can't be used for this as it is allowed to be unset and setting this unconditionally would change the semantics of this field. binutils/ChangeLog: * objdump.c (disassemble_bytes): Pass stop_offset. * testsuite/binutils-all/aarch64/out-of-order.T: New test. * testsuite/binutils-all/aarch64/out-of-order.d: New test. * testsuite/binutils-all/aarch64/out-of-order.s: New test. include/ChangeLog: * dis-asm.h (struct disassemble_info): Add stop_offset. opcodes/ChangeLog: * aarch64-dis.c (last_stop_offset): New. (print_insn_aarch64): Use stop_offset.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/objdump.c1
-rw-r--r--binutils/testsuite/binutils-all/aarch64/out-of-order.T14
-rw-r--r--binutils/testsuite/binutils-all/aarch64/out-of-order.d27
-rw-r--r--binutils/testsuite/binutils-all/aarch64/out-of-order.s28
5 files changed, 77 insertions, 0 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6fa4bf4..121c54d 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2019-03-25 Tamar Christina <tamar.christina@arm.com>
+
+ * objdump.c (disassemble_bytes): Pass stop_offset.
+ * testsuite/binutils-all/aarch64/out-of-order.T: New test.
+ * testsuite/binutils-all/aarch64/out-of-order.d: New test.
+ * testsuite/binutils-all/aarch64/out-of-order.s: New test.
+
2019-03-19 Nick Clifton <nickc@redhat.com>
PR 24360
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 79aed75..d80b3f5 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -1991,6 +1991,7 @@ disassemble_bytes (struct disassemble_info * inf,
disassembling code of course, and when -D is in effect. */
inf->stop_vma = section->vma + stop_offset;
+ inf->stop_offset = stop_offset;
octets = (*disassemble_fn) (section->vma + addr_offset, inf);
inf->stop_vma = 0;
diff --git a/binutils/testsuite/binutils-all/aarch64/out-of-order.T b/binutils/testsuite/binutils-all/aarch64/out-of-order.T
new file mode 100644
index 0000000..489ae80
--- /dev/null
+++ b/binutils/testsuite/binutils-all/aarch64/out-of-order.T
@@ -0,0 +1,14 @@
+ENTRY(v1)
+SECTIONS
+{
+ . = 0xffe00000;
+ .global : { *(.global) }
+ . = 0x4018280;
+ .func2 : { *(.func2) }
+ . = 0x4005000;
+ .func1 : { *(.func1) }
+ . = 0x4015000;
+ .func3 : { *(.func3) }
+ .data : { *(.data) }
+ .rodata : { *(.rodata) }
+} \ No newline at end of file
diff --git a/binutils/testsuite/binutils-all/aarch64/out-of-order.d b/binutils/testsuite/binutils-all/aarch64/out-of-order.d
new file mode 100644
index 0000000..410f37f
--- /dev/null
+++ b/binutils/testsuite/binutils-all/aarch64/out-of-order.d
@@ -0,0 +1,27 @@
+#PROG: objcopy
+#ld: -T out-of-order.T
+#objdump: -d
+#name: Check if disassembler can handle sections in different order than header
+
+.*: +file format .*aarch64.*
+
+Disassembly of section \.func2:
+
+0000000004018280 <\.func2>:
+ 4018280: 8b010000 add x0, x0, x1
+
+Disassembly of section \.func1:
+
+0000000004005000 <v1>:
+ 4005000: 8b010000 add x0, x0, x1
+ 4005004: 00000000 \.word 0x00000000
+
+Disassembly of section \.func3:
+
+0000000004015000 <\.func3>:
+ 4015000: 8b010000 add x0, x0, x1
+ 4015004: 8b010000 add x0, x0, x1
+ 4015008: 8b010000 add x0, x0, x1
+ 401500c: 8b010000 add x0, x0, x1
+ 4015010: 8b010000 add x0, x0, x1
+ 4015014: 00000000 \.word 0x00000000
diff --git a/binutils/testsuite/binutils-all/aarch64/out-of-order.s b/binutils/testsuite/binutils-all/aarch64/out-of-order.s
new file mode 100644
index 0000000..6c52e85
--- /dev/null
+++ b/binutils/testsuite/binutils-all/aarch64/out-of-order.s
@@ -0,0 +1,28 @@
+ .text
+ .global v1
+ .section .func1,"ax",@progbits
+ .type v1 %function
+ .size v1, 4
+v1:
+ add x0, x0, x1
+ .word 0
+
+ .section .func2,"ax",@progbits
+ add x0, x0, x1
+
+ .section .func3,"ax",@progbits
+ add x0, x0, x1
+ add x0, x0, x1
+ add x0, x0, x1
+ add x0, x0, x1
+ add x0, x0, x1
+ .word 0
+
+ .data
+ .section .global,"aw",@progbits
+ .xword 1
+ .xword 1
+ .xword 1
+
+ .section .rodata
+ .word 4