PR ld/2218
authorAlan Modra <amodra@gmail.com>
Fri, 17 Feb 2006 04:49:34 +0000 (04:49 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 17 Feb 2006 04:49:34 +0000 (04:49 +0000)
* elf64-ppc.c (allocate_dynrelocs): Ensure undef weak sym is
dynamic.
(ppc64_elf_relocate_section): Check output reloc section size.
* elf32-ppc.c (allocate_dynrelocs): Simplify undef weak test.

bfd/ChangeLog
bfd/elf32-ppc.c
bfd/elf64-ppc.c

index a7449e5..3f4da9c 100644 (file)
@@ -1,3 +1,11 @@
+2006-02-17  Alan Modra  <amodra@bigpond.net.au>
+
+       PR ld/2218
+       * elf64-ppc.c (allocate_dynrelocs): Ensure undef weak sym is
+       dynamic.
+       (ppc64_elf_relocate_section): Check output reloc section size.
+       * elf32-ppc.c (allocate_dynrelocs): Simplify undef weak test.
+
 2006-02-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/2322
index e6de049..caa5ed4 100644 (file)
@@ -4546,20 +4546,19 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
       /* Also discard relocs on undefined weak syms with non-default
         visibility.  */
-      if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-         && h->root.type == bfd_link_hash_undefweak)
-       eh->dyn_relocs = NULL;
-
-      /* Make sure undefined weak symbols are output as a dynamic symbol
-        in PIEs.  */
-      if (info->pie
-         && eh->dyn_relocs != NULL
-         && h->dynindx == -1
-         && h->root.type == bfd_link_hash_undefweak
-         && !h->forced_local)
+      if (h->root.type == bfd_link_hash_undefweak)
        {
-         if (! bfd_elf_link_record_dynamic_symbol (info, h))
-           return FALSE;
+         if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+           eh->dyn_relocs = NULL;
+
+         /* Make sure undefined weak symbols are output as a dynamic
+            symbol in PIEs.  */
+         else if (h->dynindx == -1
+                  && !h->forced_local)
+           {
+             if (! bfd_elf_link_record_dynamic_symbol (info, h))
+               return FALSE;
+           }
        }
     }
   else if (ELIMINATE_COPY_RELOCS)
index 3a807eb..785c859 100644 (file)
@@ -7582,9 +7582,20 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
       /* Also discard relocs on undefined weak syms with non-default
         visibility.  */
-      if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-         && h->root.type == bfd_link_hash_undefweak)
-       eh->dyn_relocs = NULL;
+      if (h->root.type == bfd_link_hash_undefweak)
+       {
+         if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+           eh->dyn_relocs = NULL;
+
+         /* Make sure this symbol is output as a dynamic symbol.
+            Undefined weak syms won't yet be marked as dynamic.  */
+         else if (h->dynindx == -1
+                  && !h->forced_local)
+           {
+             if (! bfd_elf_link_record_dynamic_symbol (info, h))
+               return FALSE;
+           }
+       }
     }
   else if (ELIMINATE_COPY_RELOCS)
     {
@@ -10757,6 +10768,9 @@ ppc64_elf_relocate_section (bfd *output_bfd,
              if (sreloc == NULL)
                abort ();
 
+             if (sreloc->reloc_count * sizeof (Elf64_External_Rela)
+                 >= sreloc->size)
+               abort ();
              loc = sreloc->contents;
              loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
              bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);