This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH, AArch64, LD] Fix branch stubs for BE.
- From: Tejas Belagod <tejas dot belagod at arm dot com>
- To: binutils at sourceware dot org
- Cc: Marcus Shawcroft <Marcus dot Shawcroft at arm dot com>
- Date: Thu, 26 Mar 2015 15:59:53 +0000
- Subject: [PATCH, AArch64, LD] Fix branch stubs for BE.
- Authentication-results: sourceware.org; auth=none
Hi,
The attached patch fixes branch stubs for BE. The fix replaces the call
to generic _bfd_final_link_relocate () in aarch64_build_one_stub () to
aarch64-specific relocation wrapper aarch64_relocate(). This prevents
the instructions getting filled with relocation bits in the reverse order.
aarch64-none-elf, aarch64_be-none-elf regressions happy.
OK for trunk and 2.25?
Thanks,
Tejas.
Changelog:
2015-03-26 Tejas Belagod <tejas.belagod@arm.com>
ld/testsuite
* ld-aarch64/farcall-back-be.d: New.
bfd/
* elfnn-aarch64.c (aarch64_build_one_stub): Replace the call to
generic _bfd_final_link_relocate with aarch64_relocate.
From fa79f91cdf7ec5f8daf3c21741398ac1b11b6c98 Mon Sep 17 00:00:00 2001
From: Tejas Belagod <tbelagod@arm.com>
Date: Thu, 26 Mar 2015 14:14:21 +0000
Subject: [PATCH] Fix branch
---
bfd/elfnn-aarch64.c | 19 +++-----
ld/testsuite/ld-aarch64/farcall-back-be.d | 74 +++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 13 deletions(-)
create mode 100644 ld/testsuite/ld-aarch64/farcall-back-be.d
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 9b62a5e..e0e4915 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -2477,24 +2477,17 @@ aarch64_build_one_stub (struct bfd_hash_entry *gen_entry,
of range. */
BFD_FAIL ();
- _bfd_final_link_relocate
- (elfNN_aarch64_howto_from_type (AARCH64_R (ADD_ABS_LO12_NC)),
- stub_bfd,
- stub_sec,
- stub_sec->contents,
- stub_entry->stub_offset + 4,
- sym_value,
- 0);
+ if (aarch64_relocate (AARCH64_R (ADD_ABS_LO12_NC), stub_bfd, stub_sec,
+ stub_entry->stub_offset + 4, sym_value))
+ BFD_FAIL ();
break;
case aarch64_stub_long_branch:
/* We want the value relative to the address 12 bytes back from the
value itself. */
- _bfd_final_link_relocate (elfNN_aarch64_howto_from_type
- (AARCH64_R (PRELNN)), stub_bfd, stub_sec,
- stub_sec->contents,
- stub_entry->stub_offset + 16,
- sym_value + 12, 0);
+ if (aarch64_relocate (AARCH64_R (PRELNN), stub_bfd, stub_sec,
+ stub_entry->stub_offset + 16, sym_value + 12))
+ BFD_FAIL ();
break;
case aarch64_stub_erratum_835769_veneer:
diff --git a/ld/testsuite/ld-aarch64/farcall-back-be.d b/ld/testsuite/ld-aarch64/farcall-back-be.d
new file mode 100644
index 0000000..f408b8c
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/farcall-back-be.d
@@ -0,0 +1,74 @@
+#name: aarch64-farcall-back-be
+#source: farcall-back.s
+#as:
+#ld: -Ttext 0x1000 --section-start .foo=0x100000000
+#objdump: -dr
+#target: aarch64_be-*-*
+#...
+
+Disassembly of section .text:
+
+0000000000001000 <_start>:
+ 1000: 14000413 b 204c <__bar1_veneer>
+ 1004: 94000412 bl 204c <__bar1_veneer>
+ 1008: 14000407 b 2024 <__bar2_veneer>
+ 100c: 94000406 bl 2024 <__bar2_veneer>
+ 1010: 14000409 b 2034 <__bar3_veneer>
+ 1014: 94000408 bl 2034 <__bar3_veneer>
+ 1018: d65f03c0 ret
+ ...
+
+000000000000201c <_back>:
+ 201c: d65f03c0 ret
+
+[ \t]+2020:[ \t]+14000013[ \t]+b[ \t]+206c <__bar1_veneer\+0x20>
+0000000000002024 <__bar2_veneer>:
+ 2024: f07ffff0 adrp x16, 100001000 <bar1\+0x1000>
+ 2028: 91002210 add x16, x16, #0x8
+ 202c: d61f0200 br x16
+ 2030: 00000000 .inst 0x00000000 ; undefined
+
+0000000000002034 <__bar3_veneer>:
+ 2034: 58000090 ldr x16, 2044 <__bar3_veneer\+0x10>
+ 2038: 10000011 adr x17, 2038 <__bar3_veneer\+0x4>
+ 203c: 8b110210 add x16, x16, x17
+ 2040: d61f0200 br x16
+ 2044: 00000000 .word 0x00000000
+ 2048: ffffffd8 .word 0xffffffd8
+
+000000000000204c <__bar1_veneer>:
+ 204c: d07ffff0 adrp x16, 100000000 <bar1>
+ 2050: 91000210 add x16, x16, #0x0
+ 2054: d61f0200 br x16
+ ...
+
+Disassembly of section .foo:
+
+0000000100000000 <bar1>:
+ 100000000: d65f03c0 ret
+ 100000004: 14000806 b 10000201c <___start_veneer>
+ ...
+
+0000000100001008 <bar2>:
+ 100001008: d65f03c0 ret
+ 10000100c: 14000404 b 10000201c <___start_veneer>
+ ...
+
+0000000100002010 <bar3>:
+ 100002010: d65f03c0 ret
+ 100002014: 14000008 b 100002034 <___back_veneer>
+
+[ \t]+100002018:[ \t]+1400000d[ \t]+b[ \t]+10000204c <___back_veneer\+0x18>
+000000010000201c <___start_veneer>:
+ 10000201c: 58000090 ldr x16, 10000202c <___start_veneer\+0x10>
+ 100002020: 10000011 adr x17, 100002020 <___start_veneer\+0x4>
+ 100002024: 8b110210 add x16, x16, x17
+ 100002028: d61f0200 br x16
+ 10000202c: fffffffe .word 0xfffffffe
+ 100002030: ffffefe0 .word 0xffffefe0
+
+0000000100002034 <___back_veneer>:
+ 100002034: 90800010 adrp x16, 2000 <_start\+0x1000>
+ 100002038: 91007210 add x16, x16, #0x1c
+ 10000203c: d61f0200 br x16
+ ...
--
1.9.1