]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd/
authorAlan Modra <amodra@gmail.com>
Tue, 6 Jul 2010 09:29:47 +0000 (09:29 +0000)
committerAlan Modra <amodra@gmail.com>
Tue, 6 Jul 2010 09:29:47 +0000 (09:29 +0000)
* elf32-ppc.c (ppc_elf_relax_section): Insert branch around
trampolines only for .init and .fini sections.
ld/testsuite/
* ld-powerpc/relax.s: Add branch back to _start.
* ld-powerpc/relax.d: Update.
* ld-powerpc/relaxr.d: Update.

bfd/ChangeLog
bfd/elf32-ppc.c
ld/testsuite/ChangeLog
ld/testsuite/ld-powerpc/relax.d
ld/testsuite/ld-powerpc/relax.s
ld/testsuite/ld-powerpc/relaxr.d

index 6c4dbf5028837ad368f1f9ca244a56218a458f68..ade05112eec18ad95fa7d30e3e047df747199ca0 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-06  Alan Modra  <amodra@gmail.com>
+
+       * elf32-ppc.c (ppc_elf_relax_section): Insert branch around
+       trampolines only for .init and .fini sections.
+
 2010-07-05  Alan Modra  <amodra@gmail.com>
 
        * elf32-ppc.c: Formatting.
index 60adae8a127e130459e99c6bab2a87f6ab419dca..e3638cd20c68dca4af259cab108758752f408dda 100644 (file)
@@ -5967,6 +5967,7 @@ ppc_elf_relax_section (bfd *abfd,
   struct ppc_elf_link_hash_table *htab;
   bfd_size_type trampoff;
   asection *got2;
+  bfd_boolean maybe_pasted;
 
   *again = FALSE;
 
@@ -5985,8 +5986,11 @@ ppc_elf_relax_section (bfd *abfd,
      return TRUE;
 
   trampoff = (isec->size + 3) & (bfd_vma) -4;
+  maybe_pasted = (strcmp (isec->output_section->name, ".init") == 0
+                 || strcmp (isec->output_section->name, ".fini") == 0);
   /* Space for a branch around any trampolines.  */
-  trampoff += 4;
+  if (maybe_pasted)
+    trampoff += 4;
 
   symtab_hdr = &elf_symtab_hdr (abfd);
 
@@ -6311,7 +6315,6 @@ ppc_elf_relax_section (bfd *abfd,
     {
       const int *stub;
       bfd_byte *dest;
-      bfd_vma val;
       int i, size;
 
       do
@@ -6327,12 +6330,15 @@ ppc_elf_relax_section (bfd *abfd,
        goto error_return;
 
       isec->size = (isec->size + 3) & (bfd_vma) -4;
-      /* Branch around the trampolines.  */
-      val = B + trampoff - isec->size;
       dest = contents + isec->size;
+      /* Branch around the trampolines.  */
+      if (maybe_pasted)
+       {
+         bfd_vma val = B + trampoff - isec->size;
+         bfd_put_32 (abfd, val, dest);
+         dest += 4;
+       }
       isec->size = trampoff;
-      bfd_put_32 (abfd, val, dest);
-      dest += 4;
 
       if (link_info->shared)
        {
index fdd6a501e85eb1695af7e3078ad6dfca08178a94..463a14c5fe2b885c81061a458dfe5f96fbc0e39a 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-06  Alan Modra  <amodra@gmail.com>
+
+       * ld-powerpc/relax.s: Add branch back to _start.
+       * ld-powerpc/relax.d: Update.
+       * ld-powerpc/relaxr.d: Update.
+
 2010-07-01  Alan Modra  <amodra@gmail.com>
 
        * lib/ld-lib.exp (default_ld_simple_link): Add $gcc_ld_flag before
index 51d253be33b3e45b67d900a4106dfe19f71aa0c2..5a6b3ddf5ffceb5c3736796179a349a7b9393538 100644 (file)
@@ -8,7 +8,7 @@ Disassembly of section .text:
    4:  48 00 00 11     bl      14 <_start\+0x14>
    8:  48 00 43 19     bl      4320 <near>
    c:  48 00 00 09     bl      14 <_start\+0x14>
-  10:  48 00 00 14     b       24 <.*>
+  10:  4b ff ff f0     b       0 <.*>
   14:  3d 80 80 00     lis     r12,-32768
   18:  39 8c 12 34     addi    r12,r12,4660
   1c:  7d 89 03 a6     mtctr   r12
index 2e055695244a3a136a3442616eb55d5d09efcd53..11afc533f17ac3ef7b942fc1fd684ed3e0fc743a 100644 (file)
@@ -4,3 +4,4 @@ _start:
        bl far
        bl near
        bl far
+       b _start
index ce8cb9c7bf80084c6857dad9f9ffa6a64b6879e5..6e559843e64e26a8b796202f2f32785542f2ab9b 100644 (file)
@@ -10,7 +10,8 @@ Disassembly of section .text:
                        8: R_PPC_NONE   \*ABS\*
    c:  48 00 00 19     bl      24 <_start\+0x24>
                        c: R_PPC_NONE   \*ABS\*
-  10:  48 00 00 24     b       34 <_start\+0x34>
+  10:  48 00 00 00     b       10 <_start\+0x10>
+                       10: R_PPC_REL24 _start
   14:  3d 80 00 00     lis     r12,0
                        16: R_PPC_ADDR16_HA     near
   18:  39 8c 00 00     addi    r12,r12,0