include/
[deliverable/binutils-gdb.git] / bfd / elf32-hppa.c
index 4c35bbe4ea32245942829c66bcd5c3339801c0f7..dbe6d06553e6ee8f79864356023a8c84200656e0 100644 (file)
@@ -539,8 +539,8 @@ hppa_add_stub (const char *stub_name,
                                      TRUE, FALSE);
   if (stub_entry == NULL)
     {
-      (*_bfd_error_handler) (_("%s: cannot create stub entry %s"),
-                            bfd_archive_filename (section->owner),
+      (*_bfd_error_handler) (_("%B: cannot create stub entry %s"),
+                            section->owner,
                             stub_name);
       return NULL;
     }
@@ -570,7 +570,7 @@ hppa_type_of_stub (asection *input_sec,
       && hash->elf.dynindx != -1
       && !hash->plabel
       && (info->shared
-         || !(hash->elf.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
+         || !hash->elf.def_regular
          || hash->elf.root.type == bfd_link_hash_defweak))
     {
       /* We need an import stub.  Decide between hppa_stub_import
@@ -792,9 +792,9 @@ hppa_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
              || sym_value - 8 + (1 << (22 + 1)) >= (1 << (22 + 2))))
        {
          (*_bfd_error_handler)
-           (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
-            bfd_archive_filename (stub_entry->target_section->owner),
-            stub_sec->name,
+           (_("%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
+            stub_entry->target_section->owner,
+            stub_sec,
             (long) stub_entry->stub_offset,
             stub_entry->root.string);
          bfd_set_error (bfd_error_bad_value);
@@ -901,6 +901,14 @@ elf32_hppa_object_p (bfd *abfd)
          i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */
        return FALSE;
     }
+  else if (strcmp (bfd_get_target (abfd), "elf32-hppa-netbsd") == 0)
+    {
+      /* GCC on hppa-netbsd produces binaries with OSABI=NetBSD,
+        but the kernel produces corefiles with OSABI=SysV.  */
+      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NETBSD &&
+         i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */
+       return FALSE;
+    }
   else
     {
       if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_HPUX)
@@ -1011,15 +1019,16 @@ elf32_hppa_copy_indirect_symbol (const struct elf_backend_data *bed,
 
   if (ELIMINATE_COPY_RELOCS
       && ind->root.type != bfd_link_hash_indirect
-      && (dir->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
-    /* If called to transfer flags for a weakdef during processing
-       of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF.
-       We clear it ourselves for ELIMINATE_COPY_RELOCS.  */
-    dir->elf_link_hash_flags |=
-      (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC
-                                  | ELF_LINK_HASH_REF_REGULAR
-                                  | ELF_LINK_HASH_REF_REGULAR_NONWEAK
-                                  | ELF_LINK_HASH_NEEDS_PLT));
+      && dir->dynamic_adjusted)
+    {
+      /* If called to transfer flags for a weakdef during processing
+        of elf_adjust_dynamic_symbol, don't copy non_got_ref.
+        We clear it ourselves for ELIMINATE_COPY_RELOCS.  */
+      dir->ref_dynamic |= ind->ref_dynamic;
+      dir->ref_regular |= ind->ref_regular;
+      dir->ref_regular_nonweak |= ind->ref_regular_nonweak;
+      dir->needs_plt |= ind->needs_plt;
+    }
   else
     _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
 }
@@ -1164,8 +1173,8 @@ elf32_hppa_check_relocs (bfd *abfd,
          if (info->shared)
            {
              (*_bfd_error_handler)
-               (_("%s: relocation %s can not be used when making a shared object; recompile with -fPIC"),
-                bfd_archive_filename (abfd),
+               (_("%B: relocation %s can not be used when making a shared object; recompile with -fPIC"),
+                abfd,
                 elf_hppa_howto_table[r_type].name);
              bfd_set_error (bfd_error_bad_value);
              return FALSE;
@@ -1184,8 +1193,8 @@ elf32_hppa_check_relocs (bfd *abfd,
          if (info->shared)
            {
              (*_bfd_error_handler)
-               (_("%s: relocation %s should not be used when making a shared object; recompile with -fPIC"),
-                bfd_archive_filename (abfd),
+               (_("%B: relocation %s should not be used when making a shared object; recompile with -fPIC"),
+                abfd,
                 elf_hppa_howto_table[r_type].name);
            }
          /* Fall through.  */
@@ -1270,7 +1279,7 @@ elf32_hppa_check_relocs (bfd *abfd,
            {
              if (h != NULL)
                {
-                 h->elf.elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+                 h->elf.needs_plt = 1;
                  h->elf.plt.refcount += 1;
 
                  /* If this .plt entry is for a plabel, mark it so
@@ -1311,7 +1320,7 @@ elf32_hppa_check_relocs (bfd *abfd,
             so that we generate copy relocs if it turns out to be
             dynamic.  */
          if (h != NULL && !info->shared)
-           h->elf.elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+           h->elf.non_got_ref = 1;
 
          /* If we are creating a shared library then we need to copy
             the reloc into the shared library.  However, if we are
@@ -1347,15 +1356,13 @@ elf32_hppa_check_relocs (bfd *abfd,
                   || (h != NULL
                       && (!info->symbolic
                           || h->elf.root.type == bfd_link_hash_defweak
-                          || (h->elf.elf_link_hash_flags
-                              & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+                          || !h->elf.def_regular))))
              || (ELIMINATE_COPY_RELOCS
                  && !info->shared
                  && (sec->flags & SEC_ALLOC) != 0
                  && h != NULL
                  && (h->elf.root.type == bfd_link_hash_defweak
-                     || (h->elf.elf_link_hash_flags
-                         & ELF_LINK_HASH_DEF_REGULAR) == 0)))
+                     || !h->elf.def_regular)))
            {
              struct elf32_hppa_dyn_reloc_entry *p;
              struct elf32_hppa_dyn_reloc_entry **head;
@@ -1603,7 +1610,7 @@ elf32_hppa_hide_symbol (struct bfd_link_info *info,
 {
   if (force_local)
     {
-      h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+      h->forced_local = 1;
       if (h->dynindx != -1)
        {
          h->dynindx = -1;
@@ -1614,8 +1621,8 @@ elf32_hppa_hide_symbol (struct bfd_link_info *info,
 
   if (! ((struct elf32_hppa_link_hash_entry *) h)->plabel)
     {
-      h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
-      h->plt.offset = (bfd_vma) -1;
+      h->needs_plt = 0;
+      h->plt = elf_hash_table (info)->init_refcount;
     }
 }
 
@@ -1636,10 +1643,10 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info,
   /* If this is a function, put it in the procedure linkage table.  We
      will fill in the contents of the procedure linkage table later.  */
   if (h->type == STT_FUNC
-      || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
+      || h->needs_plt)
     {
       if (h->plt.refcount <= 0
-         || ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
+         || (h->def_regular
              && h->root.type != bfd_link_hash_defweak
              && ! ((struct elf32_hppa_link_hash_entry *) h)->plabel
              && (!info->shared || info->symbolic)))
@@ -1653,7 +1660,7 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info,
             application or we are doing a shared symbolic link.  */
 
          h->plt.offset = (bfd_vma) -1;
-         h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+         h->needs_plt = 0;
        }
 
       return TRUE;
@@ -1664,17 +1671,15 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info,
   /* If this is a weak symbol, and there is a real definition, the
      processor independent code will have arranged for us to see the
      real definition first, and we can just use the same value.  */
-  if (h->weakdef != NULL)
+  if (h->u.weakdef != NULL)
     {
-      if (h->weakdef->root.type != bfd_link_hash_defined
-         && h->weakdef->root.type != bfd_link_hash_defweak)
+      if (h->u.weakdef->root.type != bfd_link_hash_defined
+         && h->u.weakdef->root.type != bfd_link_hash_defweak)
        abort ();
-      h->root.u.def.section = h->weakdef->root.u.def.section;
-      h->root.u.def.value = h->weakdef->root.u.def.value;
+      h->root.u.def.section = h->u.weakdef->root.u.def.section;
+      h->root.u.def.value = h->u.weakdef->root.u.def.value;
       if (ELIMINATE_COPY_RELOCS)
-       h->elf_link_hash_flags
-         = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
-            | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
+       h->non_got_ref = h->u.weakdef->non_got_ref;
       return TRUE;
     }
 
@@ -1690,7 +1695,7 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info,
 
   /* If there are no references to this symbol that do not use the
      GOT, we don't need to generate a copy reloc.  */
-  if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
+  if (!h->non_got_ref)
     return TRUE;
 
   if (ELIMINATE_COPY_RELOCS)
@@ -1710,7 +1715,7 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info,
         we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
       if (p == NULL)
        {
-         h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+         h->non_got_ref = 0;
          return TRUE;
        }
     }
@@ -1733,7 +1738,7 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info,
   if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
     {
       htab->srelbss->size += sizeof (Elf32_External_Rela);
-      h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+      h->needs_copy = 1;
     }
 
   /* We need to figure out the alignment required for this symbol.  I
@@ -1786,7 +1791,7 @@ allocate_plt_static (struct elf_link_hash_entry *h, void *inf)
       /* Make sure this symbol is output as a dynamic symbol.
         Undefined weak syms won't yet be marked as dynamic.  */
       if (h->dynindx == -1
-         && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0
+         && !h->forced_local
          && h->type != STT_PARISC_MILLI)
        {
          if (! bfd_elf_link_record_dynamic_symbol (info, h))
@@ -1813,13 +1818,13 @@ allocate_plt_static (struct elf_link_hash_entry *h, void *inf)
        {
          /* No .plt entry needed.  */
          h->plt.offset = (bfd_vma) -1;
-         h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+         h->needs_plt = 0;
        }
     }
   else
     {
       h->plt.offset = (bfd_vma) -1;
-      h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
+      h->needs_plt = 0;
     }
 
   return TRUE;
@@ -1864,7 +1869,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       /* Make sure this symbol is output as a dynamic symbol.
         Undefined weak syms won't yet be marked as dynamic.  */
       if (h->dynindx == -1
-         && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0
+         && !h->forced_local
          && h->type != STT_PARISC_MILLI)
        {
          if (! bfd_elf_link_record_dynamic_symbol (info, h))
@@ -1877,7 +1882,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       if (htab->elf.dynamic_sections_created
          && (info->shared
              || (h->dynindx != -1
-                 && h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0))
+                 && !h->forced_local)))
        {
          htab->srelgot->size += sizeof (Elf32_External_Rela);
        }
@@ -1924,10 +1929,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       /* For the non-shared case, discard space for relocs against
         symbols which turn out to need copy relocs or are not
         dynamic.  */
-      if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
+      if (!h->non_got_ref
          && ((ELIMINATE_COPY_RELOCS
-              && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-              && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+              && h->def_dynamic
+              && !h->def_regular)
              || (htab->elf.dynamic_sections_created
                  && (h->root.type == bfd_link_hash_undefweak
                      || h->root.type == bfd_link_hash_undefined))))
@@ -1935,7 +1940,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
          /* Make sure this symbol is output as a dynamic symbol.
             Undefined weak syms won't yet be marked as dynamic.  */
          if (h->dynindx == -1
-             && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0
+             && !h->forced_local
              && h->type != STT_PARISC_MILLI)
            {
              if (! bfd_elf_link_record_dynamic_symbol (info, h))
@@ -1979,7 +1984,7 @@ clobber_millicode_symbols (struct elf_link_hash_entry *h,
     h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
   if (h->type == STT_PARISC_MILLI
-      && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+      && !h->forced_local)
     {
       elf32_hppa_hide_symbol (info, h, TRUE);
     }
@@ -2538,8 +2543,8 @@ get_local_syms (bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *info)
                  && (hash->elf.root.u.def.section->output_section->owner
                      == output_bfd)
                  && hash->elf.root.u.def.section->owner == input_bfd
-                 && (hash->elf.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
-                 && !(hash->elf.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)
+                 && hash->elf.def_regular
+                 && !hash->elf.forced_local
                  && ELF_ST_VISIBILITY (hash->elf.other) == STV_DEFAULT)
                {
                  asection *sec;
@@ -2565,8 +2570,8 @@ get_local_syms (bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *info)
                    }
                  else
                    {
-                     (*_bfd_error_handler) (_("%s: duplicate export stub %s"),
-                                            bfd_archive_filename (input_bfd),
+                     (*_bfd_error_handler) (_("%B: duplicate export stub %s"),
+                                            input_bfd,
                                             stub_name);
                    }
                }
@@ -2899,7 +2904,8 @@ elf32_hppa_set_gp (bfd *abfd, struct bfd_link_info *info)
         if either the .plt or .got is larger than 0x2000.  If both
         the .plt and .got are smaller than 0x2000, choose the end of
         the .plt section.  */
-      sec = splt;
+      sec = strcmp (bfd_get_target (abfd), "elf32-hppa-netbsd") == 0
+         ? NULL : splt;
       if (sec != NULL)
        {
          gp_val = sec->size;
@@ -2913,10 +2919,13 @@ elf32_hppa_set_gp (bfd *abfd, struct bfd_link_info *info)
          sec = sgot;
          if (sec != NULL)
            {
-             /* We know we don't have a .plt.  If .got is large,
-                offset our LTP.  */
-             if (sec->size > 0x2000)
-               gp_val = 0x2000;
+             if (strcmp (bfd_get_target (abfd), "elf32-hppa-netbsd") != 0)
+               {
+                 /* We know we don't have a .plt.  If .got is large,
+                    offset our LTP.  */
+                 if (sec->size > 0x2000)
+                   gp_val = 0x2000;
+               }
            }
          else
            {
@@ -3092,7 +3101,7 @@ final_link_relocate (asection *input_section,
              && h->elf.dynindx != -1
              && !h->plabel
              && (info->shared
-                 || !(h->elf.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)
+                 || !h->elf.def_regular
                  || h->elf.root.type == bfd_link_hash_defweak)))
        {
          stub_entry = hppa_get_stub_entry (input_section, sym_sec,
@@ -3152,9 +3161,9 @@ final_link_relocate (asection *input_section,
               and convert the associated add instruction, so issue an
               error.  */
            (*_bfd_error_handler)
-             (_("%s(%s+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"),
-              bfd_archive_filename (input_bfd),
-              input_section->name,
+             (_("%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"),
+              input_bfd,
+              input_section,
               (long) rel->r_offset,
               howto->name,
               insn);
@@ -3182,9 +3191,9 @@ final_link_relocate (asection *input_section,
              insn &= ~ (0x1f << 21);
 #if 0 /* debug them.  */
              (*_bfd_error_handler)
-               (_("%s(%s+0x%lx): fixing %s"),
-                bfd_archive_filename (input_bfd),
-                input_section->name,
+               (_("%B(%A+0x%lx): fixing %s"),
+                input_bfd,
+                input_section,
                 (long) rel->r_offset,
                 howto->name);
 #endif
@@ -3305,9 +3314,9 @@ final_link_relocate (asection *input_section,
       && value + addend + max_branch_offset >= 2*max_branch_offset)
     {
       (*_bfd_error_handler)
-       (_("%s(%s+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
-        bfd_archive_filename (input_bfd),
-        input_section->name,
+       (_("%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"),
+        input_bfd,
+        input_section,
         (long) rel->r_offset,
         stub_entry->root.string);
       bfd_set_error (bfd_error_bad_value);
@@ -3678,12 +3687,10 @@ elf32_hppa_relocate_section (bfd *output_bfd,
              || (!info->shared
                  && h != NULL
                  && h->elf.dynindx != -1
-                 && (h->elf.elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
+                 && !h->elf.non_got_ref
                  && ((ELIMINATE_COPY_RELOCS
-                      && (h->elf.elf_link_hash_flags
-                          & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-                      && (h->elf.elf_link_hash_flags
-                          & ELF_LINK_HASH_DEF_REGULAR) == 0)
+                      && h->elf.def_dynamic
+                      && !h->elf.def_regular)
                      || h->elf.root.type == bfd_link_hash_undefweak
                      || h->elf.root.type == bfd_link_hash_undefined)))
            {
@@ -3715,8 +3722,7 @@ elf32_hppa_relocate_section (bfd *output_bfd,
                           || !IS_ABSOLUTE_RELOC (r_type)
                           || !info->shared
                           || !info->symbolic
-                          || (h->elf.elf_link_hash_flags
-                              & ELF_LINK_HASH_DEF_REGULAR) == 0))
+                          || !h->elf.def_regular))
                {
                  outrel.r_info = ELF32_R_INFO (h->elf.dynindx, r_type);
                }
@@ -3800,9 +3806,9 @@ elf32_hppa_relocate_section (bfd *output_bfd,
          if (r == bfd_reloc_notsupported || !warned_undef)
            {
              (*_bfd_error_handler)
-               (_("%s(%s+0x%lx): cannot handle %s for %s"),
-                bfd_archive_filename (input_bfd),
-                input_section->name,
+               (_("%B(%A+0x%lx): cannot handle %s for %s"),
+                input_bfd,
+                input_section,
                 (long) rel->r_offset,
                 howto->name,
                 sym_name);
@@ -3882,7 +3888,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
       loc += htab->srelplt->reloc_count++ * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (htab->splt->output_section->owner, &rel, loc);
 
-      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+      if (!h->def_regular)
        {
          /* Mark the symbol as undefined, rather than as defined in
             the .plt section.  Leave the value alone.  */
@@ -3906,7 +3912,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
         relocate_section function.  */
       if (info->shared
          && (info->symbolic || h->dynindx == -1)
-         && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+         && h->def_regular)
        {
          rel.r_info = ELF32_R_INFO (0, R_PARISC_DIR32);
          rel.r_addend = (h->root.u.def.value
@@ -3927,7 +3933,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
       bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
     }
 
-  if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
+  if (h->needs_copy)
     {
       asection *s;
 
@@ -4116,6 +4122,10 @@ elf32_hppa_post_process_headers (bfd *abfd,
     {
       i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_LINUX;
     }
+  else if (strcmp (bfd_get_target (abfd), "elf32-hppa-netbsd") == 0)
+    {
+      i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_NETBSD;
+    }
   else
     {
       i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_HPUX;
@@ -4185,3 +4195,10 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
 
 #define INCLUDED_TARGET_FILE 1
 #include "elf32-target.h"
+
+#undef TARGET_BIG_SYM
+#define TARGET_BIG_SYM                 bfd_elf32_hppa_nbsd_vec
+#undef TARGET_BIG_NAME
+#define TARGET_BIG_NAME                        "elf32-hppa-netbsd"
+
+#include "elf32-target.h"
This page took 0.048418 seconds and 4 git commands to generate.