From 39f21624991525f1f937a796cf008654a8596240 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 18 Jul 2013 12:00:26 +0000 Subject: [PATCH] * elf32-arm.c (arm_type_of_stub): Don't use ST_BRANCH_TO_ARM for thumb only targets. (elf32_arm_final_link_relocate): Likewise. * ld-arm/thumb-b-lks-sym.d: Updated to be more flexible. * ld-arm/thumb-bl-lks-sym.d: Likewise. --- bfd/ChangeLog | 6 ++++++ bfd/elf32-arm.c | 14 ++++++++++++++ ld/testsuite/ChangeLog | 5 +++++ ld/testsuite/ld-arm/thumb-b-lks-sym.d | 2 +- ld/testsuite/ld-arm/thumb-bl-lks-sym.d | 2 +- 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index df25bd4..ecd2842 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2013-07-18 Terry Guo + + * elf32-arm.c (arm_type_of_stub): Don't use ST_BRANCH_TO_ARM for + thumb only targets. + (elf32_arm_final_link_relocate): Likewise. + 2013-07-18 Bill Neubauer * mach-o.c (mach_o_section_name_xlat dw): Add entry for diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 427ac6d..8f88839 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -3609,6 +3609,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 @@ -8123,6 +8129,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/ChangeLog b/ld/testsuite/ChangeLog index 652474d..9eeb006 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-07-18 Terry Guo + + * ld-arm/thumb-b-lks-sym.d: Updated to be more flexible. + * ld-arm/thumb-bl-lks-sym.d: Likewise. + 2013-07-18 Roland McGrath * ld-arm/farcall-arm-nacl.d: New file. 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 -- 2.7.4