From 82b5c97a793698d0b27480bbfbf7f56f9dfe741a Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Wed, 15 Apr 2009 13:49:54 +0000 Subject: [PATCH] 2009-04-15 Christophe Lyon bfd/ * elf32-arm.c (elf32_arm_final_link_relocate): Don't convert ARM branch to an undef weak symbol into a jump to next instruction if a PLT entry will be created. testsuite/ * ld-arm/arm-elf.exp: Add 1 more test to check undef weak reference with PLT in ARM mode. * ld-arm/thumb2-bl-undefweak1.d, ld-arm/thumb2-bl-undefweak1.s: New files. --- bfd/ChangeLog | 6 ++++++ bfd/elf32-arm.c | 5 +++-- ld/testsuite/ChangeLog | 7 +++++++ ld/testsuite/ld-arm/arm-elf.exp | 1 + ld/testsuite/ld-arm/thumb2-bl-undefweak1.d | 9 +++++++++ ld/testsuite/ld-arm/thumb2-bl-undefweak1.s | 9 +++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 ld/testsuite/ld-arm/thumb2-bl-undefweak1.d create mode 100644 ld/testsuite/ld-arm/thumb2-bl-undefweak1.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bcd2179..6e4b535 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2009-04-15 Christophe Lyon + + * elf32-arm.c (elf32_arm_final_link_relocate): Don't convert ARM + branch to an undef weak symbol into a jump to next instruction if + a PLT entry will be created. + 2009-04-14 Dave Korn * coffgen.c (make_a_section_from_file): Set the backend long diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index a47d02c..99beb9e 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -6363,8 +6363,9 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, signed_addend >>= howto->rightshift; /* A branch to an undefined weak symbol is turned into a jump to - the next instruction. */ - if (h && h->root.type == bfd_link_hash_undefweak) + the next instruction unless a PLT entry will be created. */ + if (h && h->root.type == bfd_link_hash_undefweak + && !(splt != NULL && h->plt.offset != (bfd_vma) -1)) { value = (bfd_get_32 (input_bfd, hit_data) & 0xf0000000) | 0x0affffff; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index e92a871..7c79608 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2009-04-15 Christophe Lyon + + * ld-arm/arm-elf.exp: Add 1 more test to check undef weak + reference with PLT in ARM mode. + * ld-arm/thumb2-bl-undefweak1.d, ld-arm/thumb2-bl-undefweak1.s: + New files. + 2009-04-08 H.J. Lu * ld-i386/abs.d: Add --32 for assembler and -melf_i386 for diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 3625ddb..94002a1 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -185,6 +185,7 @@ 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-undefweak" +run_dump_test "thumb2-bl-undefweak1" run_dump_test "emit-relocs1" # Exclude non-ARM-EABI targets. diff --git a/ld/testsuite/ld-arm/thumb2-bl-undefweak1.d b/ld/testsuite/ld-arm/thumb2-bl-undefweak1.d new file mode 100644 index 0000000..929d180 --- /dev/null +++ b/ld/testsuite/ld-arm/thumb2-bl-undefweak1.d @@ -0,0 +1,9 @@ +#source: thumb2-bl-undefweak1.s +#as: +#ld: -shared +#objdump: -dr +#... +Disassembly of section .text: + +.* : + .*: ........ bl ... diff --git a/ld/testsuite/ld-arm/thumb2-bl-undefweak1.s b/ld/testsuite/ld-arm/thumb2-bl-undefweak1.s new file mode 100644 index 0000000..a302811 --- /dev/null +++ b/ld/testsuite/ld-arm/thumb2-bl-undefweak1.s @@ -0,0 +1,9 @@ +@ Test that calls to undefined weak functions resolve to call through +@ the PLT in shared libraries in ARM mode. + + .arch armv6 + .syntax unified + .text +foo: + bl bar + .weak bar -- 2.7.4