bfd:
authorJoseph Myers <joseph@codesourcery.com>
Tue, 25 Nov 2008 15:53:27 +0000 (15:53 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 25 Nov 2008 15:53:27 +0000 (15:53 +0000)
* elf32-arm.c (elf32_arm_final_link_relocate): Do not turn
branches to undefine weak symbols into branches to the next
instruction if creating PLT entries for those symbols.

ld/testsuite:
* ld-arm/thumb2-bl-undefweak.d, ld-arm/thumb2-bl-undefweak.s: New.
* ld-arm/arm-elf.exp: Run thumb2-bl-undefweak test.

bfd/ChangeLog
bfd/elf32-arm.c
ld/testsuite/ChangeLog
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/thumb2-bl-undefweak.d [new file with mode: 0644]
ld/testsuite/ld-arm/thumb2-bl-undefweak.s [new file with mode: 0644]

index 8f01ddf13a97fe41cce8b1c367c6818d360fbebf..ea1742338c070c3c16cbdfb7db76006913faecd0 100644 (file)
@@ -1,3 +1,9 @@
+2008-11-25  Joseph Myers  <joseph@codesourcery.com>
+
+       * elf32-arm.c (elf32_arm_final_link_relocate): Do not turn
+       branches to undefine weak symbols into branches to the next
+       instruction if creating PLT entries for those symbols.
+
 2008-11-25  Nick Clifton  <nickc@redhat.com>
 
        * elflink.c (is_reloc_section): New function.  Returns true if the
index 5b78dc3dfddb0c73d1f3ad65a8513dc73d6c9200..cd5a9bfc0712879ad8ae01c9da114ceccf5aee42 100644 (file)
@@ -6360,8 +6360,9 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
        int thumb2 = using_thumb2 (globals);
 
        /* 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))
          {
            bfd_put_16 (input_bfd, 0xe000, hit_data);
            bfd_put_16 (input_bfd, 0xbf00, hit_data + 2);
index f46a7e134a9f3c27630b9b2e2ef22422dd21e696..7157245a24654d1ce3521cf0337a978bb5395ffb 100644 (file)
@@ -1,3 +1,8 @@
+2008-11-25  Joseph Myers  <joseph@codesourcery.com>
+
+       * ld-arm/thumb2-bl-undefweak.d, ld-arm/thumb2-bl-undefweak.s: New.
+       * ld-arm/arm-elf.exp: Run thumb2-bl-undefweak test.
+
 2008-11-25  Hans-Peter Nilsson  <hp@axis.com>
 
        * ld-cris/got7.s, ld-cris/init.s, ld-cris/pic-gc-72.d,
index 6075e68d35717a0f5717d20a2bf93f5c8526a842..665dab19d4a52838c6d465d6f6f63d1ccda3d4b6 100644 (file)
@@ -184,6 +184,7 @@ 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-undefweak"
 run_dump_test "emit-relocs1"
 
 # Exclude non-ARM-EABI targets.
diff --git a/ld/testsuite/ld-arm/thumb2-bl-undefweak.d b/ld/testsuite/ld-arm/thumb2-bl-undefweak.d
new file mode 100644 (file)
index 0000000..d06f1ab
--- /dev/null
@@ -0,0 +1,9 @@
+#source: thumb2-bl-undefweak.s
+#as:
+#ld: -shared
+#objdump: -dr
+#...
+Disassembly of section .text:
+
+.* <foo>:
+ .*:   .... ....       blx     ... <foo-0x.*>
diff --git a/ld/testsuite/ld-arm/thumb2-bl-undefweak.s b/ld/testsuite/ld-arm/thumb2-bl-undefweak.s
new file mode 100644 (file)
index 0000000..5e70eea
--- /dev/null
@@ -0,0 +1,10 @@
+@ Test that calls to undefined weak functions resolve to call through
+@ the PLT in shared libraries.
+
+       .arch armv7
+       .syntax unified
+       .text
+       .thumb_func
+foo:
+       bl bar
+       .weak bar