diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index eef1b13..66b7ebd 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -3580,6 +3580,12 @@ arm_type_of_stub (struct bfd_link_info *info, r_type = ELF32_R_TYPE (rel->r_info); + /* ST_BRANCH_TO_ARM is nonsense to thumb-only targets when we + are considering a function call relocation. */ + if (thumb_only && (r_type == R_ARM_THM_CALL || r_type == R_ARM_THM_JUMP24) + && branch_type == ST_BRANCH_TO_ARM) + branch_type = ST_BRANCH_TO_THUMB; + /* For TLS call relocs, it is the caller's responsibility to provide the address of the appropriate trampoline. */ if (r_type != R_ARM_TLS_CALL @@ -8084,6 +8090,14 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, else addend = signed_addend = rel->r_addend; + /* ST_BRANCH_TO_ARM is nonsense to thumb-only targets when we + are resolving a function call relocation. */ + if (using_thumb_only (globals) + && (r_type == R_ARM_THM_CALL + || r_type == R_ARM_THM_JUMP24) + && branch_type == ST_BRANCH_TO_ARM) + branch_type = ST_BRANCH_TO_THUMB; + /* Record the symbol information that should be used in dynamic relocations. */ dynreloc_st_type = st_type; diff --git a/ld/testsuite/ld-arm/thumb-b-lks-sym.d b/ld/testsuite/ld-arm/thumb-b-lks-sym.d index eadd9a4..cc23bc3 100644 --- a/ld/testsuite/ld-arm/thumb-b-lks-sym.d +++ b/ld/testsuite/ld-arm/thumb-b-lks-sym.d @@ -4,4 +4,4 @@ Disassembly of section .text: 00000000
: - 0: f000 bffe b.w 1000 + 0: f000 bffe b.w 1000 <.*> diff --git a/ld/testsuite/ld-arm/thumb-bl-lks-sym.d b/ld/testsuite/ld-arm/thumb-bl-lks-sym.d index b553b51..1da6928 100644 --- a/ld/testsuite/ld-arm/thumb-bl-lks-sym.d +++ b/ld/testsuite/ld-arm/thumb-bl-lks-sym.d @@ -6,7 +6,7 @@ Disassembly of section .text: 00000000
: 0: b580 push {r7, lr} 2: af00 add r7, sp, #0 - 4: f000 fffc bl 1000 + 4: f000 fffc bl 1000 <.*> 8: bd80 pop {r7, pc} a: bf00 nop