diff options
-rw-r--r-- | bfd/ChangeLog | 12 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 73 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 19 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/arm-elf.exp | 24 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/farcall-thumb-arm.d | 17 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/farcall-thumb-thumb-m-pic-veneer.d | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/farcall-thumb-thumb-m.d | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/farcall-thumb-thumb.d | 24 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad-noeabi.d | 23 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/thumb2-bl-bad-noeabi.d | 23 |
14 files changed, 175 insertions, 74 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 17a23d7..1c4717f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,15 @@ +2009-02-23 Christophe Lyon <christophe.lyon@st.com> + + * elf32-arm.c (elf32_arm_stub_long_branch_thumb_only): Fix stub + code. + (elf32_arm_stub_long_branch_v4t_thumb_arm): Likewise. + (arm_type_of_stub): Use Thumb-only long branch stub (non-PIC) when + BLX is not available. Fix typo in warning message. Add comments + and improve formatting. + (arm_build_one_stub): Adjust to new + elf32_arm_stub_long_branch_v4t_thumb_arm stub. + (arm_map_one_stub): Likewise. + 2009-02-23 Tristan Gingold <gingold@adacore.com> * vms.h: Update copyright year, fix comments, reorder declarations. diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 04f5405..6cf3322 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2032,11 +2032,11 @@ static const bfd_vma elf32_arm_stub_long_branch_v4t_arm_thumb[] = to ARM. */ static const bfd_vma elf32_arm_stub_long_branch_thumb_only[] = { - 0x4e02b540, /* push {r6, lr} */ - /* ldr r6, [pc, #8] */ - 0x473046fe, /* mov lr, pc */ - /* bx r6 */ - 0xbf00bd40, /* pop {r6, pc} */ + 0x4802b401, /* push {r0} */ + /* ldr r0, [pc, #8] */ + 0xbc014684, /* mov ip, r0 */ + /* pop {r0} */ + 0xbf004760, /* bx ip */ /* nop */ 0x00000000, /* dcd R_ARM_ABS32(X) */ }; @@ -2045,13 +2045,10 @@ static const bfd_vma elf32_arm_stub_long_branch_thumb_only[] = available. */ static const bfd_vma elf32_arm_stub_long_branch_v4t_thumb_arm[] = { - 0x4e03b540, /* push {r6, lr} */ - /* ldr r6, [pc, #12] */ - 0x473046fe, /* mov lr, pc */ - /* bx r6 */ - 0xe8bd4040, /* pop {r6, pc} */ - 0xe12fff1e, /* bx lr */ - 0x00000000, /* dcd R_ARM_ABS32(X) */ + 0x46c04778, /* bx pc */ + /* nop */ + 0xe51ff004, /* ldr pc, [pc, #-4] */ + 0x00000000, /* dcd R_ARM_ABS32(X) */ }; /* V4T Thumb -> ARM short branch stub. Shorter variant of the above @@ -2819,20 +2816,27 @@ arm_type_of_stub (struct bfd_link_info *info, if (!thumb_only) { stub_type = (info->shared | globals->pic_veneer) + /* PIC stubs. */ ? ((globals->use_blx) + /* V5T and above. */ ? arm_stub_long_branch_any_any_pic + /* not yet supported on V4T. */ : arm_stub_none) - : (globals->use_blx) - ? arm_stub_long_branch_any_any - : arm_stub_none; + + /* non-PIC stubs. */ + : ((globals->use_blx) + /* V5T and above. */ + ? arm_stub_long_branch_any_any + /* V4T. */ + : arm_stub_long_branch_thumb_only); } else { stub_type = (info->shared | globals->pic_veneer) + /* PIC stub not yet supported on V4T. */ ? arm_stub_none - : (globals->use_blx) - ? arm_stub_long_branch_thumb_only - : arm_stub_none; + /* non-PIC stub. */ + : arm_stub_long_branch_thumb_only; } } else @@ -2849,12 +2853,19 @@ arm_type_of_stub (struct bfd_link_info *info, } stub_type = (info->shared | globals->pic_veneer) + /* PIC stubs. */ ? ((globals->use_blx) + /* V5T and above. */ ? arm_stub_long_branch_any_any_pic + /* not yet supported on V4T. */ : arm_stub_none) - : (globals->use_blx) - ? arm_stub_long_branch_any_any - : arm_stub_long_branch_v4t_thumb_arm; + + /* non-PIC stubs. */ + : ((globals->use_blx) + /* V5T and above. */ + ? arm_stub_long_branch_any_any + /* V4T. */ + : arm_stub_long_branch_v4t_thumb_arm); /* Handle v4t short branches. */ if ((stub_type == arm_stub_long_branch_v4t_thumb_arm) @@ -2876,7 +2887,7 @@ arm_type_of_stub (struct bfd_link_info *info, { (*_bfd_error_handler) (_("%B(%s): warning: interworking not enabled.\n" - " first occurrence: %B: Thumb call to ARM"), + " first occurrence: %B: ARM call to Thumb"), sym_sec->owner, input_bfd, name); } @@ -2887,10 +2898,14 @@ arm_type_of_stub (struct bfd_link_info *info, || !globals->use_blx) { stub_type = (info->shared | globals->pic_veneer) + /* PIC stubs. */ ? arm_stub_long_branch_any_any_pic - : (globals->use_blx) - ? arm_stub_long_branch_any_any - : arm_stub_long_branch_v4t_arm_thumb; + /* non-PIC stubs. */ + : ((globals->use_blx) + /* V5T and above. */ + ? arm_stub_long_branch_any_any + /* V4T. */ + : arm_stub_long_branch_v4t_arm_thumb); } } else @@ -2900,7 +2915,9 @@ arm_type_of_stub (struct bfd_link_info *info, || (branch_offset < ARM_MAX_BWD_BRANCH_OFFSET)) { stub_type = (info->shared | globals->pic_veneer) + /* PIC stubs. */ ? arm_stub_long_branch_any_any_pic + /* non-PIC stubs. */ : arm_stub_long_branch_any_any; } } @@ -3188,7 +3205,7 @@ arm_build_one_stub (struct bfd_hash_entry *gen_entry, case arm_stub_long_branch_v4t_thumb_arm: _bfd_final_link_relocate (elf32_arm_howto_from_type (R_ARM_ABS32), stub_bfd, stub_sec, stub_sec->contents, - stub_entry->stub_offset + 16, sym_value, 0); + stub_entry->stub_offset + 8, sym_value, 0); break; case arm_stub_short_branch_v4t_thumb_arm: { @@ -11697,9 +11714,9 @@ arm_map_one_stub (struct bfd_hash_entry * gen_entry, return FALSE; if (!elf32_arm_output_map_sym (osi, ARM_MAP_THUMB, addr)) return FALSE; - if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr + 8)) + if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr + 4)) return FALSE; - if (!elf32_arm_output_map_sym (osi, ARM_MAP_DATA, addr + 16)) + if (!elf32_arm_output_map_sym (osi, ARM_MAP_DATA, addr + 8)) return FALSE; break; case arm_stub_short_branch_v4t_thumb_arm: diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 5d41613..a828653 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,22 @@ +2009-02-23 Christophe Lyon <christophe.lyon@st.com> + * ld-arm/arm-elf.exp: Rewrite non-EABI variants of + thumb2-bl-as-thumb1-bad and thumb2-bl-bad tests, which now + pass. farcall-thumb-thumb now passes in EABI mode. + * ld-arm/farcall-thumb-arm-pic-veneer.d: Fixed name, source, as + and ld flags to match intended test. + * ld-arm/farcall-thumb-arm.d: New expected result. + * ld-arm/farcall-thumb-thumb-m.d: Likewise. + * ld-arm/farcall-thumb-thumb-m-pic-veneer.d: Fixed name and ld + flags. + * ld-arm/farcall-thumb-thumb-pic-veneer.d: Likewise. + * ld-arm/farcall-thumb-thumb.d: New expected result, this test is + now expected to pass. + * ld-arm/thumb2-bl-as-thumb1-bad-noeabi.d: Likewise. + * ld-arm/thumb2-bl-bad-noeabi.d: Likewise. + * ld-arm/thumb2-bl-as-thumb1-bad.d: Update addresses according to + new use. + * ld-arm/thumb2-bl-as-thumb1-bad.s: Update comment. + 2009-18-02 Dave Korn <dave.korn.cygwin@gmail.com> * ld-pe/longsecn-1.d: New test file. diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 3ea17e9..f850f74 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -190,10 +190,20 @@ run_dump_test "emit-relocs1" # Exclude non-ARM-EABI targets. if { ![istarget "arm*-*-*eabi"] } { - # Special variants of these tests, as no farcall stub is generated - # for a non-ARM-EABI target - run_dump_test "thumb2-bl-as-thumb1-bad-noeabi" - run_dump_test "thumb2-bl-bad-noeabi" + # Special variants of these tests, as a different farcall stub is + # generated for a non-ARM-EABI target: indeed in such a case, + # there are no attributes to indicate that blx can be used. + + set arm_noeabi_tests { + {"Thumb-2-as-Thumb-1 BL" "-Ttext 0x1000 --section-start .foo=0x100100c" "" {thumb2-bl-as-thumb1-bad.s} + {{objdump -d thumb2-bl-as-thumb1-bad-noeabi.d}} + "thumb2-bl-as-thumb1-bad"} + {"Thumb-2 BL" "-Ttext 0x1000 --section-start .foo=0x100100c" "" {thumb2-bl-bad.s} + {{objdump -d thumb2-bl-bad-noeabi.d}} + "thumb2-bl-bad"} + } + run_ld_link_tests $arm_noeabi_tests + return } @@ -241,7 +251,7 @@ set armeabitests { {"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} + {"Thumb-2-as-Thumb-1 BL" "-Ttext 0x1000 --section-start .foo=0x100100c" "" {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} @@ -277,6 +287,9 @@ set armeabitests { {"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" "-Ttext 0x1000 --section-start .foo=0x2001014" "-march=armv4t" {farcall-thumb-thumb.s} + {{objdump -d farcall-thumb-thumb.d}} + "farcall-thumb-thumb"} {"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"} @@ -328,7 +341,6 @@ run_dump_test "attr-merge-wchar-24-nowarn" run_dump_test "attr-merge-wchar-40-nowarn" run_dump_test "attr-merge-wchar-42-nowarn" run_dump_test "attr-merge-wchar-44-nowarn" -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" diff --git a/ld/testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d b/ld/testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d index 932f28a..a2c09d2 100644 --- a/ld/testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d +++ b/ld/testsuite/ld-arm/farcall-thumb-arm-pic-veneer.d @@ -1,5 +1,5 @@ -#name: Thumb-Thumb farcall without BLX -#source: farcall-thumb-thumb.s -#as: -march=armv4t -#ld: -Ttext 0x1000 --section-start .foo=0x2001014 +#name: Thumb-ARM farcall without BLX (PIC veneer) +#source: farcall-thumb-arm.s +#as: -march=armv4t -W +#ld: -Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer #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 index 61e72be..dc02e25 100644 --- a/ld/testsuite/ld-arm/farcall-thumb-arm.d +++ b/ld/testsuite/ld-arm/farcall-thumb-arm.d @@ -3,17 +3,14 @@ Disassembly of section .text: 00001000 <__bar_from_thumb>: - 1000: b540 push {r6, lr} - 1002: 4e03 ldr r6, \[pc, #12\] \(1010 <__bar_from_thumb\+0x10>\) - 1004: 46fe mov lr, pc - 1006: 4730 bx r6 - 1008: e8bd4040 pop {r6, lr} - 100c: e12fff1e bx lr - 1010: 02001014 .word 0x02001014 - 1014: 00000000 .word 0x00000000 + 1000: 4778 bx pc + 1002: 46c0 nop \(mov r8, r8\) + 1004: e51ff004 ldr pc, \[pc, #-4\] ; 1008 <__bar_from_thumb\+0x8> + 1008: 02001014 .word 0x02001014 + 100c: 00000000 .word 0x00000000 -00001018 <_start>: - 1018: f7ff fff2 bl 1000 <__bar_from_thumb> +00001010 <_start>: + 1010: f7ff fff6 bl 1000 <__bar_from_thumb> Disassembly of section .foo: 02001014 <bar>: 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 index 932f28a..f8308ff 100644 --- a/ld/testsuite/ld-arm/farcall-thumb-thumb-m-pic-veneer.d +++ b/ld/testsuite/ld-arm/farcall-thumb-thumb-m-pic-veneer.d @@ -1,5 +1,5 @@ -#name: Thumb-Thumb farcall without BLX +#name: Thumb-Thumb farcall M profile (PIC veneer) #source: farcall-thumb-thumb.s #as: -march=armv4t -#ld: -Ttext 0x1000 --section-start .foo=0x2001014 +#ld: -Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer #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 index 2f7cdaf..c7a0db7 100644 --- a/ld/testsuite/ld-arm/farcall-thumb-thumb-m.d +++ b/ld/testsuite/ld-arm/farcall-thumb-thumb-m.d @@ -3,11 +3,11 @@ Disassembly of section .text: 00001000 <__bar_veneer>: - 1000: b540 push {r6, lr} - 1002: 4e02 ldr r6, \[pc, #8\] \(100c <__bar_veneer\+0xc>\) - 1004: 46fe mov lr, pc - 1006: 4730 bx r6 - 1008: bd40 pop {r6, pc} + 1000: b401 push {r0} + 1002: 4802 ldr r0, \[pc, #8\] \(100c <__bar_veneer\+0xc>\) + 1004: 4684 mov ip, r0 + 1006: bc01 pop {r0} + 1008: 4760 bx ip 100a: bf00 nop 100c: 02001015 .word 0x02001015 diff --git a/ld/testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d b/ld/testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d index 932f28a..f97671b 100644 --- a/ld/testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d +++ b/ld/testsuite/ld-arm/farcall-thumb-thumb-pic-veneer.d @@ -1,5 +1,5 @@ -#name: Thumb-Thumb farcall without BLX +#name: Thumb-Thumb farcall without BLX (PIC veneer) #source: farcall-thumb-thumb.s #as: -march=armv4t -#ld: -Ttext 0x1000 --section-start .foo=0x2001014 +#ld: -Ttext 0x1000 --section-start .foo=0x2001014 --pic-veneer #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 index 932f28a..c7a0db7 100644 --- a/ld/testsuite/ld-arm/farcall-thumb-thumb.d +++ b/ld/testsuite/ld-arm/farcall-thumb-thumb.d @@ -1,5 +1,19 @@ -#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' +.*: file format .* + +Disassembly of section .text: + +00001000 <__bar_veneer>: + 1000: b401 push {r0} + 1002: 4802 ldr r0, \[pc, #8\] \(100c <__bar_veneer\+0xc>\) + 1004: 4684 mov ip, r0 + 1006: bc01 pop {r0} + 1008: 4760 bx ip + 100a: bf00 nop + 100c: 02001015 .word 0x02001015 + +00001010 <_start>: + 1010: f7ff fff6 bl 1000 <__bar_veneer> +Disassembly of section .foo: + +02001014 <bar>: + 2001014: 4770 bx lr diff --git a/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad-noeabi.d b/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad-noeabi.d index 749b58f..fdf9d8a 100644 --- a/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad-noeabi.d +++ b/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad-noeabi.d @@ -1,4 +1,19 @@ -#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 <__bar_veneer>: + 1000: b401 push {r0} + 1002: 4802 ldr r0, \[pc, #8\] \(100c <__bar_veneer\+0xc>\) + 1004: 4684 mov ip, r0 + 1006: bc01 pop {r0} + 1008: 4760 bx ip + 100a: bf00 nop + 100c: 0100100d .word 0x0100100d + +00001010 <_start>: + 1010: f7ff fff6 bl 1000 <__bar_veneer> +Disassembly of section .foo: + +0100100c <bar>: + 100100c: 4770 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 28d1b29..12674f9 100644 --- a/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d +++ b/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.d @@ -4,11 +4,11 @@ Disassembly of section .text: 00001000 <__bar_veneer>: 1000: e51ff004 ldr pc, \[pc, #-4\] ; 1004 <__bar_veneer\+0x4> - 1004: 0040100d .word 0x0040100d + 1004: 0100100d .word 0x0100100d 00001008 <_start>: 1008: f7ff effa blx 1000 <__bar_veneer> Disassembly of section .foo: -0040100c <bar>: - 40100c: 4770 bx lr +0100100c <bar>: + 100100c: 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 13f7f33..834001c 100644 --- a/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.s +++ b/ld/testsuite/ld-arm/thumb2-bl-as-thumb1-bad.s @@ -12,7 +12,7 @@ _start: bl bar -@ We will place the section .foo at 0x40100c. +@ We will place the section .foo at 0x100100c. .section .foo, "xa" .thumb_func diff --git a/ld/testsuite/ld-arm/thumb2-bl-bad-noeabi.d b/ld/testsuite/ld-arm/thumb2-bl-bad-noeabi.d index 0fc6e04..fdf9d8a 100644 --- a/ld/testsuite/ld-arm/thumb2-bl-bad-noeabi.d +++ b/ld/testsuite/ld-arm/thumb2-bl-bad-noeabi.d @@ -1,4 +1,19 @@ -#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 <__bar_veneer>: + 1000: b401 push {r0} + 1002: 4802 ldr r0, \[pc, #8\] \(100c <__bar_veneer\+0xc>\) + 1004: 4684 mov ip, r0 + 1006: bc01 pop {r0} + 1008: 4760 bx ip + 100a: bf00 nop + 100c: 0100100d .word 0x0100100d + +00001010 <_start>: + 1010: f7ff fff6 bl 1000 <__bar_veneer> +Disassembly of section .foo: + +0100100c <bar>: + 100100c: 4770 bx lr |