aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2008-05-15 17:00:15 +0000
committerNick Clifton <nickc@redhat.com>2008-05-15 17:00:15 +0000
commit906e58cab5ef4c02cbd341d913a3a07e4cba27df (patch)
treef8e8dc93ff35f8510b59bf9f217dab8002c537fa /ld/testsuite
parent83b94be54133a44825c4c33975d8fb72e286ed16 (diff)
downloadgdb-906e58cab5ef4c02cbd341d913a3a07e4cba27df.zip
gdb-906e58cab5ef4c02cbd341d913a3a07e4cba27df.tar.gz
gdb-906e58cab5ef4c02cbd341d913a3a07e4cba27df.tar.bz2
bfd/
* elf32-arm.c (THM2_MAX_FWD_BRANCH_OFFSET): Define. (THM2_MAX_BWD_BRANCH_OFFSET): Define. (ARM_MAX_FWD_BRANCH_OFFSET): Define. (ARM_MAX_BWD_BRANCH_OFFSET): Define. (THM_MAX_FWD_BRANCH_OFFSET): Define. (THM_MAX_BWD_BRANCH_OFFSET): Define. (arm_long_branch_stub): Define. (arm_pic_long_branch_stub): Define. (arm_thumb_v4t_long_branch_stub): Define. (arm_thumb_thumb_long_branch_stub): Define. (arm_thumb_arm_v4t_long_branch_stub): Define. (STUB_SUFFIX): Define. (elf32_arm_stub_type): Define. (elf32_arm_stub_hash_entry): Define. (elf32_arm_link_hash_entry): Add stub_cache field. (arm_stub_hash_lookup): Define. (elf32_arm_link_hash_table): Add stub_hash_table, stub_bfd, add_stub_section, layout_sections_again, stub_group, bfd_count, top_index, input_list fields. (elf32_arm_link_hash_newfunc): Init new field. (stub_hash_newfunc): New function. (elf32_arm_link_hash_table_create): Init stub_hash_table. (elf32_arm_hash_table_free): New function. (arm_type_of_stub): New function. (elf32_arm_stub_name): New function. (elf32_arm_get_stub_entry): New function. (elf32_arm_stub_add_mapping_symbol): New function. (elf32_arm_add_stub): New function. (arm_build_one_stub): New function. (arm_size_one_stub): New function. (elf32_arm_setup_section_lists): New function. (elf32_arm_next_input_section): New function. (group_sections): New function. (elf32_arm_size_stubs): New function. (elf32_arm_build_stubs): New function. (bfd_elf32_arm_add_glue_sections_to_bfd): Skip stub sections. (bfd_elf32_arm_process_before_allocation): No longer handle R_ARM_CALL and R_ARM_THM_CALL. (using_thumb_only): New function. (elf32_arm_final_link_relocate): Redirect calls to stub if range exceeds encoding capabilities. (bfd_elf32_bfd_link_hash_table_free): Define. * bfd-in.h (R_ARM_max): Fix value to 130. (elf32_arm_setup_section_lists): Protype. (elf32_arm_next_input_section): Protype. (elf32_arm_size_stubs): Protype. (elf32_arm_build_stubs): Protype. ld/ * emultempl/armelf.em (build_section_lists): New function. (stub_file): Define. (need_laying_out): Define. (group_size): Define. (hook_stub_info): Define. (hook_in_stub): New function. (elf32_arm_add_stub_section): New function. (gldarm_layout_sections_again): New function. (gld${EMULATION_NAME}_finish): Replace arm_elf_finish(). Generate stubs for long calls if needed. (arm_elf_create_output_section_statements): create stub_file bfd. (arm_for_each_input_file_wrapper): New function. (arm_lang_for_each_input_file): New function. (lang_for_each_input_file): Define. (PARSE_AND_LIST_PROLOGUE): Add option token OPTION_STUBGROUP_SIZE. (PARSE_AND_LIST_LONGOPTS): Add option stub-group-size. (PARSE_AND_LIST_OPTIONS): Add option stub-group-size. (PARSE_AND_LIST_ARGS_CASES): Add OPTION_STUBGROUP_SIZE case. (LDEMUL_FINISH): Update to gld${EMULATION_NAME}_finish. * ld/lang.c (print_input_statement): Skip if bfd has BFD_LINKER_CREATED. ld/testsuite * ld-arm/arm-elf.exp (armelftests): Add farcall-arm-arm, farcall-arm-arm-pic-veneer, farcall-arm-arm-be8 farcall-arm-thumb, farcall-arm-thumb-blx, farcall-arm-thumb-pic-veneer, farcall-arm-thumb-blx-pic-veneer, farcall-thumb-thumb, farcall-thumb-thumb-pic-veneer, farcall-thumb-thumb-blx, farcall-thumb-thumb-m, farcall-thumb-thumb-m-pic-veneer, farcall-thumb-thumb-blx-pic-veneer, farcall-thumb-arm, farcall-thumb-arm-pic-veneer, farcall-thumb-arm-blx, farcall-thumb-arm-blx-pic-veneer. Change thumb2-bl-as-thumb1-bad, thumb2-bl-bad. * ld-arm/thumb2-bl-as-thumb1-bad.d: Reflects farcall stub generation. * ld-arm/thumb2-bl-bad.d: Likewise. * ld-arm/thumb2-bl-as-thumb1-bad.s: Update comments. * ld-arm/thumb2-bl-bad.s: Likewise.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog18
-rw-r--r--ld/testsuite/ld-arm/arm-elf.exp76
-rw-r--r--ld/testsuite/ld-arm/farcall-arm-arm-be8.d14
-rw-r--r--ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d16
-rw-r--r--ld/testsuite/ld-arm/farcall-arm-arm.d14
-rw-r--r--ld/testsuite/ld-arm/farcall-arm-arm.s19
-rw-r--r--ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d16
-rw-r--r--ld/testsuite/ld-arm/farcall-arm-thumb-blx.d14
-rw-r--r--ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d16
-rw-r--r--ld/testsuite/ld-arm/farcall-arm-thumb.d16
-rw-r--r--ld/testsuite/ld-arm/farcall-arm-thumb.s20
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d16
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-arm-blx.d14
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d5
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-arm.d19
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-arm.s19
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d16
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-thumb-blx.d14
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-thumb-m-pic-veneer.d5
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-thumb-m.d19
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d5
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-thumb.d5
-rw-r--r--ld/testsuite/ld-arm/farcall-thumb-thumb.s19
-rw-r--r--ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d18
-rw-r--r--ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.s4
-rw-r--r--ld/testsuite/ld-arm/thumb2-bl-bad.d18
-rw-r--r--ld/testsuite/ld-arm/thumb2-bl-bad.s4
27 files changed, 415 insertions, 24 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 5383fbd..ee4105b 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,21 @@
+2008-05-15 Christophe Lyon <christophe.lyon@st.com>
+
+ * ld-arm/arm-elf.exp (armelftests): Add farcall-arm-arm,
+ farcall-arm-arm-pic-veneer, farcall-arm-arm-be8 farcall-arm-thumb,
+ farcall-arm-thumb-blx, farcall-arm-thumb-pic-veneer,
+ farcall-arm-thumb-blx-pic-veneer, farcall-thumb-thumb,
+ farcall-thumb-thumb-pic-veneer, farcall-thumb-thumb-blx,
+ farcall-thumb-thumb-m, farcall-thumb-thumb-m-pic-veneer,
+ farcall-thumb-thumb-blx-pic-veneer, farcall-thumb-arm,
+ farcall-thumb-arm-pic-veneer, farcall-thumb-arm-blx,
+ farcall-thumb-arm-blx-pic-veneer.
+ Change thumb2-bl-as-thumb1-bad, thumb2-bl-bad.
+ * ld-arm/thumb2-bl-as-thumb1-bad.d: Reflects farcall stub
+ generation.
+ * ld-arm/thumb2-bl-bad.d: Likewise.
+ * ld-arm/thumb2-bl-as-thumb1-bad.s: Update comments.
+ * ld-arm/thumb2-bl-bad.s: Likewise.
+
2008-05-08 Alan Modra <amodra@bigpond.net.au>
* ld-spu/ear.s: Align various sections.
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index 7447b7c..0dd64bc 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -1,5 +1,5 @@
# Expect script for various ARM ELF tests.
-# Copyright 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
@@ -177,15 +177,65 @@ set armelftests {
{"callweak" "-static -T arm.ld" "" {callweak.s}
{{objdump -dr callweak.d}}
"callweak"}
- {"ARMv4 interworking" "-static -T arm.ld --fix-v4bx-interworking" "--fix-v4bx -meabi=4" {armv4-bx.s}
- {{objdump -d armv4-bx.d}}
- "armv4-bx"}
- {"MOVW/MOVT and merged sections" "-T arm.ld" "" {movw-merge.s}
- {{objdump -dw movw-merge.d}}
- "movw-merge"}
- {"MOVW/MOVT against shared libraries" "tmpdir/arm-lib.so" "" {arm-app-movw.s}
- {{objdump -Rw arm-app.r}}
- "arm-app-movw"}
+
+ {"ARMv4 interworking" "-static -T arm.ld --fix-v4bx-interworking" "--fix-v4bx -meabi=4" {armv4-bx.s}
+ {{objdump -d armv4-bx.d}}
+ "armv4-bx"}
+ {"MOVW/MOVT and merged sections" "-T arm.ld" "" {movw-merge.s}
+ {{objdump -dw movw-merge.d}}
+ "movw-merge"}
+ {"MOVW/MOVT against shared libraries" "tmpdir/arm-lib.so" "" {arm-app-movw.s}
+ {{objdump -Rw arm-app.r}}
+ "arm-app-movw"}
+ {"Thumb-2-as-Thumb-1 BL" "-Ttext 0x1000 --section-start .foo=0x40100c" "" {thumb2-bl-as-thumb1-bad.s}
+ {{objdump -d thumb2-bl-as-thumb1-bad.d}}
+ "thumb2-bl-as-thumb1-bad"}
+ {"Thumb-2 BL" "-Ttext 0x1000 --section-start .foo=0x100100c" "" {thumb2-bl-bad.s}
+ {{objdump -d thumb2-bl-bad.d}}
+ "thumb2-bl-bad"}
+
+ {"ARM-ARM farcall" "-Ttext 0x1000 --section-start .foo=0x2001020" "" {farcall-arm-arm.s}
+ {{objdump -d farcall-arm-arm.d}}
+ "farcall-arm-arm"}
+ {"ARM-ARM farcall (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001020 --pic-veneer" "" {farcall-arm-arm.s}
+ {{objdump -d farcall-arm-arm-pic-veneer.d}}
+ "farcall-arm-arm-pic-veneer"}
+ {"ARM-ARM farcall (BE8)" "-Ttext 0x1000 --section-start .foo=0x2001020 -EB --be8" "-EB" {farcall-arm-arm.s}
+ {{objdump -d farcall-arm-arm-be8.d}}
+ "farcall-arm-arm-be8"}
+
+ {"ARM-Thumb farcall" "-Ttext 0x1000 --section-start .foo=0x2001014" "" {farcall-arm-thumb.s}
+ {{objdump -d farcall-arm-thumb.d}}
+ "farcall-arm-thumb"}
+ {"ARM-Thumb farcall with BLX" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv5t" {farcall-arm-thumb.s}
+ {{objdump -d farcall-arm-thumb-blx.d}}
+ "farcall-arm-thumb-blx"}
+ {"ARM-Thumb farcall (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "" {farcall-arm-thumb.s}
+ {{objdump -d farcall-arm-thumb-pic-veneer.d}}
+ "farcall-arm-thumb-pic-veneer"}
+ {"ARM-Thumb farcall with BLX (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "-march=armv5t" {farcall-arm-thumb.s}
+ {{objdump -d farcall-arm-thumb-blx-pic-veneer.d}}
+ "farcall-arm-thumb-blx-pic-veneer"}
+
+ {"Thumb-Thumb farcall with BLX" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv5t" {farcall-thumb-thumb.s}
+ {{objdump -d farcall-thumb-thumb-blx.d}}
+ "farcall-thumb-thumb-blx"}
+ {"Thumb-Thumb farcall M profile" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv7m" {farcall-thumb-thumb.s}
+ {{objdump -d farcall-thumb-thumb-m.d}}
+ "farcall-thumb-thumb-m"}
+ {"Thumb-Thumb farcall with BLX (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "-march=armv5t" {farcall-thumb-thumb.s}
+ {{objdump -d farcall-thumb-thumb-blx-pic-veneer.d}}
+ "farcall-thumb-thumb-blx-pic-veneer"}
+
+ {"Thumb-ARM farcall" "-Ttext 0x1000 --section-start .foo=0x2001014" "" {farcall-thumb-arm.s}
+ {{objdump -d farcall-thumb-arm.d}}
+ "farcall-thumb-arm"}
+ {"Thumb-ARM farcall with BLX" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv5t" {farcall-thumb-arm.s}
+ {{objdump -d farcall-thumb-arm-blx.d}}
+ "farcall-thumb-arm-blx"}
+ {"Thumb-ARM farcall with BLX (PIC veneer)" "-Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer" "-march=armv5t" {farcall-thumb-arm.s}
+ {{objdump -d farcall-thumb-arm-blx-pic-veneer.d}}
+ "farcall-thumb-arm-blx-pic-veneer"}
}
run_ld_link_tests $armelftests
@@ -193,9 +243,11 @@ run_dump_test "group-relocs-alu-bad"
run_dump_test "group-relocs-ldr-bad"
run_dump_test "group-relocs-ldrs-bad"
run_dump_test "group-relocs-ldc-bad"
-run_dump_test "thumb2-bl-as-thumb1-bad"
-run_dump_test "thumb2-bl-bad"
run_dump_test "emit-relocs1"
+run_dump_test "farcall-thumb-thumb"
+run_dump_test "farcall-thumb-thumb-pic-veneer"
+run_dump_test "farcall-thumb-thumb-m-pic-veneer"
+run_dump_test "farcall-thumb-arm-pic-veneer"
# Exclude non-ARM-EABI targets.
diff --git a/ld/testsuite/ld-arm/farcall-arm-arm-be8.d b/ld/testsuite/ld-arm/farcall-arm-arm-be8.d
new file mode 100644
index 0000000..b409517
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-arm-arm-be8.d
@@ -0,0 +1,14 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x8>:
+ 1000: 04f01fe5 .*
+ 1004: 02001020 .word 0x02001020
+
+00001008 <_start>:
+ 1008: fcffffeb .*
+Disassembly of section .foo:
+
+02001020 <bar>:
+ 2001020: 1eff2fe1 .*
diff --git a/ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d b/ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d
new file mode 100644
index 0000000..1d0af22
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-arm-arm-pic-veneer.d
@@ -0,0 +1,16 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x10>:
+ 1000: e59fc000 ldr ip, \[pc, #0\] ; 1008 <_start-0x8>
+ 1004: e08ff00c add pc, pc, ip
+ 1008: 02000018 .word 0x02000018
+ 100c: 00000000 .word 0x00000000
+
+00001010 <_start>:
+ 1010: ebfffffa bl 1000 <_start-0x10>
+Disassembly of section .foo:
+
+02001020 <bar>:
+ 2001020: e12fff1e bx lr
diff --git a/ld/testsuite/ld-arm/farcall-arm-arm.d b/ld/testsuite/ld-arm/farcall-arm-arm.d
new file mode 100644
index 0000000..3ccb2c4
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-arm-arm.d
@@ -0,0 +1,14 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x8>:
+ 1000: e51ff004 ldr pc, \[pc, #-4\] ; 1004 <_start-0x4>
+ 1004: 02001020 .word 0x02001020
+
+00001008 <_start>:
+ 1008: ebfffffc bl 1000 <_start-0x8>
+Disassembly of section .foo:
+
+02001020 <bar>:
+ 2001020: e12fff1e bx lr
diff --git a/ld/testsuite/ld-arm/farcall-arm-arm.s b/ld/testsuite/ld-arm/farcall-arm-arm.s
new file mode 100644
index 0000000..bc77ad3
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-arm-arm.s
@@ -0,0 +1,19 @@
+@ Test to ensure that a ARM to ARM call exceeding 32Mb generates a stub.
+
+ .global _start
+ .syntax unified
+
+@ We will place the section .text at 0x1000.
+
+ .text
+
+_start:
+ bl bar
+
+@ We will place the section .foo at 0x2001020.
+
+ .section .foo, "xa"
+
+bar:
+ bx lr
+
diff --git a/ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d b/ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d
new file mode 100644
index 0000000..3ede5de
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-arm-thumb-blx-pic-veneer.d
@@ -0,0 +1,16 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x10>:
+ 1000: e59fc000 ldr ip, \[pc, #0\] ; 1008 <_start-0x8>
+ 1004: e08ff00c add pc, pc, ip
+ 1008: 0200000d .word 0x0200000d
+ 100c: 00000000 .word 0x00000000
+
+00001010 <_start>:
+ 1010: ebfffffa bl 1000 <_start-0x10>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-arm-thumb-blx.d b/ld/testsuite/ld-arm/farcall-arm-thumb-blx.d
new file mode 100644
index 0000000..86aaf39
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-arm-thumb-blx.d
@@ -0,0 +1,14 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x8>:
+ 1000: e51ff004 ldr pc, \[pc, #-4\] ; 1004 <_start-0x4>
+ 1004: 02001015 .word 0x02001015
+
+00001008 <_start>:
+ 1008: ebfffffc bl 1000 <_start-0x8>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d b/ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d
new file mode 100644
index 0000000..3ede5de
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-arm-thumb-pic-veneer.d
@@ -0,0 +1,16 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x10>:
+ 1000: e59fc000 ldr ip, \[pc, #0\] ; 1008 <_start-0x8>
+ 1004: e08ff00c add pc, pc, ip
+ 1008: 0200000d .word 0x0200000d
+ 100c: 00000000 .word 0x00000000
+
+00001010 <_start>:
+ 1010: ebfffffa bl 1000 <_start-0x10>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-arm-thumb.d b/ld/testsuite/ld-arm/farcall-arm-thumb.d
new file mode 100644
index 0000000..c664eff
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-arm-thumb.d
@@ -0,0 +1,16 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x10>:
+ 1000: e59fc000 ldr ip, \[pc, #0\] ; 1008 <_start-0x8>
+ 1004: e12fff1c bx ip
+ 1008: 02001015 .word 0x02001015
+ 100c: 00000000 .word 0x00000000
+
+00001010 <_start>:
+ 1010: ebfffffa bl 1000 <_start-0x10>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-arm-thumb.s b/ld/testsuite/ld-arm/farcall-arm-thumb.s
new file mode 100644
index 0000000..c69f31c
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-arm-thumb.s
@@ -0,0 +1,20 @@
+@ Test to ensure that a ARM to Thumb call exceeding 32Mb generates a stub.
+
+ .global _start
+ .global bar
+ .syntax unified
+
+@ We will place the section .text at 0x1000.
+
+ .text
+
+_start:
+ bl bar
+
+@ We will place the section .foo at 0x2001010.
+
+ .section .foo, "xa"
+ .thumb_func
+bar:
+ bx lr
+
diff --git a/ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d b/ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d
new file mode 100644
index 0000000..3e0cb39
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-arm-blx-pic-veneer.d
@@ -0,0 +1,16 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x10>:
+ 1000: e59fc000 ldr ip, \[pc, #0\] ; 1008 <_start-0x8>
+ 1004: e08ff00c add pc, pc, ip
+ 1008: 0200000c .word 0x0200000c
+ 100c: 00000000 .word 0x00000000
+
+00001010 <_start>:
+ 1010: f7ff eff6 blx 1000 <_start-0x10>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-thumb-arm-blx.d b/ld/testsuite/ld-arm/farcall-thumb-arm-blx.d
new file mode 100644
index 0000000..c4bdd3b
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-arm-blx.d
@@ -0,0 +1,14 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x8>:
+ 1000: e51ff004 ldr pc, \[pc, #-4\] ; 1004 <_start-0x4>
+ 1004: 02001014 .word 0x02001014
+
+00001008 <_start>:
+ 1008: f7ff effa blx 1000 <_start-0x8>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d b/ld/testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d
new file mode 100644
index 0000000..932f28a
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d
@@ -0,0 +1,5 @@
+#name: Thumb-Thumb farcall without BLX
+#source: farcall-thumb-thumb.s
+#as: -march=armv4t
+#ld: -Ttext 0x1000 --section-start .foo=0x2001014
+#error: .*\(.text\+0x0\): relocation truncated to fit: R_ARM_THM_CALL against `bar'
diff --git a/ld/testsuite/ld-arm/farcall-thumb-arm.d b/ld/testsuite/ld-arm/farcall-thumb-arm.d
new file mode 100644
index 0000000..90495b8
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-arm.d
@@ -0,0 +1,19 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x18>:
+ 1000: b540 push {r6, lr}
+ 1002: 4e03 ldr r6, \[pc, #12\] \(1010 <_start-0x8>\)
+ 1004: 46fe mov lr, pc
+ 1006: 4730 bx r6
+ 1008: e8bd4040 pop {r6, lr}
+ 100c: e12fff1e bx lr
+ ...
+
+00001018 <_start>:
+ 1018: f7ff eff2 blx 1000 <_start-0x18>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-thumb-arm.s b/ld/testsuite/ld-arm/farcall-thumb-arm.s
new file mode 100644
index 0000000..82cfb95
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-arm.s
@@ -0,0 +1,19 @@
+@ Test to ensure that a Thumb to ARM call exceeding 4Mb generates a stub.
+
+ .global _start
+ .syntax unified
+
+@ We will place the section .text at 0x1000.
+
+ .text
+ .thumb_func
+_start:
+ bl bar
+
+@ We will place the section .foo at 0x2001014.
+
+ .section .foo, "xa"
+
+bar:
+ bx lr
+
diff --git a/ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d b/ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d
new file mode 100644
index 0000000..cadb620
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-thumb-blx-pic-veneer.d
@@ -0,0 +1,16 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x10>:
+ 1000: e59fc000 ldr ip, \[pc, #0\] ; 1008 <_start-0x8>
+ 1004: e08ff00c add pc, pc, ip
+ 1008: 0200000d .word 0x0200000d
+ 100c: 00000000 .word 0x00000000
+
+00001010 <_start>:
+ 1010: f7ff eff6 blx 1000 <_start-0x10>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-thumb-thumb-blx.d b/ld/testsuite/ld-arm/farcall-thumb-thumb-blx.d
new file mode 100644
index 0000000..11280c9
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-thumb-blx.d
@@ -0,0 +1,14 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x8>:
+ 1000: e51ff004 ldr pc, \[pc, #-4\] ; 1004 <_start-0x4>
+ 1004: 02001015 .word 0x02001015
+
+00001008 <_start>:
+ 1008: f7ff effa blx 1000 <_start-0x8>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-thumb-thumb-m-pic-veneer.d b/ld/testsuite/ld-arm/farcall-thumb-thumb-m-pic-veneer.d
new file mode 100644
index 0000000..932f28a
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-thumb-m-pic-veneer.d
@@ -0,0 +1,5 @@
+#name: Thumb-Thumb farcall without BLX
+#source: farcall-thumb-thumb.s
+#as: -march=armv4t
+#ld: -Ttext 0x1000 --section-start .foo=0x2001014
+#error: .*\(.text\+0x0\): relocation truncated to fit: R_ARM_THM_CALL against `bar'
diff --git a/ld/testsuite/ld-arm/farcall-thumb-thumb-m.d b/ld/testsuite/ld-arm/farcall-thumb-thumb-m.d
new file mode 100644
index 0000000..691d4e0
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-thumb-m.d
@@ -0,0 +1,19 @@
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x10>:
+ 1000: b540 push {r6, lr}
+ 1002: 4e02 ldr r6, \[pc, #8\] \(100c <_start-0x4>\)
+ 1004: 46fe mov lr, pc
+ 1006: e7fe b.n 1006 <_start-0xa>
+ 1008: bd40 pop {r6, pc}
+ 100a: bf00 nop
+ 100c: 02001015 .word 0x02001015
+
+00001010 <_start>:
+ 1010: f7ff eff6 blx 1000 <_start-0x10>
+Disassembly of section .foo:
+
+02001014 <bar>:
+ 2001014: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d b/ld/testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d
new file mode 100644
index 0000000..932f28a
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d
@@ -0,0 +1,5 @@
+#name: Thumb-Thumb farcall without BLX
+#source: farcall-thumb-thumb.s
+#as: -march=armv4t
+#ld: -Ttext 0x1000 --section-start .foo=0x2001014
+#error: .*\(.text\+0x0\): relocation truncated to fit: R_ARM_THM_CALL against `bar'
diff --git a/ld/testsuite/ld-arm/farcall-thumb-thumb.d b/ld/testsuite/ld-arm/farcall-thumb-thumb.d
new file mode 100644
index 0000000..932f28a
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-thumb.d
@@ -0,0 +1,5 @@
+#name: Thumb-Thumb farcall without BLX
+#source: farcall-thumb-thumb.s
+#as: -march=armv4t
+#ld: -Ttext 0x1000 --section-start .foo=0x2001014
+#error: .*\(.text\+0x0\): relocation truncated to fit: R_ARM_THM_CALL against `bar'
diff --git a/ld/testsuite/ld-arm/farcall-thumb-thumb.s b/ld/testsuite/ld-arm/farcall-thumb-thumb.s
new file mode 100644
index 0000000..650b1a6
--- /dev/null
+++ b/ld/testsuite/ld-arm/farcall-thumb-thumb.s
@@ -0,0 +1,19 @@
+@ Test to ensure that a Thumb to Thumb call exceeding 4Mb generates a stub.
+
+ .global _start
+ .syntax unified
+
+@ We will place the section .text at 0x1000.
+
+ .text
+ .thumb_func
+_start:
+ bl bar
+
+@ We will place the section .foo at 0x02001014.
+
+ .section .foo, "xa"
+ .thumb_func
+bar:
+ bx lr
+
diff --git a/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d b/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d
index 749b58f..1dfca21 100644
--- a/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d
+++ b/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d
@@ -1,4 +1,14 @@
-#name: Thumb-2-as-Thumb-1 BL failure test
-#source: thumb2-bl-as-thumb1-bad.s
-#ld: -Ttext 0x1000 --section-start .foo=0x401004
-#error: .*\(.text\+0x0\): relocation truncated to fit: R_ARM_THM_CALL against `bar'
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x8>:
+ 1000: e51ff004 ldr pc, \[pc, #-4\] ; 1004 <_start-0x4>
+ 1004: 0040100d .word 0x0040100d
+
+00001008 <_start>:
+ 1008: f7ff effa blx 1000 <_start-0x8>
+Disassembly of section .foo:
+
+0040100c <bar>:
+ 40100c: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.s b/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.s
index dae5d43..13f7f33 100644
--- a/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.s
+++ b/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.s
@@ -1,4 +1,4 @@
-@ Test to ensure that a Thumb-1 BL with a Thumb-2-only offset fails.
+@ Test to ensure that a Thumb-1 BL with a Thumb-2-only offset makes the linker generate a stub.
.arch armv5t
.global _start
@@ -12,7 +12,7 @@
_start:
bl bar
-@ We will place the section .foo at 0x401004.
+@ We will place the section .foo at 0x40100c.
.section .foo, "xa"
.thumb_func
diff --git a/ld/testsuite/ld-arm/thumb2-bl-bad.d b/ld/testsuite/ld-arm/thumb2-bl-bad.d
index 0fc6e04..ea38797 100644
--- a/ld/testsuite/ld-arm/thumb2-bl-bad.d
+++ b/ld/testsuite/ld-arm/thumb2-bl-bad.d
@@ -1,4 +1,14 @@
-#name: Thumb-2 BL failure test
-#source: thumb2-bl-bad.s
-#ld: -Ttext 0x1000 --section-start .foo=0x1001004
-#error: .*\(.text\+0x0\): relocation truncated to fit: R_ARM_THM_CALL against `bar'
+.*: file format .*
+
+Disassembly of section .text:
+
+00001000 <_start-0x8>:
+ 1000: e51ff004 ldr pc, \[pc, #-4\] ; 1004 <_start-0x4>
+ 1004: 0100100d .word 0x0100100d
+
+00001008 <_start>:
+ 1008: f7ff effa blx 1000 <_start-0x8>
+Disassembly of section .foo:
+
+0100100c <bar>:
+ 100100c: 4770 bx lr
diff --git a/ld/testsuite/ld-arm/thumb2-bl-bad.s b/ld/testsuite/ld-arm/thumb2-bl-bad.s
index 63e3fe7..7685860 100644
--- a/ld/testsuite/ld-arm/thumb2-bl-bad.s
+++ b/ld/testsuite/ld-arm/thumb2-bl-bad.s
@@ -1,4 +1,4 @@
-@ Test to ensure that a Thumb-2 BL with an oversize offset fails.
+@ Test to ensure that a Thumb-2 BL with an oversize offset makes the linker generate a stub.
.arch armv7
.global _start
@@ -12,7 +12,7 @@
_start:
bl bar
-@ We will place the section .foo at 0x1001004.
+@ We will place the section .foo at 0x100100c.
.section .foo, "xa"
.thumb_func