This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[AArch64] Long branch veneer support far symbol defined by --defsym
- From: Jiong Wang <jiong dot wang at arm dot com>
- To: "binutils\ at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 21 Jul 2015 09:32:57 +0100
- Subject: [AArch64] Long branch veneer support far symbol defined by --defsym
- Authentication-results: sourceware.org; auth=none
- References: <n99pp3sgori dot fsf at arm dot com> <n99oajcgon5 dot fsf at arm dot com>
Another long branch veneer issue in AArch64 backend is currently we
reject far symbol defined by --defsym when generating long branch
veneer. This is too strict as according to AArch64 ELF Specification,
symbol with type of non STT_FUNC but in different input section with
relocation place should insert long branch veneer.
To support symbol defined by --defsym, we need to support symbol comes
from ABS section at least.
OK for trunk?
Thanks
2015-07-20 Jiong Wang <jiong.wang@arm.com>
bfd/
* bfd/elfnn-aarch64.c (aarch64_type_of_stub): New parameter "sym_sec".
Loose the check for symbol from ABS section.
(elfNN_aarch64_size_stubs): Pass sym_sec.
ld/testsuite/
* ld-aarch64/farcall-b-defsym.s: New test.
* ld-aarch64/farcall-bl-defsym.s: Ditto.
* ld-aarch64/farcall-b-defsym.d: New expectation.
* ld-aarch64/farcall-bl-defsym.d: Ditto.
--
Regards,
Jiong
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index e05a5da..cfc3ad1 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -2205,6 +2205,7 @@ static enum elf_aarch64_stub_type
aarch64_type_of_stub (struct bfd_link_info *info,
asection *input_sec,
const Elf_Internal_Rela *rel,
+ asection *sym_sec,
unsigned char st_type,
struct elf_aarch64_link_hash_entry *hash,
bfd_vma destination)
@@ -2216,7 +2217,8 @@ aarch64_type_of_stub (struct bfd_link_info *info,
enum elf_aarch64_stub_type stub_type = aarch64_stub_none;
bfd_boolean via_plt_p;
- if (st_type != STT_FUNC)
+ if (st_type != STT_FUNC
+ && (sym_sec != bfd_abs_section_ptr))
return stub_type;
globals = elf_aarch64_hash_table (info);
@@ -3704,7 +3706,7 @@ elfNN_aarch64_size_stubs (bfd *output_bfd,
/* Determine what (if any) linker stub is needed. */
stub_type = aarch64_type_of_stub
- (info, section, irela, st_type, hash, destination);
+ (info, section, irela, sym_sec, st_type, hash, destination);
if (stub_type == aarch64_stub_none)
continue;
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index bfbbe24..f3dc51c 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -113,6 +113,8 @@ run_dump_test "limit-b"
run_dump_test "limit-bl"
run_dump_test "farcall-section"
run_dump_test "farcall-back"
+run_dump_test "farcall-b-defsym"
+run_dump_test "farcall-bl-defsym"
run_dump_test "farcall-bl"
run_dump_test "farcall-b"
run_dump_test "farcall-b-none-function"
diff --git a/ld/testsuite/ld-aarch64/farcall-b-defsym.d b/ld/testsuite/ld-aarch64/farcall-b-defsym.d
new file mode 100644
index 0000000..c3e1602
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/farcall-b-defsym.d
@@ -0,0 +1,18 @@
+#name: aarch64-farcall-b-defsym
+#source: farcall-b-defsym.s
+#as:
+#ld: -Ttext 0x1000 --defsym=bar=0x8001000
+#objdump: -dr
+#...
+
+Disassembly of section .text:
+
+0000000000001000 <_start>:
+ +1000: 14000003 b 100c <__bar_veneer>
+ +1004: d65f03c0 ret
+[ \t]+1008:[ \t]+14000007[ \t]+b[ \t]+1024 <__bar_veneer\+0x18>
+000000000000100c <__bar_veneer>:
+ 100c: 90040010 adrp x16, 8001000 <bar>
+ 1010: 91000210 add x16, x16, #0x0
+ 1014: d61f0200 br x16
+ ...
diff --git a/ld/testsuite/ld-aarch64/farcall-b-defsym.s b/ld/testsuite/ld-aarch64/farcall-b-defsym.s
new file mode 100644
index 0000000..3eec50c
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/farcall-b-defsym.s
@@ -0,0 +1,10 @@
+ .global _start
+ .global bar
+
+# We will place the section .text at 0x1000.
+
+ .text
+
+_start:
+ b bar
+ ret
diff --git a/ld/testsuite/ld-aarch64/farcall-bl-defsym.d b/ld/testsuite/ld-aarch64/farcall-bl-defsym.d
new file mode 100644
index 0000000..68332bf
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/farcall-bl-defsym.d
@@ -0,0 +1,18 @@
+#name: aarch64-farcall-bl-defsym
+#source: farcall-bl-defsym.s
+#as:
+#ld: -Ttext 0x1000 --defsym=bar=0x8001000
+#objdump: -dr
+#...
+
+Disassembly of section .text:
+
+0000000000001000 <_start>:
+ +1000: 94000003 bl 100c <__bar_veneer>
+ +1004: d65f03c0 ret
+[ \t]+1008:[ \t]+14000007[ \t]+b[ \t]+1024 <__bar_veneer\+0x18>
+000000000000100c <__bar_veneer>:
+ 100c: 90040010 adrp x16, 8001000 <bar>
+ 1010: 91000210 add x16, x16, #0x0
+ 1014: d61f0200 br x16
+ ...
diff --git a/ld/testsuite/ld-aarch64/farcall-bl-defsym.s b/ld/testsuite/ld-aarch64/farcall-bl-defsym.s
new file mode 100644
index 0000000..c525db6
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/farcall-bl-defsym.s
@@ -0,0 +1,10 @@
+ .global _start
+ .global bar
+
+# We will place the section .text at 0x1000.
+
+ .text
+
+_start:
+ bl bar
+ ret