2011-05-20 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / bfd / elf64-hppa.c
index 957e61a000c9efab8ee7673e0b5fd95f83854649..d8213a01a8ac80a2cc30fa5b7b78ed5f12f1e426 100644 (file)
@@ -371,8 +371,6 @@ elf64_hppa_section_from_shdr (bfd *abfd,
                              const char *name,
                              int shindex)
 {
-  asection *newsect;
-
   switch (hdr->sh_type)
     {
     case SHT_PARISC_EXT:
@@ -391,7 +389,6 @@ elf64_hppa_section_from_shdr (bfd *abfd,
 
   if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
-  newsect = hdr->bfd_section;
 
   return TRUE;
 }
@@ -410,17 +407,10 @@ get_reloc_section (bfd *abfd,
 
   srel_name = (bfd_elf_string_from_elf_section
               (abfd, elf_elfheader(abfd)->e_shstrndx,
-               elf_section_data(sec)->rel_hdr.sh_name));
+               _bfd_elf_single_rel_hdr(sec)->sh_name));
   if (srel_name == NULL)
     return FALSE;
 
-  BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela")
-              && strcmp (bfd_get_section_name (abfd, sec),
-                         srel_name + 5) == 0)
-             || (CONST_STRNEQ (srel_name, ".rel")
-                 && strcmp (bfd_get_section_name (abfd, sec),
-                            srel_name + 4) == 0));
-
   dynobj = hppa_info->root.dynobj;
   if (!dynobj)
     hppa_info->root.dynobj = dynobj = abfd;
@@ -515,9 +505,6 @@ elf64_hppa_check_relocs (bfd *abfd,
   const Elf_Internal_Rela *relend;
   Elf_Internal_Shdr *symtab_hdr;
   const Elf_Internal_Rela *rel;
-  asection *dlt, *plt, *stubs;
-  char *buf;
-  size_t buf_len;
   unsigned int sec_symndx;
 
   if (info->relocatable)
@@ -630,10 +617,6 @@ elf64_hppa_check_relocs (bfd *abfd,
   else
     sec_symndx = 0;
 
-  dlt = plt = stubs = NULL;
-  buf = NULL;
-  buf_len = 0;
-
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; ++rel)
     {
@@ -907,13 +890,9 @@ elf64_hppa_check_relocs (bfd *abfd,
        }
     }
 
-  if (buf)
-    free (buf);
   return TRUE;
 
  err_out:
-  if (buf)
-    free (buf);
   return FALSE;
 }
 
@@ -1979,7 +1958,7 @@ elf64_hppa_finish_dynamic_symbol (bfd *output_bfd,
                                  Elf_Internal_Sym *sym)
 {
   struct elf64_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh);
-  asection *stub, *splt, *sdlt, *sopd, *spltrel, *sdltrel;
+  asection *stub, *splt, *sopd, *spltrel;
   struct elf64_hppa_link_hash_table *hppa_info;
 
   hppa_info = hppa_link_hash_table (info);
@@ -1988,10 +1967,8 @@ elf64_hppa_finish_dynamic_symbol (bfd *output_bfd,
 
   stub = hppa_info->stub_sec;
   splt = hppa_info->plt_sec;
-  sdlt = hppa_info->dlt_sec;
   sopd = hppa_info->opd_sec;
   spltrel = hppa_info->plt_rel_sec;
-  sdltrel = hppa_info->dlt_rel_sec;
 
   /* Incredible.  It is actually necessary to NOT use the symbol's real
      value when building the dynamic symbol table for a shared library.
@@ -2481,7 +2458,7 @@ elf64_hppa_finalize_dynreloc (struct elf_link_hash_entry *eh,
 static enum elf_reloc_type_class
 elf64_hppa_reloc_type_class (const Elf_Internal_Rela *rela)
 {
-  if (ELF64_R_SYM (rela->r_info) == 0)
+  if (ELF64_R_SYM (rela->r_info) == STN_UNDEF)
     return reloc_class_relative;
 
   switch ((int) ELF64_R_TYPE (rela->r_info))
@@ -2627,7 +2604,7 @@ elf64_hppa_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
 
        /* pr_pid */
-       elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32);
+       elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
 
        /* pr_reg */
        offset = 112;
@@ -3870,7 +3847,6 @@ elf64_hppa_relocate_section (bfd *output_bfd,
       asection *sym_sec;
       bfd_vma relocation;
       bfd_reloc_status_type r;
-      bfd_boolean warned_undef;
 
       r_type = ELF_R_TYPE (rel->r_info);
       if (r_type < 0 || r_type >= (int) R_PARISC_UNIMPLEMENTED)
@@ -3887,7 +3863,6 @@ elf64_hppa_relocate_section (bfd *output_bfd,
       eh = NULL;
       sym = NULL;
       sym_sec = NULL;
-      warned_undef = FALSE;
       if (r_symndx < symtab_hdr->sh_info)
        {
          /* This is a local symbol, hh defaults to NULL.  */
@@ -3898,7 +3873,6 @@ elf64_hppa_relocate_section (bfd *output_bfd,
       else
        {
          /* This is not a local symbol.  */
-         bfd_boolean unresolved_reloc;
          struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
 
          /* It seems this can happen with erroneous or unsupported 
@@ -3912,21 +3886,13 @@ elf64_hppa_relocate_section (bfd *output_bfd,
                 || eh->root.type == bfd_link_hash_warning)
            eh = (struct elf_link_hash_entry *) eh->root.u.i.link;
 
-         warned_undef = FALSE;
-         unresolved_reloc = FALSE;
          relocation = 0;
          if (eh->root.type == bfd_link_hash_defined
              || eh->root.type == bfd_link_hash_defweak)
            {
              sym_sec = eh->root.u.def.section;
-             if (sym_sec == NULL
-                 || sym_sec->output_section == NULL)
-               /* Set a flag that will be cleared later if we find a
-                  relocation value for this symbol.  output_section
-                  is typically NULL for symbols satisfied by a shared
-                  library.  */
-               unresolved_reloc = TRUE;
-             else
+             if (sym_sec != NULL
+                 && sym_sec->output_section != NULL)
                relocation = (eh->root.u.def.value
                              + sym_sec->output_section->vma
                              + sym_sec->output_offset);
@@ -3950,7 +3916,6 @@ elf64_hppa_relocate_section (bfd *output_bfd,
                                                      input_section,
                                                      rel->r_offset, err))
                return FALSE;
-             warned_undef = TRUE;
            }
 
           if (!info->relocatable
@@ -3967,21 +3932,13 @@ elf64_hppa_relocate_section (bfd *output_bfd,
                       (info, eh_name (eh), input_bfd,
                        input_section, rel->r_offset, FALSE))
                     return FALSE;
-                  warned_undef = TRUE;
                 }
             }
        }
 
       if (sym_sec != NULL && elf_discarded_section (sym_sec))
-       {
-         /* For relocs against symbols from removed linkonce sections,
-            or sections discarded by a linker script, we just want the
-            section contents zeroed.  Avoid any special processing.  */
-         _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-         rel->r_info = 0;
-         rel->r_addend = 0;
-         continue;
-       }
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, relend, howto, contents);
 
       if (info->relocatable)
        continue;
@@ -4074,6 +4031,7 @@ const struct elf_size_info hppa64_elf_size_info =
 #define TARGET_BIG_SYM                 bfd_elf64_hppa_vec
 #define TARGET_BIG_NAME                        "elf64-hppa"
 #define ELF_ARCH                       bfd_arch_hppa
+#define ELF_TARGET_ID                  HPPA64_ELF_DATA
 #define ELF_MACHINE_CODE               EM_PARISC
 /* This is not strictly correct.  The maximum page size for PA2.0 is
    64M.  But everything still uses 4k.  */
This page took 0.025682 seconds and 4 git commands to generate.