This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / bfd / elf32-ppc.c
index e8d512c4eb19b4c01c9aa6c244dbe4c1a86cbe9d..6dc3effc3f14e4a47e5711b6e31e1f476432b522 100644 (file)
@@ -80,8 +80,6 @@ static boolean ppc_elf_gc_sweep_hook PARAMS ((bfd *abfd,
 static boolean ppc_elf_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *,
                                                      struct elf_link_hash_entry *));
 
-static boolean ppc_elf_adjust_dynindx PARAMS ((struct elf_link_hash_entry *, PTR));
-
 static boolean ppc_elf_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
 
 static boolean ppc_elf_relocate_section PARAMS ((bfd *,
@@ -1401,21 +1399,8 @@ ppc_elf_merge_private_bfd_data (ibfd, obfd)
   boolean error;
 
   /* Check if we have the same endianess */
-  if (ibfd->xvec->byteorder != obfd->xvec->byteorder
-      && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
-    {
-      const char *msg;
-
-      if (bfd_big_endian (ibfd))
-       msg = _("%s: compiled for a big endian system and target is little endian");
-      else
-       msg = _("%s: compiled for a little endian system and target is big endian");
-
-      (*_bfd_error_handler) (msg, bfd_get_filename (ibfd));
-
-      bfd_set_error (bfd_error_wrong_format);
-      return false;
-    }
+  if (_bfd_generic_verify_endian_match (ibfd, obfd) == false)
+    return false;
 
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
@@ -1880,27 +1865,6 @@ ppc_elf_adjust_dynamic_symbol (info, h)
   return true;
 }
 
-\f
-/* Increment the index of a dynamic symbol by a given amount.  Called
-   via elf_link_hash_traverse.  */
-
-static boolean
-ppc_elf_adjust_dynindx (h, cparg)
-     struct elf_link_hash_entry *h;
-     PTR cparg;
-{
-  int *cp = (int *) cparg;
-
-#ifdef DEBUG
-  fprintf (stderr, "ppc_elf_adjust_dynindx called, h->dynindx = %d, *cp = %d\n", h->dynindx, *cp);
-#endif
-
-  if (h->dynindx != -1)
-    h->dynindx += *cp;
-
-  return true;
-}
-
 \f
 /* Set the sizes of the dynamic sections.  */
 
@@ -2035,7 +1999,7 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
 
       if (strip)
        {
-         _bfd_strip_section_from_output (s);
+         _bfd_strip_section_from_output (info, s);
          continue;
        }
 
@@ -2083,43 +2047,6 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
        }
     }
 
-  /* If we are generating a shared library, we generate a section
-     symbol for each output section.  These are local symbols, which
-     means that they must come first in the dynamic symbol table.
-     That means we must increment the dynamic symbol index of every
-     other dynamic symbol.
-
-     FIXME: We assume that there will never be relocations to
-     locations in linker-created sections that do not have
-     externally-visible names. Instead, we should work out precisely
-     which sections relocations are targetted at.  */
-  if (info->shared)
-    {
-      int c;
-
-      for (c = 0, s = output_bfd->sections; s != NULL; s = s->next)
-       {
-         if ((s->flags & SEC_LINKER_CREATED) != 0
-             || (s->flags & SEC_ALLOC) == 0)
-           {
-             elf_section_data (s)->dynindx = 0;
-             continue;
-           }
-
-         /* These symbols will have no names, so we don't need to
-            fiddle with dynstr_index.  */
-
-         elf_section_data (s)->dynindx = c + 1;
-
-         c++;
-       }
-
-      elf_link_hash_traverse (elf_hash_table (info),
-                             ppc_elf_adjust_dynindx,
-                             (PTR) &c);
-      elf_hash_table (info)->dynsymcount += c;
-    }
-
   return true;
 }
 
@@ -2600,7 +2527,7 @@ ppc_elf_gc_sweep_hook (abfd, info, sec, relocs)
            if (h->got.refcount > 0)
              h->got.refcount--;
          }
-       else
+       else if (local_got_refcounts != NULL)
          {
            if (local_got_refcounts[r_symndx] > 0)
              local_got_refcounts[r_symndx]--;
@@ -2924,54 +2851,6 @@ ppc_elf_finish_dynamic_sections (output_bfd, info)
       elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
     }
 
-  if (info->shared)
-    {
-      asection *sdynsym;
-      asection *s;
-      Elf_Internal_Sym sym;
-      int maxdindx = 0;
-
-      /* Set up the section symbols for the output sections.  */
-
-      sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
-      BFD_ASSERT (sdynsym != NULL);
-
-      sym.st_size = 0;
-      sym.st_name = 0;
-      sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
-      sym.st_other = 0;
-
-      for (s = output_bfd->sections; s != NULL; s = s->next)
-       {
-         int indx, dindx;
-
-         sym.st_value = s->vma;
-
-         indx = elf_section_data (s)->this_idx;
-         dindx = elf_section_data (s)->dynindx;
-         if (dindx > 0)
-           {
-             BFD_ASSERT(indx > 0);
-             BFD_ASSERT(dindx > 0);
-
-             if (dindx > maxdindx)
-               maxdindx = dindx;
-
-             sym.st_shndx = indx;
-
-             bfd_elf32_swap_symbol_out (output_bfd, &sym,
-                                        (PTR) (((Elf32_External_Sym *)
-                                                sdynsym->contents)
-                                               + dindx));
-           }
-       }
-
-      /* Set the sh_info field of the output .dynsym section to the
-         index of the first global symbol.  */
-      elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
-       maxdindx + 1;
-    }
-
   return true;
 }
 
@@ -3130,6 +3009,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
            {
              sec = h->root.u.def.section;
              if ((r_type == R_PPC_PLT32
+                  && splt != NULL
                   && h->plt.offset != (bfd_vma) -1)
                  || (r_type == R_PPC_LOCAL24PC
                      && sec->output_section == NULL)
@@ -3146,7 +3026,14 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                      && ((! info->symbolic && h->dynindx != -1)
                          || (h->elf_link_hash_flags
                              & ELF_LINK_HASH_DEF_REGULAR) == 0)
-                     && (input_section->flags & SEC_ALLOC) != 0
+                     && ((input_section->flags & SEC_ALLOC) != 0
+                         /* Testing SEC_DEBUGGING here may be wrong.
+                             It's here to avoid a crash when
+                             generating a shared library with DWARF
+                             debugging information.  */
+                         || ((input_section->flags & SEC_DEBUGGING) != 0
+                             && (h->elf_link_hash_flags
+                                 & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
                      && (r_type == R_PPC_ADDR32
                          || r_type == R_PPC_ADDR24
                          || r_type == R_PPC_ADDR16
@@ -3189,6 +3076,14 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                      obscure cases sec->output_section will be NULL.  */
                  relocation = 0;
                }
+             else if (sec->output_section == NULL)
+               {
+                  (*_bfd_error_handler)
+                    (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
+                     bfd_get_filename (input_bfd), h->root.root.string,
+                     bfd_get_section_name (input_bfd, input_section));
+                 relocation = 0;
+               }
              else
                relocation = (h->root.u.def.value
                              + sec->output_section->vma
@@ -3196,7 +3091,9 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
            }
          else if (h->root.type == bfd_link_hash_undefweak)
            relocation = 0;
-         else if (info->shared && !info->symbolic && !info->no_undefined)
+         else if (info->shared && !info->symbolic
+                  && !info->no_undefined
+                  && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
            relocation = 0;
          else
            {
@@ -3204,7 +3101,10 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                                                         h->root.root.string,
                                                         input_bfd,
                                                         input_section,
-                                                        rel->r_offset))
+                                                        rel->r_offset,
+                                                        (!info->shared
+                                                         || info->no_undefined
+                                                         || ELF_ST_VISIBILITY (h->other))))
                return false;
              relocation = 0;
            }
@@ -3234,7 +3134,8 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                                                          h->root.root.string,
                                                          input_bfd,
                                                          input_section,
-                                                         rel->r_offset))
+                                                         rel->r_offset,
+                                                         true))
                return false;
              continue;
            }
This page took 0.034051 seconds and 4 git commands to generate.