* som.c (som_fixup_formats): Improve handling of R_AUX_UNWIND,
[deliverable/binutils-gdb.git] / bfd / elf32-ppc.c
index b84b863952fa7ffcedf089b05f029eacc59de910..1de197b224c9727b5f4ad813665e26dcd3b17d0d 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 *,
@@ -1231,7 +1229,7 @@ error_return:
 \f
 static reloc_howto_type *
 ppc_elf_reloc_type_lookup (abfd, code)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      bfd_reloc_code_real_type code;
 {
   enum elf_ppc_reloc_type ppc_reloc = R_PPC_NONE;
@@ -1307,7 +1305,7 @@ ppc_elf_reloc_type_lookup (abfd, code)
 
 static void
 ppc_elf_info_to_howto (abfd, cache_ptr, dst)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      arelent *cache_ptr;
      Elf32_Internal_Rela *dst;
 {
@@ -1323,13 +1321,13 @@ ppc_elf_info_to_howto (abfd, cache_ptr, dst)
 static bfd_reloc_status_type
 ppc_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section,
                         output_bfd, error_message)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      arelent *reloc_entry;
      asymbol *symbol;
-     PTR data;
+     PTR data ATTRIBUTE_UNUSED;
      asection *input_section;
      bfd *output_bfd;
-     char **error_message;
+     char **error_message ATTRIBUTE_UNUSED;
 {
   bfd_vma relocation;
 
@@ -1523,7 +1521,7 @@ ppc_elf_section_from_shdr (abfd, hdr, name)
 
 static boolean
 ppc_elf_fake_sections (abfd, shdr, asect)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      Elf32_Internal_Shdr *shdr;
      asection *asect;
 {
@@ -1640,7 +1638,7 @@ ppc_elf_additional_program_headers (abfd)
 
 static boolean
 ppc_elf_modify_segment_map (abfd)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
 {
   return true;
 }
@@ -1880,27 +1878,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.  */
 
@@ -2083,43 +2060,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 = -1;
-             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;
 }
 
@@ -2523,7 +2463,7 @@ ppc_elf_check_relocs (abfd, info, sec, relocs)
 static asection *
 ppc_elf_gc_mark_hook (abfd, info, rel, h, sym)
      bfd *abfd;
-     struct bfd_link_info *info;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
      Elf_Internal_Rela *rel;
      struct elf_link_hash_entry *h;
      Elf_Internal_Sym *sym;
@@ -2570,7 +2510,7 @@ ppc_elf_gc_mark_hook (abfd, info, rel, h, sym)
 static boolean
 ppc_elf_gc_sweep_hook (abfd, info, sec, relocs)
      bfd *abfd;
-     struct bfd_link_info *info;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
      asection *sec;
      const Elf_Internal_Rela *relocs;
 {
@@ -2637,8 +2577,8 @@ ppc_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
      bfd *abfd;
      struct bfd_link_info *info;
      const Elf_Internal_Sym *sym;
-     const char **namep;
-     flagword *flagsp;
+     const char **namep ATTRIBUTE_UNUSED;
+     flagword *flagsp ATTRIBUTE_UNUSED;
      asection **secp;
      bfd_vma *valp;
 {
@@ -2924,54 +2864,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 != -1)
-           {
-             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;
 }
 
@@ -3146,7 +3038,12 @@ 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)
                      && (r_type == R_PPC_ADDR32
                          || r_type == R_PPC_ADDR24
                          || r_type == R_PPC_ADDR16
@@ -3189,6 +3086,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
@@ -3200,13 +3105,13 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
            relocation = 0;
          else
            {
-             (*info->callbacks->undefined_symbol)(info,
-                                                  h->root.root.string,
-                                                  input_bfd,
-                                                  input_section,
-                                                  rel->r_offset);
-             ret = false;
-             continue;
+             if (! (*info->callbacks->undefined_symbol)(info,
+                                                        h->root.root.string,
+                                                        input_bfd,
+                                                        input_section,
+                                                        rel->r_offset))
+               return false;
+             relocation = 0;
            }
        }
 
@@ -3230,12 +3135,12 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                  || h->root.type == bfd_link_hash_defweak)
              && sec->output_section == NULL)
            {
-             (*info->callbacks->undefined_symbol) (info,
-                                                   h->root.root.string,
-                                                   input_bfd,
-                                                   input_section,
-                                                   rel->r_offset);
-             ret = false;
+             if (! (*info->callbacks->undefined_symbol) (info,
+                                                         h->root.root.string,
+                                                         input_bfd,
+                                                         input_section,
+                                                         rel->r_offset))
+               return false;
              continue;
            }
          break;
@@ -3784,14 +3689,14 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                name = bfd_section_name (input_bfd, sec);
            }
 
-         (*info->callbacks->reloc_overflow)(info,
-                                            name,
-                                            howto->name,
-                                            (bfd_vma) 0,
-                                            input_bfd,
-                                            input_section,
-                                            offset);
-         ret = false;
+         if (! (*info->callbacks->reloc_overflow)(info,
+                                                  name,
+                                                  howto->name,
+                                                  (bfd_vma) 0,
+                                                  input_bfd,
+                                                  input_section,
+                                                  offset))
+           return false;
        }
       else
        ret = false;
This page took 0.032792 seconds and 4 git commands to generate.