aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-aarch64
diff options
context:
space:
mode:
authorJiong Wang <jiong.wang@arm.com>2016-01-20 16:57:59 +0000
committerJiong Wang <jiong.wang@arm.com>2016-01-21 09:57:09 +0000
commit2f340668a9a7c00f8813b097b157b07fba8cfa82 (patch)
treee5cf0bc883324833481f0352a698c54bf21d9096 /ld/testsuite/ld-aarch64
parentaeb7056972f1b383578204b9151b0ae6d8c1df81 (diff)
downloadgdb-2f340668a9a7c00f8813b097b157b07fba8cfa82.zip
gdb-2f340668a9a7c00f8813b097b157b07fba8cfa82.tar.gz
gdb-2f340668a9a7c00f8813b097b157b07fba8cfa82.tar.bz2
[AArch64] Relax long branch veneer insertion for non STT_FUNC symbol
As defined at AArch64 ELF Specification (4.6.7 Call and Jump relocations), symbol with type of non STT_FUNC but in different input section with relocation place should insert long branch veneer also. Meanwhile the current long branch veneer infrastructure havn't considered the situation where the branch destination is "sym_value + rela->addend". This was OK because we only insert veneer for long call destination is STT_FUNC symbol for which the addend is always zero. But as we relax the support to other situations by this patch, we need to handle addend be non-zero value. For example, for static function, relocation against "local symbol" are turned into relocation against "section symbol + offset" where there is a valid addend. bfd/ * elfnn-aarch64.c (aarch64_type_of_stub): Allow insert long branch veneer for sym_sec != input_sec. (elfNN_aarch64_size_stub): Support STT_SECTION symbol. (elfNN_aarch64_final_link_relocate): Take rela addend into account when calculation destination. ld/ * testsuite/ld-aarch64/farcall-section.d: Delete. * testsuite/ld-aarch64/farcall-section.s: Delete. * testsuite/ld-aarch64/farcall-b-section.d: New expectation file. * testsuite/ld-aarch64/farcall-bl-section.d: Likewise. * testsuite/ld-aarch64/farcall-b-section.s: New testcase. * testsuite/ld-aarch64/farcall-bl-section.s: Likewise. * testsuite/ld-aarch64/aarch64-elf.exp: Likewise.
Diffstat (limited to 'ld/testsuite/ld-aarch64')
-rw-r--r--ld/testsuite/ld-aarch64/aarch64-elf.exp3
-rw-r--r--ld/testsuite/ld-aarch64/farcall-b-none-function.d21
-rw-r--r--ld/testsuite/ld-aarch64/farcall-b-section.d34
-rw-r--r--ld/testsuite/ld-aarch64/farcall-b-section.s20
-rw-r--r--ld/testsuite/ld-aarch64/farcall-bl-none-function.d21
-rw-r--r--ld/testsuite/ld-aarch64/farcall-bl-section.d34
-rw-r--r--ld/testsuite/ld-aarch64/farcall-bl-section.s20
-rw-r--r--ld/testsuite/ld-aarch64/farcall-section.d5
-rw-r--r--ld/testsuite/ld-aarch64/farcall-section.s19
9 files changed, 150 insertions, 27 deletions
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index c5c9ad0..939539e 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -170,7 +170,6 @@ run_dump_test "pcrel_pic_defined_local"
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"
@@ -181,6 +180,8 @@ run_dump_test "farcall-bl"
run_dump_test "farcall-b"
run_dump_test "farcall-b-none-function"
run_dump_test "farcall-bl-none-function"
+run_dump_test "farcall-b-section"
+run_dump_test "farcall-bl-section"
run_dump_test "tls-relax-all"
run_dump_test "tls-relax-gd-le"
diff --git a/ld/testsuite/ld-aarch64/farcall-b-none-function.d b/ld/testsuite/ld-aarch64/farcall-b-none-function.d
index 34a6568..ba2981f 100644
--- a/ld/testsuite/ld-aarch64/farcall-b-none-function.d
+++ b/ld/testsuite/ld-aarch64/farcall-b-none-function.d
@@ -2,4 +2,23 @@
#source: farcall-b-none-function.s
#as:
#ld: -Ttext 0x1000 --section-start .foo=0x8001000
-#error: .*\(.text\+0x0\): relocation truncated to fit: R_AARCH64_JUMP26 against symbol `bar'.*
+#objdump: -dr
+#...
+
+Disassembly of section .text:
+
+.* <_start>:
+ 1000: 14000003 b 100c <__bar_veneer>
+ 1004: d65f03c0 ret
+ 1008: 14000007 b 1024 <__bar_veneer\+0x18>
+
+.* <__bar_veneer>:
+ 100c: 90040010 adrp x16, 8001000 <bar>
+ 1010: 91000210 add x16, x16, #0x0
+ 1014: d61f0200 br x16
+ ...
+
+Disassembly of section .foo:
+
+.* <bar>:
+ 8001000: d65f03c0 ret
diff --git a/ld/testsuite/ld-aarch64/farcall-b-section.d b/ld/testsuite/ld-aarch64/farcall-b-section.d
new file mode 100644
index 0000000..4745c0f
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/farcall-b-section.d
@@ -0,0 +1,34 @@
+#name: aarch64-farcall-b-section
+#source: farcall-b-section.s
+#as:
+#ld: -Ttext 0x1000 --section-start .foo=0x8001000
+#objdump: -dr
+#...
+
+Disassembly of section .text:
+
+.* <_start>:
+ 1000: 14000008 b 1020 <___veneer>
+ 1004: 14000003 b 1010 <___veneer>
+ 1008: d65f03c0 ret
+ 100c: 1400000d b 1040 <___veneer\+0x20>
+
+.* <___veneer>:
+ 1010: 90040010 adrp x16, 8001000 <bar>
+ 1014: 91001210 add x16, x16, #0x4
+ 1018: d61f0200 br x16
+ 101c: 00000000 .inst 0x00000000 ; undefined
+
+.* <___veneer>:
+ 1020: 90040010 adrp x16, 8001000 <bar>
+ 1024: 91000210 add x16, x16, #0x0
+ 1028: d61f0200 br x16
+ ...
+
+Disassembly of section .foo:
+
+.* <bar>:
+ 8001000: d65f03c0 ret
+
+.* <bar2>:
+ 8001004: d65f03c0 ret
diff --git a/ld/testsuite/ld-aarch64/farcall-b-section.s b/ld/testsuite/ld-aarch64/farcall-b-section.s
new file mode 100644
index 0000000..1a135ef
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/farcall-b-section.s
@@ -0,0 +1,20 @@
+.global _start
+
+# We will place the section .text at 0x1000.
+
+ .text
+
+_start:
+ b bar
+ b bar2
+ ret
+
+# We will place the section .foo at 0x8001000.
+
+ .section .foo, "xa"
+ .type bar, @function
+bar:
+ ret
+ .type bar2, @function
+bar2:
+ ret
diff --git a/ld/testsuite/ld-aarch64/farcall-bl-none-function.d b/ld/testsuite/ld-aarch64/farcall-bl-none-function.d
index 6ce9ca4..b6a4dda 100644
--- a/ld/testsuite/ld-aarch64/farcall-bl-none-function.d
+++ b/ld/testsuite/ld-aarch64/farcall-bl-none-function.d
@@ -2,4 +2,23 @@
#source: farcall-bl-none-function.s
#as:
#ld: -Ttext 0x1000 --section-start .foo=0x8001000
-#error: .*\(.text\+0x0\): relocation truncated to fit: R_AARCH64_CALL26 against symbol `bar'.*
+#objdump: -dr
+#...
+
+Disassembly of section .text:
+
+.* <_start>:
+ 1000: 94000003 bl 100c <__bar_veneer>
+ 1004: d65f03c0 ret
+ 1008: 14000007 b 1024 <__bar_veneer\+0x18>
+
+.* <__bar_veneer>:
+ 100c: 90040010 adrp x16, 8001000 <bar>
+ 1010: 91000210 add x16, x16, #0x0
+ 1014: d61f0200 br x16
+ ...
+
+Disassembly of section .foo:
+
+.* <bar>:
+ 8001000: d65f03c0 ret
diff --git a/ld/testsuite/ld-aarch64/farcall-bl-section.d b/ld/testsuite/ld-aarch64/farcall-bl-section.d
new file mode 100644
index 0000000..2bd4f85
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/farcall-bl-section.d
@@ -0,0 +1,34 @@
+#name: aarch64-farcall-bl-section
+#source: farcall-bl-section.s
+#as:
+#ld: -Ttext 0x1000 --section-start .foo=0x8001000
+#objdump: -dr
+#...
+
+Disassembly of section .text:
+
+.* <_start>:
+ 1000: 94000008 bl 1020 <___veneer>
+ 1004: 94000003 bl 1010 <___veneer>
+ 1008: d65f03c0 ret
+ 100c: 1400000d b 1040 <___veneer\+0x20>
+
+.* <___veneer>:
+ 1010: 90040010 adrp x16, 8001000 <bar>
+ 1014: 91001210 add x16, x16, #0x4
+ 1018: d61f0200 br x16
+ 101c: 00000000 .inst 0x00000000 ; undefined
+
+.* <___veneer>:
+ 1020: 90040010 adrp x16, 8001000 <bar>
+ 1024: 91000210 add x16, x16, #0x0
+ 1028: d61f0200 br x16
+ ...
+
+Disassembly of section .foo:
+
+.* <bar>:
+ 8001000: d65f03c0 ret
+
+.* <bar2>:
+ 8001004: d65f03c0 ret
diff --git a/ld/testsuite/ld-aarch64/farcall-bl-section.s b/ld/testsuite/ld-aarch64/farcall-bl-section.s
new file mode 100644
index 0000000..4469d4d
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/farcall-bl-section.s
@@ -0,0 +1,20 @@
+ .global _start
+
+# We will place the section .text at 0x1000.
+
+ .text
+
+_start:
+ bl bar
+ bl bar2
+ ret
+
+# We will place the section .foo at 0x8001000.
+
+ .section .foo, "xa"
+ .type bar, @function
+bar:
+ ret
+ .type bar2, @function
+bar2:
+ ret
diff --git a/ld/testsuite/ld-aarch64/farcall-section.d b/ld/testsuite/ld-aarch64/farcall-section.d
deleted file mode 100644
index 85775e1..0000000
--- a/ld/testsuite/ld-aarch64/farcall-section.d
+++ /dev/null
@@ -1,5 +0,0 @@
-#name: Aarch64 farcall to symbol of type STT_SECTION
-#source: farcall-section.s
-#as:
-#ld: -Ttext 0x1000 --section-start .foo=0x8001014
-#error: .*\(.text\+0x0\): relocation truncated to fit: R_AARCH64_CALL26 against `.foo'
diff --git a/ld/testsuite/ld-aarch64/farcall-section.s b/ld/testsuite/ld-aarch64/farcall-section.s
deleted file mode 100644
index 86a070c..0000000
--- a/ld/testsuite/ld-aarch64/farcall-section.s
+++ /dev/null
@@ -1,19 +0,0 @@
-# Test to ensure that an Aarch64 call exceeding 128MB generates an error
-# if the destination is of type STT_SECTION (eg non-global symbol)
-
- .global _start
-
-# We will place the section .text at 0x1000.
-
- .text
-
-_start:
- bl bar
-
-# We will place the section .foo at 0x8001020.
-
- .section .foo, "xa"
-
-bar:
- ret
-