bfd/
[deliverable/binutils-gdb.git] / bfd / elf32-hppa.c
index b204c57df462d85056fe7cefd193256574266e3a..00fd99048c3495623c4722c2bb947ad116321a9f 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for HP PA-RISC ELF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
-   2002, 2003 Free Software Foundation, Inc.
+   2002, 2003, 2004 Free Software Foundation, Inc.
 
    Original code by
        Center for Software Science
@@ -141,6 +141,12 @@ static const bfd_byte plt_stub[] =
 #define IS_ABSOLUTE_RELOC(r_type) 1
 #endif
 
+/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
+   copying dynamic variables from a shared lib into an app's dynbss
+   section, and instead use a dynamic relocation to point into the
+   shared lib.  */
+#define ELIMINATE_COPY_RELOCS 1
+
 enum elf32_hppa_stub_type {
   hppa_stub_long_branch,
   hppa_stub_long_branch_shared,
@@ -203,10 +209,6 @@ struct elf32_hppa_link_hash_entry {
 #endif
   } *dyn_relocs;
 
-  /* Set if the only reason we need a .plt entry is for a non-PIC to
-     PIC function call.  */
-  unsigned int pic_call:1;
-
   /* Set if this symbol is used by a plabel reloc.  */
   unsigned int plabel:1;
 };
@@ -223,8 +225,8 @@ struct elf32_hppa_link_hash_table {
   bfd *stub_bfd;
 
   /* Linker call-backs.  */
-  asection * (*add_stub_section) PARAMS ((const char *, asection *));
-  void (*layout_sections_again) PARAMS ((void));
+  asection * (*add_stub_section) (const char *, asection *);
+  void (*layout_sections_again) (void);
 
   /* Array to keep track of which stub sections have been created, and
      information on stub grouping.  */
@@ -279,139 +281,14 @@ struct elf32_hppa_link_hash_table {
   ((struct elf32_hppa_stub_hash_entry *) \
    bfd_hash_lookup ((table), (string), (create), (copy)))
 
-static struct bfd_hash_entry *stub_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-
-static struct bfd_hash_entry *hppa_link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-
-static struct bfd_link_hash_table *elf32_hppa_link_hash_table_create
-  PARAMS ((bfd *));
-
-static void elf32_hppa_link_hash_table_free
-  PARAMS ((struct bfd_link_hash_table *));
-
-/* Stub handling functions.  */
-static char *hppa_stub_name
-  PARAMS ((const asection *, const asection *,
-          const struct elf32_hppa_link_hash_entry *,
-          const Elf_Internal_Rela *));
-
-static struct elf32_hppa_stub_hash_entry *hppa_get_stub_entry
-  PARAMS ((const asection *, const asection *,
-          struct elf32_hppa_link_hash_entry *,
-          const Elf_Internal_Rela *,
-          struct elf32_hppa_link_hash_table *));
-
-static struct elf32_hppa_stub_hash_entry *hppa_add_stub
-  PARAMS ((const char *, asection *, struct elf32_hppa_link_hash_table *));
-
-static enum elf32_hppa_stub_type hppa_type_of_stub
-  PARAMS ((asection *, const Elf_Internal_Rela *,
-          struct elf32_hppa_link_hash_entry *, bfd_vma));
-
-static bfd_boolean hppa_build_one_stub
-  PARAMS ((struct bfd_hash_entry *, PTR));
-
-static bfd_boolean hppa_size_one_stub
-  PARAMS ((struct bfd_hash_entry *, PTR));
-
-/* BFD and elf backend functions.  */
-static bfd_boolean elf32_hppa_object_p PARAMS ((bfd *));
-
-static bfd_boolean elf32_hppa_add_symbol_hook
-  PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
-          const char **, flagword *, asection **, bfd_vma *));
-
-static bfd_boolean elf32_hppa_create_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-
-static void elf32_hppa_copy_indirect_symbol
-  PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *,
-          struct elf_link_hash_entry *));
-
-static bfd_boolean elf32_hppa_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *,
-          asection *, const Elf_Internal_Rela *));
-
-static asection *elf32_hppa_gc_mark_hook
-  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-          struct elf_link_hash_entry *, Elf_Internal_Sym *));
-
-static bfd_boolean elf32_hppa_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *,
-          asection *, const Elf_Internal_Rela *));
-
-static void elf32_hppa_hide_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean));
-
-static bfd_boolean elf32_hppa_adjust_dynamic_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-
-static bfd_boolean mark_PIC_calls
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-
-static bfd_boolean allocate_plt_static
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-
-static bfd_boolean allocate_dynrelocs
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-
-static bfd_boolean readonly_dynrelocs
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-
-static bfd_boolean clobber_millicode_symbols
-  PARAMS ((struct elf_link_hash_entry *, struct bfd_link_info *));
-
-static bfd_boolean elf32_hppa_size_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-
-static void group_sections
-  PARAMS ((struct elf32_hppa_link_hash_table *, bfd_size_type, bfd_boolean));
-
-static int get_local_syms
-  PARAMS ((bfd *, bfd *, struct bfd_link_info *));
-
-static bfd_boolean elf32_hppa_final_link
-  PARAMS ((bfd *, struct bfd_link_info *));
-
-static void hppa_record_segment_addr
-  PARAMS ((bfd *, asection *, PTR));
-
-static bfd_reloc_status_type final_link_relocate
-  PARAMS ((asection *, bfd_byte *, const Elf_Internal_Rela *,
-          bfd_vma, struct elf32_hppa_link_hash_table *, asection *,
-          struct elf32_hppa_link_hash_entry *));
-
-static bfd_boolean elf32_hppa_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
-          bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-
-static bfd_boolean elf32_hppa_finish_dynamic_symbol
-  PARAMS ((bfd *, struct bfd_link_info *,
-          struct elf_link_hash_entry *, Elf_Internal_Sym *));
-
-static enum elf_reloc_type_class elf32_hppa_reloc_type_class
-  PARAMS ((const Elf_Internal_Rela *));
-
-static bfd_boolean elf32_hppa_finish_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-
-static void elf32_hppa_post_process_headers
-  PARAMS ((bfd *, struct bfd_link_info *));
-
-static int elf32_hppa_elf_get_symbol_type
-  PARAMS ((Elf_Internal_Sym *, int));
-
 /* Assorted hash table functions.  */
 
 /* Initialize an entry in the stub hash table.  */
 
 static struct bfd_hash_entry *
-stub_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
+stub_hash_newfunc (struct bfd_hash_entry *entry,
+                  struct bfd_hash_table *table,
+                  const char *string)
 {
   /* Allocate the structure if it has not already been allocated by a
      subclass.  */
@@ -446,10 +323,9 @@ stub_hash_newfunc (entry, table, string)
 /* Initialize an entry in the link hash table.  */
 
 static struct bfd_hash_entry *
-hppa_link_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
+hppa_link_hash_newfunc (struct bfd_hash_entry *entry,
+                       struct bfd_hash_table *table,
+                       const char *string)
 {
   /* Allocate the structure if it has not already been allocated by a
      subclass.  */
@@ -471,7 +347,6 @@ hppa_link_hash_newfunc (entry, table, string)
       eh = (struct elf32_hppa_link_hash_entry *) entry;
       eh->stub_cache = NULL;
       eh->dyn_relocs = NULL;
-      eh->pic_call = 0;
       eh->plabel = 0;
     }
 
@@ -483,13 +358,12 @@ hppa_link_hash_newfunc (entry, table, string)
    using static variables).  */
 
 static struct bfd_link_hash_table *
-elf32_hppa_link_hash_table_create (abfd)
-     bfd *abfd;
+elf32_hppa_link_hash_table_create (bfd *abfd)
 {
   struct elf32_hppa_link_hash_table *ret;
   bfd_size_type amt = sizeof (*ret);
 
-  ret = (struct elf32_hppa_link_hash_table *) bfd_malloc (amt);
+  ret = bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -528,8 +402,7 @@ elf32_hppa_link_hash_table_create (abfd)
 /* Free the derived linker hash table.  */
 
 static void
-elf32_hppa_link_hash_table_free (hash)
-     struct bfd_link_hash_table *hash;
+elf32_hppa_link_hash_table_free (struct bfd_link_hash_table *hash)
 {
   struct elf32_hppa_link_hash_table *ret
     = (struct elf32_hppa_link_hash_table *) hash;
@@ -541,11 +414,10 @@ elf32_hppa_link_hash_table_free (hash)
 /* Build a name for an entry in the stub hash table.  */
 
 static char *
-hppa_stub_name (input_section, sym_sec, hash, rel)
-     const asection *input_section;
-     const asection *sym_sec;
-     const struct elf32_hppa_link_hash_entry *hash;
-     const Elf_Internal_Rela *rel;
+hppa_stub_name (const asection *input_section,
+               const asection *sym_sec,
+               const struct elf32_hppa_link_hash_entry *hash,
+               const Elf_Internal_Rela *rel)
 {
   char *stub_name;
   bfd_size_type len;
@@ -582,12 +454,11 @@ hppa_stub_name (input_section, sym_sec, hash, rel)
    creating the stub name takes a bit of time.  */
 
 static struct elf32_hppa_stub_hash_entry *
-hppa_get_stub_entry (input_section, sym_sec, hash, rel, htab)
-     const asection *input_section;
-     const asection *sym_sec;
-     struct elf32_hppa_link_hash_entry *hash;
-     const Elf_Internal_Rela *rel;
-     struct elf32_hppa_link_hash_table *htab;
+hppa_get_stub_entry (const asection *input_section,
+                    const asection *sym_sec,
+                    struct elf32_hppa_link_hash_entry *hash,
+                    const Elf_Internal_Rela *rel,
+                    struct elf32_hppa_link_hash_table *htab)
 {
   struct elf32_hppa_stub_hash_entry *stub_entry;
   const asection *id_sec;
@@ -628,10 +499,9 @@ hppa_get_stub_entry (input_section, sym_sec, hash, rel, htab)
    stub entry are initialised.  */
 
 static struct elf32_hppa_stub_hash_entry *
-hppa_add_stub (stub_name, section, htab)
-     const char *stub_name;
-     asection *section;
-     struct elf32_hppa_link_hash_table *htab;
+hppa_add_stub (const char *stub_name,
+              asection *section,
+              struct elf32_hppa_link_hash_table *htab)
 {
   asection *link_sec;
   asection *stub_sec;
@@ -669,8 +539,8 @@ hppa_add_stub (stub_name, section, htab)
                                      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;
     }
@@ -684,11 +554,11 @@ hppa_add_stub (stub_name, section, htab)
 /* Determine the type of stub needed, if any, for a call.  */
 
 static enum elf32_hppa_stub_type
-hppa_type_of_stub (input_sec, rel, hash, destination)
-     asection *input_sec;
-     const Elf_Internal_Rela *rel;
-     struct elf32_hppa_link_hash_entry *hash;
-     bfd_vma destination;
+hppa_type_of_stub (asection *input_sec,
+                  const Elf_Internal_Rela *rel,
+                  struct elf32_hppa_link_hash_entry *hash,
+                  bfd_vma destination,
+                  struct bfd_link_info *info)
 {
   bfd_vma location;
   bfd_vma branch_offset;
@@ -697,8 +567,11 @@ hppa_type_of_stub (input_sec, rel, hash, destination)
 
   if (hash != NULL
       && hash->elf.plt.offset != (bfd_vma) -1
-      && (hash->elf.dynindx != -1 || hash->pic_call)
-      && !hash->plabel)
+      && hash->elf.dynindx != -1
+      && !hash->plabel
+      && (info->shared
+         || !hash->elf.def_regular
+         || hash->elf.root.type == bfd_link_hash_defweak))
     {
       /* We need an import stub.  Decide between hppa_stub_import
         and hppa_stub_import_shared later.  */
@@ -777,9 +650,7 @@ hppa_type_of_stub (input_sec, rel, hash, destination)
 #endif
 
 static bfd_boolean
-hppa_build_one_stub (gen_entry, in_arg)
-     struct bfd_hash_entry *gen_entry;
-     PTR in_arg;
+hppa_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
 {
   struct elf32_hppa_stub_hash_entry *stub_entry;
   struct bfd_link_info *info;
@@ -795,13 +666,13 @@ hppa_build_one_stub (gen_entry, in_arg)
 
   /* Massage our args to the form they really have.  */
   stub_entry = (struct elf32_hppa_stub_hash_entry *) gen_entry;
-  info = (struct bfd_link_info *) in_arg;
+  info = in_arg;
 
   htab = hppa_link_hash_table (info);
   stub_sec = stub_entry->stub_sec;
 
   /* Make a note of the offset within the stubs for this entry.  */
-  stub_entry->stub_offset = stub_sec->_raw_size;
+  stub_entry->stub_offset = stub_sec->size;
   loc = stub_sec->contents + stub_entry->stub_offset;
 
   stub_bfd = stub_sec->owner;
@@ -817,11 +688,11 @@ hppa_build_one_stub (gen_entry, in_arg)
                   + stub_entry->target_section->output_offset
                   + stub_entry->target_section->output_section->vma);
 
-      val = hppa_field_adjust (sym_value, (bfd_signed_vma) 0, e_lrsel);
+      val = hppa_field_adjust (sym_value, 0, e_lrsel);
       insn = hppa_rebuild_insn ((int) LDIL_R1, val, 21);
       bfd_put_32 (stub_bfd, insn, loc);
 
-      val = hppa_field_adjust (sym_value, (bfd_signed_vma) 0, e_rrsel) >> 2;
+      val = hppa_field_adjust (sym_value, 0, e_rrsel) >> 2;
       insn = hppa_rebuild_insn ((int) BE_SR4_R1, val, 17);
       bfd_put_32 (stub_bfd, insn, loc + 4);
 
@@ -867,7 +738,7 @@ hppa_build_one_stub (gen_entry, in_arg)
       if (stub_entry->stub_type == hppa_stub_import_shared)
        insn = ADDIL_R19;
 #endif
-      val = hppa_field_adjust (sym_value, (bfd_signed_vma) 0, e_lrsel),
+      val = hppa_field_adjust (sym_value, 0, e_lrsel),
       insn = hppa_rebuild_insn ((int) insn, val, 21);
       bfd_put_32 (stub_bfd, insn, loc);
 
@@ -876,7 +747,7 @@ hppa_build_one_stub (gen_entry, in_arg)
         lsel/rsel then with unfortunate sym_values we will round
         sym_value+4 up to the next 2k block leading to a mis-match
         between the lsel and rsel value.  */
-      val = hppa_field_adjust (sym_value, (bfd_signed_vma) 0, e_rrsel);
+      val = hppa_field_adjust (sym_value, 0, e_rrsel);
       insn = hppa_rebuild_insn ((int) LDW_R1_R21, val, 14);
       bfd_put_32 (stub_bfd, insn, loc + 4);
 
@@ -903,39 +774,6 @@ hppa_build_one_stub (gen_entry, in_arg)
          size = 16;
        }
 
-      if (!info->shared
-         && stub_entry->h != NULL
-         && stub_entry->h->pic_call)
-       {
-         /* Build the .plt entry needed to call a PIC function from
-            statically linked code.  We don't need any relocs.  */
-         bfd *dynobj;
-         struct elf32_hppa_link_hash_entry *eh;
-         bfd_vma value;
-
-         dynobj = htab->elf.dynobj;
-         eh = (struct elf32_hppa_link_hash_entry *) stub_entry->h;
-
-         if (eh->elf.root.type != bfd_link_hash_defined
-             && eh->elf.root.type != bfd_link_hash_defweak)
-           abort ();
-
-         value = (eh->elf.root.u.def.value
-                  + eh->elf.root.u.def.section->output_offset
-                  + eh->elf.root.u.def.section->output_section->vma);
-
-         /* Fill in the entry in the procedure linkage table.
-
-            The format of a plt entry is
-            <funcaddr>
-            <__gp>.  */
-
-         bfd_put_32 (htab->splt->owner, value,
-                     htab->splt->contents + off);
-         value = elf_gp (htab->splt->output_section->owner);
-         bfd_put_32 (htab->splt->owner, value,
-                     htab->splt->contents + off + 4);
-       }
       break;
 
     case hppa_stub_export:
@@ -954,9 +792,9 @@ hppa_build_one_stub (gen_entry, 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);
@@ -978,7 +816,7 @@ hppa_build_one_stub (gen_entry, in_arg)
 
       /* Point the function symbol at the stub.  */
       stub_entry->h->elf.root.u.def.section = stub_sec;
-      stub_entry->h->elf.root.u.def.value = stub_sec->_raw_size;
+      stub_entry->h->elf.root.u.def.value = stub_sec->size;
 
       size = 24;
       break;
@@ -988,7 +826,7 @@ hppa_build_one_stub (gen_entry, in_arg)
       return FALSE;
     }
 
-  stub_sec->_raw_size += size;
+  stub_sec->size += size;
   return TRUE;
 }
 
@@ -997,7 +835,6 @@ hppa_build_one_stub (gen_entry, in_arg)
 #undef BL_R1
 #undef ADDIL_R1
 #undef DEPI_R1
-#undef ADDIL_DP
 #undef LDW_R1_R21
 #undef LDW_R1_DLT
 #undef LDW_R1_R19
@@ -1018,9 +855,7 @@ hppa_build_one_stub (gen_entry, in_arg)
    we know stub section sizes.  */
 
 static bfd_boolean
-hppa_size_one_stub (gen_entry, in_arg)
-     struct bfd_hash_entry *gen_entry;
-     PTR in_arg;
+hppa_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
 {
   struct elf32_hppa_stub_hash_entry *stub_entry;
   struct elf32_hppa_link_hash_table *htab;
@@ -1028,7 +863,7 @@ hppa_size_one_stub (gen_entry, in_arg)
 
   /* Massage our args to the form they really have.  */
   stub_entry = (struct elf32_hppa_stub_hash_entry *) gen_entry;
-  htab = (struct elf32_hppa_link_hash_table *) in_arg;
+  htab = in_arg;
 
   if (stub_entry->stub_type == hppa_stub_long_branch)
     size = 8;
@@ -1044,7 +879,7 @@ hppa_size_one_stub (gen_entry, in_arg)
        size = 16;
     }
 
-  stub_entry->stub_sec->_raw_size += size;
+  stub_entry->stub_sec->size += size;
   return TRUE;
 }
 
@@ -1052,8 +887,7 @@ hppa_size_one_stub (gen_entry, in_arg)
    Additionally we set the default architecture and machine.  */
 
 static bfd_boolean
-elf32_hppa_object_p (abfd)
-     bfd *abfd;
+elf32_hppa_object_p (bfd *abfd)
 {
   Elf_Internal_Ehdr * i_ehdrp;
   unsigned int flags;
@@ -1061,7 +895,18 @@ elf32_hppa_object_p (abfd)
   i_ehdrp = elf_elfheader (abfd);
   if (strcmp (bfd_get_target (abfd), "elf32-hppa-linux") == 0)
     {
-      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX)
+      /* GCC on hppa-linux produces binaries with OSABI=Linux,
+        but the kernel produces corefiles with OSABI=SysV.  */
+      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX &&
+         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
@@ -1085,30 +930,11 @@ elf32_hppa_object_p (abfd)
   return TRUE;
 }
 
-/* Undo the generic ELF code's subtraction of section->vma from the
-   value of each external symbol.  */
-
-static bfd_boolean
-elf32_hppa_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     const Elf_Internal_Sym *sym ATTRIBUTE_UNUSED;
-     const char **namep ATTRIBUTE_UNUSED;
-     flagword *flagsp ATTRIBUTE_UNUSED;
-     asection **secp;
-     bfd_vma *valp;
-{
-  *valp += (*secp)->vma;
-  return TRUE;
-}
-
 /* Create the .plt and .got sections, and set up our hash table
    short-cuts to various dynamic sections.  */
 
 static bfd_boolean
-elf32_hppa_create_dynamic_sections (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+elf32_hppa_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 {
   struct elf32_hppa_link_hash_table *htab;
 
@@ -1146,9 +972,9 @@ elf32_hppa_create_dynamic_sections (abfd, info)
 /* Copy the extra info we tack onto an elf_link_hash_entry.  */
 
 static void
-elf32_hppa_copy_indirect_symbol (bed, dir, ind)
-     struct elf_backend_data *bed;
-     struct elf_link_hash_entry *dir, *ind;
+elf32_hppa_copy_indirect_symbol (const struct elf_backend_data *bed,
+                                struct elf_link_hash_entry *dir,
+                                struct elf_link_hash_entry *ind)
 {
   struct elf32_hppa_link_hash_entry *edir, *eind;
 
@@ -1191,7 +1017,20 @@ elf32_hppa_copy_indirect_symbol (bed, dir, ind)
       eind->dyn_relocs = NULL;
     }
 
-  _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
+  if (ELIMINATE_COPY_RELOCS
+      && ind->root.type != bfd_link_hash_indirect
+      && 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);
 }
 
 /* Look through the relocs for a section during the first phase, and
@@ -1200,11 +1039,10 @@ elf32_hppa_copy_indirect_symbol (bed, dir, ind)
    necessarily read all the input files.  */
 
 static bfd_boolean
-elf32_hppa_check_relocs (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+elf32_hppa_check_relocs (bfd *abfd,
+                        struct bfd_link_info *info,
+                        asection *sec,
+                        const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
@@ -1214,7 +1052,7 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
   asection *sreloc;
   asection *stubreloc;
 
-  if (info->relocateable)
+  if (info->relocatable)
     return TRUE;
 
   htab = hppa_link_hash_table (info);
@@ -1254,9 +1092,6 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
        case R_PARISC_DLTIND21L:
          /* This symbol requires a global offset table entry.  */
          need_entry = NEED_GOT;
-
-         /* Mark this section as containing PIC code.  */
-         sec->flags |= SEC_HAS_GOT_REF;
          break;
 
        case R_PARISC_PLABEL14R: /* "Official" procedure labels.  */
@@ -1321,12 +1156,13 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
            }
          break;
 
-       case R_PARISC_SEGBASE: /* Used to set segment base.  */
+       case R_PARISC_SEGBASE:  /* Used to set segment base.  */
        case R_PARISC_SEGREL32: /* Relative reloc, used for unwind.  */
        case R_PARISC_PCREL14F: /* PC relative load/store.  */
        case R_PARISC_PCREL14R:
        case R_PARISC_PCREL17R: /* External branches.  */
        case R_PARISC_PCREL21L: /* As above, and for load/store too.  */
+       case R_PARISC_PCREL32:
          /* We don't need to propagate the relocation if linking a
             shared object since these are section relative.  */
          continue;
@@ -1337,8 +1173,8 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
          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;
@@ -1357,8 +1193,8 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
          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.  */
@@ -1372,16 +1208,14 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
          /* This relocation describes the C++ object vtable hierarchy.
             Reconstruct it for later use during GC.  */
        case R_PARISC_GNU_VTINHERIT:
-         if (!_bfd_elf32_gc_record_vtinherit (abfd, sec,
-                                              &h->elf, rel->r_offset))
+         if (!bfd_elf_gc_record_vtinherit (abfd, sec, &h->elf, rel->r_offset))
            return FALSE;
          continue;
 
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_PARISC_GNU_VTENTRY:
-         if (!_bfd_elf32_gc_record_vtentry (abfd, sec,
-                                            &h->elf, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, &h->elf, rel->r_addend))
            return FALSE;
          continue;
 
@@ -1422,8 +1256,7 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
                     pointer.  */
                  size = symtab_hdr->sh_info;
                  size *= 2 * sizeof (bfd_signed_vma);
-                 local_got_refcounts = ((bfd_signed_vma *)
-                                        bfd_zalloc (abfd, size));
+                 local_got_refcounts = bfd_zalloc (abfd, size);
                  if (local_got_refcounts == NULL)
                    return FALSE;
                  elf_local_got_refcounts (abfd) = local_got_refcounts;
@@ -1446,7 +1279,7 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
            {
              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
@@ -1469,8 +1302,7 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
                         plt offsets.  */
                      size = symtab_hdr->sh_info;
                      size *= 2 * sizeof (bfd_signed_vma);
-                     local_got_refcounts = ((bfd_signed_vma *)
-                                            bfd_zalloc (abfd, size));
+                     local_got_refcounts = bfd_zalloc (abfd, size);
                      if (local_got_refcounts == NULL)
                        return FALSE;
                      elf_local_got_refcounts (abfd) = local_got_refcounts;
@@ -1488,7 +1320,7 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
             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
@@ -1524,14 +1356,13 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
                   || (h != NULL
                       && (!info->symbolic
                           || h->elf.root.type == bfd_link_hash_defweak
-                          || (h->elf.elf_link_hash_flags
-                              & ELF_LINK_HASH_DEF_REGULAR) == 0))))
-             || (!info->shared
+                          || !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;
@@ -1604,9 +1435,7 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
              p = *head;
              if (p == NULL || p->sec != sec)
                {
-                 p = ((struct elf32_hppa_dyn_reloc_entry *)
-                      bfd_alloc (htab->elf.dynobj,
-                                 (bfd_size_type) sizeof *p));
+                 p = bfd_alloc (htab->elf.dynobj, sizeof *p);
                  if (p == NULL)
                    return FALSE;
                  p->next = *head;
@@ -1634,12 +1463,11 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
    for a given relocation.  */
 
 static asection *
-elf32_hppa_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+elf32_hppa_gc_mark_hook (asection *sec,
+                        struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                        Elf_Internal_Rela *rel,
+                        struct elf_link_hash_entry *h,
+                        Elf_Internal_Sym *sym)
 {
   if (h != NULL)
     {
@@ -1674,11 +1502,10 @@ elf32_hppa_gc_mark_hook (sec, info, rel, h, sym)
    removed.  */
 
 static bfd_boolean
-elf32_hppa_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+elf32_hppa_gc_sweep_hook (bfd *abfd,
+                         struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                         asection *sec,
+                         const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
@@ -1777,14 +1604,13 @@ elf32_hppa_gc_sweep_hook (abfd, info, sec, relocs)
    plabels.  */
 
 static void
-elf32_hppa_hide_symbol (info, h, force_local)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-     bfd_boolean force_local;
+elf32_hppa_hide_symbol (struct bfd_link_info *info,
+                       struct elf_link_hash_entry *h,
+                       bfd_boolean force_local)
 {
   if (force_local)
     {
-      h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+      h->forced_local = 1;
       if (h->dynindx != -1)
        {
          h->dynindx = -1;
@@ -1795,22 +1621,11 @@ elf32_hppa_hide_symbol (info, h, force_local)
 
   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;
     }
 }
 
-/* This is the condition under which elf32_hppa_finish_dynamic_symbol
-   will be called from elflink.h.  If elflink.h doesn't call our
-   finish_dynamic_symbol routine, we'll need to do something about
-   initializing any .plt and .got entries in elf32_hppa_relocate_section.  */
-#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
-  ((DYN)                                                               \
-   && ((INFO)->shared                                                  \
-       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)     \
-   && ((H)->dynindx != -1                                              \
-       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
-
 /* Adjust a symbol defined by a dynamic object and referenced by a
    regular object.  The current definition is in some section of the
    dynamic object, but we're not including those sections.  We have to
@@ -1818,23 +1633,20 @@ elf32_hppa_hide_symbol (info, h, force_local)
    understand.  */
 
 static bfd_boolean
-elf32_hppa_adjust_dynamic_symbol (info, h)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
+elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info,
+                                 struct elf_link_hash_entry *h)
 {
   struct elf32_hppa_link_hash_table *htab;
-  struct elf32_hppa_link_hash_entry *eh;
-  struct elf32_hppa_dyn_reloc_entry *p;
   asection *s;
   unsigned int power_of_two;
 
   /* 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)))
@@ -1847,18 +1659,8 @@ elf32_hppa_adjust_dynamic_symbol (info, h)
             used by a plabel relocation.  Either this object is the
             application or we are doing a shared symbolic link.  */
 
-         /* As a special sop to the hppa ABI, we keep a .plt entry
-            for functions in sections containing PIC code.  */
-         if (!info->shared
-             && h->plt.refcount > 0
-             && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
-             && (h->root.u.def.section->flags & SEC_HAS_GOT_REF) != 0)
-           ((struct elf32_hppa_link_hash_entry *) h)->pic_call = 1;
-         else
-           {
-             h->plt.offset = (bfd_vma) -1;
-             h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
-           }
+         h->plt.offset = (bfd_vma) -1;
+         h->needs_plt = 0;
        }
 
       return TRUE;
@@ -1869,13 +1671,15 @@ elf32_hppa_adjust_dynamic_symbol (info, h)
   /* 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->non_got_ref = h->u.weakdef->non_got_ref;
       return TRUE;
     }
 
@@ -1891,23 +1695,29 @@ elf32_hppa_adjust_dynamic_symbol (info, h)
 
   /* 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;
 
-  eh = (struct elf32_hppa_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
+  if (ELIMINATE_COPY_RELOCS)
     {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-       break;
-    }
+      struct elf32_hppa_link_hash_entry *eh;
+      struct elf32_hppa_dyn_reloc_entry *p;
 
-  /* If we didn't find any dynamic relocs in read-only sections, then
-     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;
-      return TRUE;
+      eh = (struct elf32_hppa_link_hash_entry *) h;
+      for (p = eh->dyn_relocs; p != NULL; p = p->next)
+       {
+         s = p->sec->output_section;
+         if (s != NULL && (s->flags & SEC_READONLY) != 0)
+           break;
+       }
+
+      /* If we didn't find any dynamic relocs in read-only sections, then
+        we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
+      if (p == NULL)
+       {
+         h->non_got_ref = 0;
+         return TRUE;
+       }
     }
 
   /* We must allocate the symbol in our .dynbss section, which will
@@ -1927,8 +1737,8 @@ elf32_hppa_adjust_dynamic_symbol (info, h)
      runtime process image.  */
   if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
     {
-      htab->srelbss->_raw_size += sizeof (Elf32_External_Rela);
-      h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+      htab->srelbss->size += sizeof (Elf32_External_Rela);
+      h->needs_copy = 1;
     }
 
   /* We need to figure out the alignment required for this symbol.  I
@@ -1940,8 +1750,7 @@ elf32_hppa_adjust_dynamic_symbol (info, h)
 
   /* Apply the required alignment.  */
   s = htab->sdynbss;
-  s->_raw_size = BFD_ALIGN (s->_raw_size,
-                           (bfd_size_type) (1 << power_of_two));
+  s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two));
   if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s))
     {
       if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
@@ -1950,49 +1759,19 @@ elf32_hppa_adjust_dynamic_symbol (info, h)
 
   /* Define the symbol as being at this point in the section.  */
   h->root.u.def.section = s;
-  h->root.u.def.value = s->_raw_size;
+  h->root.u.def.value = s->size;
 
   /* Increment the section size to make room for the symbol.  */
-  s->_raw_size += h->size;
-
-  return TRUE;
-}
-
-/* Called via elf_link_hash_traverse to create .plt entries for an
-   application that uses statically linked PIC functions.  Similar to
-   the first part of elf32_hppa_adjust_dynamic_symbol.  */
-
-static bfd_boolean
-mark_PIC_calls (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf ATTRIBUTE_UNUSED;
-{
-  if (h->root.type == bfd_link_hash_warning)
-    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-  if (! (h->plt.refcount > 0
-        && (h->root.type == bfd_link_hash_defined
-            || h->root.type == bfd_link_hash_defweak)
-        && (h->root.u.def.section->flags & SEC_HAS_GOT_REF) != 0))
-    {
-      h->plt.offset = (bfd_vma) -1;
-      h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
-      return TRUE;
-    }
-
-  h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
-  ((struct elf32_hppa_link_hash_entry *) h)->pic_call = 1;
+  s->size += h->size;
 
   return TRUE;
 }
 
 /* Allocate space in the .plt for entries that won't have relocations.
-   ie. pic_call and plabel entries.  */
+   ie. plabel entries.  */
 
 static bfd_boolean
-allocate_plt_static (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf;
+allocate_plt_static (struct elf_link_hash_entry *h, void *inf)
 {
   struct bfd_link_info *info;
   struct elf32_hppa_link_hash_table *htab;
@@ -2004,31 +1783,22 @@ allocate_plt_static (h, inf)
   if (h->root.type == bfd_link_hash_warning)
     h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
-  info = (struct bfd_link_info *) inf;
+  info = inf;
   htab = hppa_link_hash_table (info);
-  if (((struct elf32_hppa_link_hash_entry *) h)->pic_call)
-    {
-      /* Make an entry in the .plt section for non-pic code that is
-        calling pic code.  */
-      ((struct elf32_hppa_link_hash_entry *) h)->plabel = 0;
-      s = htab->splt;
-      h->plt.offset = s->_raw_size;
-      s->_raw_size += PLT_ENTRY_SIZE;
-    }
-  else if (htab->elf.dynamic_sections_created
+  if (htab->elf.dynamic_sections_created
           && h->plt.refcount > 0)
     {
       /* 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_elf32_link_record_dynamic_symbol (info, h))
+         if (! bfd_elf_link_record_dynamic_symbol (info, h))
            return FALSE;
        }
 
-      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
+      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h))
        {
          /* Allocate these later.  From this point on, h->plabel
             means that the plt entry is only used by a plabel.
@@ -2041,20 +1811,20 @@ allocate_plt_static (h, inf)
          /* Make an entry in the .plt section for plabel references
             that won't have a .plt entry for other reasons.  */
          s = htab->splt;
-         h->plt.offset = s->_raw_size;
-         s->_raw_size += PLT_ENTRY_SIZE;
+         h->plt.offset = s->size;
+         s->size += PLT_ENTRY_SIZE;
        }
       else
        {
          /* 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;
@@ -2064,9 +1834,7 @@ allocate_plt_static (h, inf)
    global syms.  */
 
 static bfd_boolean
-allocate_dynrelocs (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf;
+allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 {
   struct bfd_link_info *info;
   struct elf32_hppa_link_hash_table *htab;
@@ -2080,20 +1848,19 @@ allocate_dynrelocs (h, inf)
   if (h->root.type == bfd_link_hash_warning)
     h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
-  info = (struct bfd_link_info *) inf;
+  info = inf;
   htab = hppa_link_hash_table (info);
   if (htab->elf.dynamic_sections_created
       && h->plt.offset != (bfd_vma) -1
-      && !((struct elf32_hppa_link_hash_entry *) h)->pic_call
       && !((struct elf32_hppa_link_hash_entry *) h)->plabel)
     {
       /* Make an entry in the .plt section.  */
       s = htab->splt;
-      h->plt.offset = s->_raw_size;
-      s->_raw_size += PLT_ENTRY_SIZE;
+      h->plt.offset = s->size;
+      s->size += PLT_ENTRY_SIZE;
 
       /* We also need to make an entry in the .rela.plt section.  */
-      htab->srelplt->_raw_size += sizeof (Elf32_External_Rela);
+      htab->srelplt->size += sizeof (Elf32_External_Rela);
       htab->need_plt_stub = 1;
     }
 
@@ -2102,22 +1869,22 @@ allocate_dynrelocs (h, 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_elf32_link_record_dynamic_symbol (info, h))
+         if (! bfd_elf_link_record_dynamic_symbol (info, h))
            return FALSE;
        }
 
       s = htab->sgot;
-      h->got.offset = s->_raw_size;
-      s->_raw_size += GOT_ENTRY_SIZE;
+      h->got.offset = s->size;
+      s->size += GOT_ENTRY_SIZE;
       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->_raw_size += sizeof (Elf32_External_Rela);
+         htab->srelgot->size += sizeof (Elf32_External_Rela);
        }
     }
   else
@@ -2135,9 +1902,7 @@ allocate_dynrelocs (h, inf)
   if (info->shared)
     {
 #if RELATIVE_DYNRELOCS
-      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
-         && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
-             || info->symbolic))
+      if (SYMBOL_CALLS_LOCAL (info, h))
        {
          struct elf32_hppa_dyn_reloc_entry **pp;
 
@@ -2152,15 +1917,22 @@ allocate_dynrelocs (h, inf)
            }
        }
 #endif
+
+      /* 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;
     }
   else
     {
       /* 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
-         && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-              && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+      if (!h->non_got_ref
+         && ((ELIMINATE_COPY_RELOCS
+              && 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))))
@@ -2168,10 +1940,10 @@ allocate_dynrelocs (h, 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_elf32_link_record_dynamic_symbol (info, h))
+             if (! bfd_elf_link_record_dynamic_symbol (info, h))
                return FALSE;
            }
 
@@ -2191,7 +1963,7 @@ allocate_dynrelocs (h, inf)
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
       asection *sreloc = elf_section_data (p->sec)->sreloc;
-      sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela);
+      sreloc->size += p->count * sizeof (Elf32_External_Rela);
     }
 
   return TRUE;
@@ -2205,15 +1977,14 @@ allocate_dynrelocs (h, inf)
    elf_adjust_dynamic_symbol.  */
 
 static bfd_boolean
-clobber_millicode_symbols (h, info)
-     struct elf_link_hash_entry *h;
-     struct bfd_link_info *info;
+clobber_millicode_symbols (struct elf_link_hash_entry *h,
+                          struct bfd_link_info *info)
 {
   if (h->root.type == bfd_link_hash_warning)
     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);
     }
@@ -2223,9 +1994,7 @@ clobber_millicode_symbols (h, info)
 /* Find any dynamic relocs that apply to read-only sections.  */
 
 static bfd_boolean
-readonly_dynrelocs (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf;
+readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 {
   struct elf32_hppa_link_hash_entry *eh;
   struct elf32_hppa_dyn_reloc_entry *p;
@@ -2240,7 +2009,7 @@ readonly_dynrelocs (h, inf)
 
       if (s != NULL && (s->flags & SEC_READONLY) != 0)
        {
-         struct bfd_link_info *info = (struct bfd_link_info *) inf;
+         struct bfd_link_info *info = inf;
 
          info->flags |= DF_TEXTREL;
 
@@ -2254,9 +2023,8 @@ readonly_dynrelocs (h, inf)
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
-elf32_hppa_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
+elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+                                 struct bfd_link_info *info)
 {
   struct elf32_hppa_link_hash_table *htab;
   bfd *dynobj;
@@ -2272,12 +2040,12 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
   if (htab->elf.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          if (s == NULL)
            abort ();
-         s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
+         s->size = sizeof ELF_DYNAMIC_INTERPRETER;
          s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
        }
 
@@ -2286,14 +2054,6 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
                              clobber_millicode_symbols,
                              info);
     }
-  else
-    {
-      /* Run through the function symbols, looking for any that are
-        PIC, and mark them as needing .plt entries so that %r19 will
-        be set up.  */
-      if (! info->shared)
-       elf_link_hash_traverse (&htab->elf, mark_PIC_calls, (PTR) info);
-    }
 
   /* Set up .got and .plt offsets for local syms, and space for local
      dynamic relocs.  */
@@ -2330,7 +2090,7 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
              else if (p->count != 0)
                {
                  srel = elf_section_data (p->sec)->sreloc;
-                 srel->_raw_size += p->count * sizeof (Elf32_External_Rela);
+                 srel->size += p->count * sizeof (Elf32_External_Rela);
                  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
                    info->flags |= DF_TEXTREL;
                }
@@ -2350,10 +2110,10 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
        {
          if (*local_got > 0)
            {
-             *local_got = s->_raw_size;
-             s->_raw_size += GOT_ENTRY_SIZE;
+             *local_got = s->size;
+             s->size += GOT_ENTRY_SIZE;
              if (info->shared)
-               srel->_raw_size += sizeof (Elf32_External_Rela);
+               srel->size += sizeof (Elf32_External_Rela);
            }
          else
            *local_got = (bfd_vma) -1;
@@ -2375,10 +2135,10 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
            {
              if (*local_plt > 0)
                {
-                 *local_plt = s->_raw_size;
-                 s->_raw_size += PLT_ENTRY_SIZE;
+                 *local_plt = s->size;
+                 s->size += PLT_ENTRY_SIZE;
                  if (info->shared)
-                   srel->_raw_size += sizeof (Elf32_External_Rela);
+                   srel->size += sizeof (Elf32_External_Rela);
                }
              else
                *local_plt = (bfd_vma) -1;
@@ -2389,11 +2149,11 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
   /* Do all the .plt entries without relocs first.  The dynamic linker
      uses the last .plt reloc to find the end of the .plt (and hence
      the start of the .got) for lazy linking.  */
-  elf_link_hash_traverse (&htab->elf, allocate_plt_static, (PTR) info);
+  elf_link_hash_traverse (&htab->elf, allocate_plt_static, info);
 
   /* Allocate global sym .plt and .got entries, and space for global
      sym dynamic relocs.  */
-  elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
+  elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
 
   /* The check_relocs and adjust_dynamic_symbol entry points have
      determined the sizes of the various dynamic sections.  Allocate
@@ -2418,14 +2178,14 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
              if (gotalign > pltalign)
                bfd_set_section_alignment (dynobj, s, gotalign);
              mask = ((bfd_size_type) 1 << gotalign) - 1;
-             s->_raw_size = (s->_raw_size + sizeof (plt_stub) + mask) & ~mask;
+             s->size = (s->size + sizeof (plt_stub) + mask) & ~mask;
            }
        }
       else if (s == htab->sgot)
        ;
       else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
        {
-         if (s->_raw_size != 0)
+         if (s->size != 0)
            {
              /* Remember whether there are any reloc sections other
                 than .rela.plt.  */
@@ -2443,7 +2203,7 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
          continue;
        }
 
-      if (s->_raw_size == 0)
+      if (s->size == 0)
        {
          /* If we don't need this section, strip it from the
             output file.  This is mostly to handle .rela.bss and
@@ -2460,8 +2220,8 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
 
       /* Allocate memory for the section contents.  Zero it, because
         we may not fill in all the reloc sections.  */
-      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
-      if (s->contents == NULL && s->_raw_size != 0)
+      s->contents = bfd_zalloc (dynobj, s->size);
+      if (s->contents == NULL && s->size != 0)
        return FALSE;
     }
 
@@ -2472,7 +2232,7 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
         communicate the LTP value of a load module to the dynamic
         linker.  */
 #define add_dynamic_entry(TAG, VAL) \
-  bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+  _bfd_elf_add_dynamic_entry (info, TAG, VAL)
 
       if (!add_dynamic_entry (DT_PLTGOT, 0))
        return FALSE;
@@ -2488,7 +2248,7 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
            return FALSE;
        }
 
-      if (htab->srelplt->_raw_size != 0)
+      if (htab->srelplt->size != 0)
        {
          if (!add_dynamic_entry (DT_PLTRELSZ, 0)
              || !add_dynamic_entry (DT_PLTREL, DT_RELA)
@@ -2506,8 +2266,7 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
          /* If any dynamic relocs apply to a read-only section,
             then we need a DT_TEXTREL entry.  */
          if ((info->flags & DF_TEXTREL) == 0)
-           elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
-                                   (PTR) info);
+           elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info);
 
          if ((info->flags & DF_TEXTREL) != 0)
            {
@@ -2528,9 +2287,7 @@ elf32_hppa_size_dynamic_sections (output_bfd, info)
    0 when no stubs will be needed, and 1 on success.  */
 
 int
-elf32_hppa_setup_section_lists (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+elf32_hppa_setup_section_lists (bfd *output_bfd, struct bfd_link_info *info)
 {
   bfd *input_bfd;
   unsigned int bfd_count;
@@ -2540,9 +2297,6 @@ elf32_hppa_setup_section_lists (output_bfd, info)
   bfd_size_type amt;
   struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info);
 
-  if (htab->elf.root.creator->flavour != bfd_target_elf_flavour)
-    return 0;
-
   /* Count the number of input BFDs and find the top input section id.  */
   for (input_bfd = info->input_bfds, bfd_count = 0, top_id = 0;
        input_bfd != NULL;
@@ -2560,7 +2314,7 @@ elf32_hppa_setup_section_lists (output_bfd, info)
   htab->bfd_count = bfd_count;
 
   amt = sizeof (struct map_stub) * (top_id + 1);
-  htab->stub_group = (struct map_stub *) bfd_zmalloc (amt);
+  htab->stub_group = bfd_zmalloc (amt);
   if (htab->stub_group == NULL)
     return -1;
 
@@ -2577,7 +2331,7 @@ elf32_hppa_setup_section_lists (output_bfd, info)
 
   htab->top_index = top_index;
   amt = sizeof (asection *) * (top_index + 1);
-  input_list = (asection **) bfd_malloc (amt);
+  input_list = bfd_malloc (amt);
   htab->input_list = input_list;
   if (input_list == NULL)
     return -1;
@@ -2606,9 +2360,7 @@ elf32_hppa_setup_section_lists (output_bfd, info)
    we may insert linker stubs.  */
 
 void
-elf32_hppa_next_input_section (info, isec)
-     struct bfd_link_info *info;
-     asection *isec;
+elf32_hppa_next_input_section (struct bfd_link_info *info, asection *isec)
 {
   struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info);
 
@@ -2635,10 +2387,9 @@ elf32_hppa_next_input_section (info, isec)
    the middle of a function is not a good idea.  */
 
 static void
-group_sections (htab, stub_group_size, stubs_always_before_branch)
-     struct elf32_hppa_link_hash_table *htab;
-     bfd_size_type stub_group_size;
-     bfd_boolean stubs_always_before_branch;
+group_sections (struct elf32_hppa_link_hash_table *htab,
+               bfd_size_type stub_group_size,
+               bfd_boolean stubs_always_before_branch)
 {
   asection **list = htab->input_list + htab->top_index;
   do
@@ -2654,10 +2405,7 @@ group_sections (htab, stub_group_size, stubs_always_before_branch)
          bfd_boolean big_sec;
 
          curr = tail;
-         if (tail->_cooked_size)
-           total = tail->_cooked_size;
-         else
-           total = tail->_raw_size;
+         total = tail->size;
          big_sec = total >= stub_group_size;
 
          while ((prev = PREV_SEC (curr)) != NULL
@@ -2716,10 +2464,7 @@ group_sections (htab, stub_group_size, stubs_always_before_branch)
    Returns -1 on error, 1 if export stubs created, 0 otherwise.  */
 
 static int
-get_local_syms (output_bfd, input_bfd, info)
-     bfd *output_bfd;
-     bfd *input_bfd;
-     struct bfd_link_info *info;
+get_local_syms (bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *info)
 {
   unsigned int bfd_indx;
   Elf_Internal_Sym *local_syms, **all_local_syms;
@@ -2730,7 +2475,7 @@ get_local_syms (output_bfd, input_bfd, info)
      we need to read in the local symbols in parallel and save them for
      later use; so hold pointers to the local symbols in an array.  */
   bfd_size_type amt = sizeof (Elf_Internal_Sym *) * htab->bfd_count;
-  all_local_syms = (Elf_Internal_Sym **) bfd_zmalloc (amt);
+  all_local_syms = bfd_zmalloc (amt);
   htab->all_local_syms = all_local_syms;
   if (all_local_syms == NULL)
     return -1;
@@ -2798,8 +2543,8 @@ get_local_syms (output_bfd, input_bfd, 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;
@@ -2825,8 +2570,8 @@ get_local_syms (output_bfd, input_bfd, 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);
                    }
                }
@@ -2844,15 +2589,11 @@ get_local_syms (output_bfd, input_bfd, info)
    instruction.  */
 
 bfd_boolean
-elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
-                      add_stub_section, layout_sections_again)
-     bfd *output_bfd;
-     bfd *stub_bfd;
-     struct bfd_link_info *info;
-     bfd_boolean multi_subspace;
-     bfd_signed_vma group_size;
-     asection * (*add_stub_section) PARAMS ((const char *, asection *));
-     void (*layout_sections_again) PARAMS ((void));
+elf32_hppa_size_stubs
+  (bfd *output_bfd, bfd *stub_bfd, struct bfd_link_info *info,
+   bfd_boolean multi_subspace, bfd_signed_vma group_size,
+   asection * (*add_stub_section) (const char *, asection *),
+   void (*layout_sections_again) (void))
 {
   bfd_size_type stub_group_size;
   bfd_boolean stubs_always_before_branch;
@@ -2950,9 +2691,8 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
 
              /* Get the relocs.  */
              internal_relocs
-               = _bfd_elf32_link_read_relocs (input_bfd, section, NULL,
-                                              (Elf_Internal_Rela *) NULL,
-                                              info->keep_memory);
+               = _bfd_elf_link_read_relocs (input_bfd, section, NULL, NULL,
+                                            info->keep_memory);
              if (internal_relocs == NULL)
                goto error_ret_free_local;
 
@@ -3041,8 +2781,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
                        }
                      else if (hash->elf.root.type == bfd_link_hash_undefined)
                        {
-                         if (! (info->shared
-                                && !info->no_undefined
+                         if (! (info->unresolved_syms_in_objects == RM_IGNORE
                                 && (ELF_ST_VISIBILITY (hash->elf.other)
                                     == STV_DEFAULT)
                                 && hash->elf.type != STT_PARISC_MILLI))
@@ -3057,7 +2796,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
 
                  /* Determine what (if any) linker stub is needed.  */
                  stub_type = hppa_type_of_stub (section, irela, hash,
-                                                destination);
+                                                destination, info);
                  if (stub_type == hppa_stub_none)
                    continue;
 
@@ -3114,10 +2853,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
       for (stub_sec = htab->stub_bfd->sections;
           stub_sec != NULL;
           stub_sec = stub_sec->next)
-       {
-         stub_sec->_raw_size = 0;
-         stub_sec->_cooked_size = 0;
-       }
+       stub_sec->size = 0;
 
       bfd_hash_traverse (&htab->stub_hash_table, hppa_size_one_stub, htab);
 
@@ -3138,9 +2874,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
    stubs to provide a value for __gp.  */
 
 bfd_boolean
-elf32_hppa_set_gp (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+elf32_hppa_set_gp (bfd *abfd, struct bfd_link_info *info)
 {
   struct bfd_link_hash_entry *h;
   asection *sec = NULL;
@@ -3159,21 +2893,8 @@ elf32_hppa_set_gp (abfd, info)
     }
   else
     {
-      asection *splt;
-      asection *sgot;
-
-      if (htab->elf.root.creator->flavour == bfd_target_elf_flavour)
-       {
-         splt = htab->splt;
-         sgot = htab->sgot;
-       }
-      else
-       {
-         /* If we're not elf, look up the output sections in the
-            hope we may actually find them.  */
-         splt = bfd_get_section_by_name (abfd, ".plt");
-         sgot = bfd_get_section_by_name (abfd, ".got");
-       }
+      asection *splt = bfd_get_section_by_name (abfd, ".plt");
+      asection *sgot = bfd_get_section_by_name (abfd, ".got");
 
       /* Choose to point our LTP at, in this order, one of .plt, .got,
         or .data, if these sections exist.  In the case of choosing
@@ -3183,11 +2904,12 @@ elf32_hppa_set_gp (abfd, 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->_raw_size;
-         if (gp_val > 0x2000 || (sgot && sgot->_raw_size > 0x2000))
+         gp_val = sec->size;
+         if (gp_val > 0x2000 || (sgot && sgot->size > 0x2000))
            {
              gp_val = 0x2000;
            }
@@ -3197,10 +2919,13 @@ elf32_hppa_set_gp (abfd, info)
          sec = sgot;
          if (sec != NULL)
            {
-             /* We know we don't have a .plt.  If .got is large,
-                offset our LTP.  */
-             if (sec->_raw_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
            {
@@ -3234,8 +2959,7 @@ elf32_hppa_set_gp (abfd, info)
    linker.  */
 
 bfd_boolean
-elf32_hppa_build_stubs (info)
-     struct bfd_link_info *info;
+elf32_hppa_build_stubs (struct bfd_link_info *info)
 {
   asection *stub_sec;
   struct bfd_hash_table *table;
@@ -3250,11 +2974,11 @@ elf32_hppa_build_stubs (info)
       bfd_size_type size;
 
       /* Allocate memory to hold the linker stubs.  */
-      size = stub_sec->_raw_size;
-      stub_sec->contents = (unsigned char *) bfd_zalloc (htab->stub_bfd, size);
+      size = stub_sec->size;
+      stub_sec->contents = bfd_zalloc (htab->stub_bfd, size);
       if (stub_sec->contents == NULL && size != 0)
        return FALSE;
-      stub_sec->_raw_size = 0;
+      stub_sec->size = 0;
     }
 
   /* Build the stubs as directed by the stub hash table.  */
@@ -3267,12 +2991,10 @@ elf32_hppa_build_stubs (info)
 /* Perform a final link.  */
 
 static bfd_boolean
-elf32_hppa_final_link (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+elf32_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
 {
   /* Invoke the regular ELF linker to do all the work.  */
-  if (!bfd_elf32_bfd_final_link (abfd, info))
+  if (!bfd_elf_final_link (abfd, info))
     return FALSE;
 
   /* If we're producing a final executable, sort the contents of the
@@ -3283,10 +3005,9 @@ elf32_hppa_final_link (abfd, info)
 /* Record the lowest address for the data and text segments.  */
 
 static void
-hppa_record_segment_addr (abfd, section, data)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *section;
-     PTR data;
+hppa_record_segment_addr (bfd *abfd ATTRIBUTE_UNUSED,
+                         asection *section,
+                         void *data)
 {
   struct elf32_hppa_link_hash_table *htab;
 
@@ -3312,17 +3033,18 @@ hppa_record_segment_addr (abfd, section, data)
 /* Perform a relocation as part of a final link.  */
 
 static bfd_reloc_status_type
-final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h)
-     asection *input_section;
-     bfd_byte *contents;
-     const Elf_Internal_Rela *rel;
-     bfd_vma value;
-     struct elf32_hppa_link_hash_table *htab;
-     asection *sym_sec;
-     struct elf32_hppa_link_hash_entry *h;
+final_link_relocate (asection *input_section,
+                    bfd_byte *contents,
+                    const Elf_Internal_Rela *rel,
+                    bfd_vma value,
+                    struct elf32_hppa_link_hash_table *htab,
+                    asection *sym_sec,
+                    struct elf32_hppa_link_hash_entry *h,
+                    struct bfd_link_info *info)
 {
   int insn;
   unsigned int r_type = ELF32_R_TYPE (rel->r_info);
+  unsigned int orig_r_type = r_type;
   reloc_howto_type *howto = elf_hppa_howto_table + r_type;
   int r_format = howto->bitsize;
   enum hppa_reloc_field_selector_type_alt r_field;
@@ -3345,6 +3067,26 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h)
              input_section->output_offset +
              input_section->output_section->vma);
 
+  /* If we are not building a shared library, convert DLTIND relocs to
+     DPREL relocs.  */
+  if (!info->shared)
+    {
+      switch (r_type)
+       {
+         case R_PARISC_DLTIND21L:
+           r_type = R_PARISC_DPREL21L;
+           break;
+
+         case R_PARISC_DLTIND14R:
+           r_type = R_PARISC_DPREL14R;
+           break;
+
+         case R_PARISC_DLTIND14F:
+           r_type = R_PARISC_DPREL14F;
+           break;
+       }
+    }
+
   switch (r_type)
     {
     case R_PARISC_PCREL12F:
@@ -3356,8 +3098,11 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h)
          || sym_sec->output_section == NULL
          || (h != NULL
              && h->elf.plt.offset != (bfd_vma) -1
-             && (h->elf.dynindx != -1 || h->pic_call)
-             && !h->plabel))
+             && h->elf.dynindx != -1
+             && !h->plabel
+             && (info->shared
+                 || !h->elf.def_regular
+                 || h->elf.root.type == bfd_link_hash_defweak)))
        {
          stub_entry = hppa_get_stub_entry (input_section, sym_sec,
                                            h, rel, htab);
@@ -3389,6 +3134,7 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h)
     case R_PARISC_PCREL17R:
     case R_PARISC_PCREL14R:
     case R_PARISC_PCREL14F:
+    case R_PARISC_PCREL32:
       /* Make it a pc relative offset.  */
       value -= location;
       addend -= 8;
@@ -3397,6 +3143,38 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h)
     case R_PARISC_DPREL21L:
     case R_PARISC_DPREL14R:
     case R_PARISC_DPREL14F:
+      /* Convert instructions that use the linkage table pointer (r19) to
+        instructions that use the global data pointer (dp).  This is the
+        most efficient way of using PIC code in an incomplete executable,
+        but the user must follow the standard runtime conventions for
+        accessing data for this to work.  */
+      if (orig_r_type == R_PARISC_DLTIND21L)
+       {
+         /* Convert addil instructions if the original reloc was a
+            DLTIND21L.  GCC sometimes uses a register other than r19 for
+            the operation, so we must convert any addil instruction
+            that uses this relocation.  */
+         if ((insn & 0xfc000000) == ((int) OP_ADDIL << 26))
+           insn = ADDIL_DP;
+         else
+           /* We must have a ldil instruction.  It's too hard to find
+              and convert the associated add instruction, so issue an
+              error.  */
+           (*_bfd_error_handler)
+             (_("%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);
+       }
+      else if (orig_r_type == R_PARISC_DLTIND14F)
+       {
+         /* This must be a format 1 load/store.  Change the base
+            register to dp.  */
+         insn = (insn & 0xfc1ffff) | (27 << 21);
+       }
+
     /* For all the DP relative relocations, we need to examine the symbol's
        section.  If it has no section or if it's a code section, then
        "data pointer relative" makes no sense.  In that case we don't
@@ -3413,9 +3191,9 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h)
              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
@@ -3450,6 +3228,7 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h)
     case R_PARISC_DIR17F:
     case R_PARISC_PCREL17C:
     case R_PARISC_PCREL14F:
+    case R_PARISC_PCREL32:
     case R_PARISC_DPREL14F:
     case R_PARISC_PLABEL32:
     case R_PARISC_DLTIND14F:
@@ -3535,9 +3314,9 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h)
       && 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);
@@ -3576,16 +3355,14 @@ final_link_relocate (input_section, contents, rel, value, htab, sym_sec, h)
 /* Relocate an HPPA ELF section.  */
 
 static bfd_boolean
-elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
-                            contents, relocs, local_syms, local_sections)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *relocs;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
+elf32_hppa_relocate_section (bfd *output_bfd,
+                            struct bfd_link_info *info,
+                            bfd *input_bfd,
+                            asection *input_section,
+                            bfd_byte *contents,
+                            Elf_Internal_Rela *relocs,
+                            Elf_Internal_Sym *local_syms,
+                            asection **local_sections)
 {
   bfd_vma *local_got_offsets;
   struct elf32_hppa_link_hash_table *htab;
@@ -3593,7 +3370,7 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
   Elf_Internal_Rela *rel;
   Elf_Internal_Rela *relend;
 
-  if (info->relocateable)
+  if (info->relocatable)
     return TRUE;
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
@@ -3638,52 +3415,36 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
          /* This is a local symbol, h defaults to NULL.  */
          sym = local_syms + r_symndx;
          sym_sec = local_sections[r_symndx];
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sym_sec, rel);
        }
       else
        {
-         int indx;
-
-         /* It's a global; Find its entry in the link hash.  */
-         indx = r_symndx - symtab_hdr->sh_info;
-         h = ((struct elf32_hppa_link_hash_entry *)
-              elf_sym_hashes (input_bfd)[indx]);
-         while (h->elf.root.type == bfd_link_hash_indirect
-                || h->elf.root.type == bfd_link_hash_warning)
-           h = (struct elf32_hppa_link_hash_entry *) h->elf.root.u.i.link;
-
-         relocation = 0;
-         if (h->elf.root.type == bfd_link_hash_defined
-             || h->elf.root.type == bfd_link_hash_defweak)
+         struct elf_link_hash_entry *hh;
+         bfd_boolean unresolved_reloc;
+         struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
+
+         RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+                                  r_symndx, symtab_hdr, sym_hashes,
+                                  hh, sym_sec, relocation,
+                                  unresolved_reloc, warned_undef);
+
+         if (relocation == 0
+             && hh->root.type != bfd_link_hash_defined
+             && hh->root.type != bfd_link_hash_defweak
+             && hh->root.type != bfd_link_hash_undefweak)
            {
-             sym_sec = h->elf.root.u.def.section;
-             /* If sym_sec->output_section is NULL, then it's a
-                symbol defined in a shared library.  */
-             if (sym_sec->output_section != NULL)
-               relocation = (h->elf.root.u.def.value
-                             + sym_sec->output_offset
-                             + sym_sec->output_section->vma);
-           }
-         else if (h->elf.root.type == bfd_link_hash_undefweak)
-           ;
-         else if (info->shared && !info->no_undefined
-                  && ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
-                  && h->elf.type != STT_PARISC_MILLI)
-           {
-             if (!((*info->callbacks->undefined_symbol)
-                   (info, h->elf.root.root.string, input_bfd,
-                    input_section, rel->r_offset, FALSE)))
-               return FALSE;
-             warned_undef = TRUE;
-           }
-         else
-           {
-             if (!((*info->callbacks->undefined_symbol)
-                   (info, h->elf.root.root.string, input_bfd,
-                    input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             warned_undef = TRUE;
+             if (info->unresolved_syms_in_objects == RM_IGNORE
+                 && ELF_ST_VISIBILITY (hh->other) == STV_DEFAULT
+                 && hh->type == STT_PARISC_MILLI)
+               {
+                 if (! info->callbacks->undefined_symbol
+                     (info, hh->root.root.string, input_bfd,
+                      input_section, rel->r_offset, FALSE))
+                   return FALSE;
+                 warned_undef = TRUE;
+               }
            }
+         h = (struct elf32_hppa_link_hash_entry *) hh;
        }
 
       /* Do any required modifications to the relocation value, and
@@ -3707,7 +3468,8 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
 
                off = h->elf.got.offset;
                dyn = htab->elf.dynamic_sections_created;
-               if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, &h->elf))
+               if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared,
+                                                      &h->elf))
                  {
                    /* If we aren't going to call finish_dynamic_symbol,
                       then we need to handle initialisation of the .got
@@ -3799,7 +3561,8 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
              if (h != NULL)
                {
                  off = h->elf.plt.offset;
-                 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, &h->elf))
+                 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared,
+                                                        &h->elf))
                    {
                      /* In a non-shared link, adjust_dynamic_symbols
                         isn't called for symbols forced local.  We
@@ -3916,20 +3679,18 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
             Conversely, DEF_DYNAMIC can't be used in check_relocs as
             there all files have not been loaded.  */
          if ((info->shared
+              && (h == NULL
+                  || ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
+                  || h->elf.root.type != bfd_link_hash_undefweak)
               && (IS_ABSOLUTE_RELOC (r_type)
-                  || (h != NULL
-                      && h->elf.dynindx != -1
-                      && (!info->symbolic
-                          || (h->elf.elf_link_hash_flags
-                              & ELF_LINK_HASH_DEF_REGULAR) == 0))))
+                  || !SYMBOL_CALLS_LOCAL (info, &h->elf)))
              || (!info->shared
                  && h != NULL
                  && h->elf.dynindx != -1
-                 && (h->elf.elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
-                 && (((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.non_got_ref
+                 && ((ELIMINATE_COPY_RELOCS
+                      && h->elf.def_dynamic
+                      && !h->elf.def_regular)
                      || h->elf.root.type == bfd_link_hash_undefweak
                      || h->elf.root.type == bfd_link_hash_undefined)))
            {
@@ -3961,8 +3722,7 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
                           || !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);
                }
@@ -3984,6 +3744,11 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
                      && sym_sec->output_section != NULL
                      && ! bfd_is_abs_section (sym_sec))
                    {
+                     /* Skip this relocation if the output section has
+                        been discarded.  */
+                     if (bfd_is_abs_section (sym_sec->output_section))
+                       break;
+
                      indx = elf_section_data (sym_sec->output_section)->dynindx;
                      /* We are turning this relocation into one
                         against a section symbol, so subtract out the
@@ -4016,7 +3781,7 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
        }
 
       r = final_link_relocate (input_section, contents, rel, relocation,
-                              htab, sym_sec, h);
+                              htab, sym_sec, h, info);
 
       if (r == bfd_reloc_ok)
        continue;
@@ -4041,9 +3806,9 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
          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);
@@ -4054,8 +3819,8 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
       else
        {
          if (!((*info->callbacks->reloc_overflow)
-               (info, sym_name, howto->name, (bfd_vma) 0,
-                input_bfd, input_section, rel->r_offset)))
+               (info, (h ? &h->elf.root : NULL), sym_name, howto->name,
+                (bfd_vma) 0, input_bfd, input_section, rel->r_offset)))
            return FALSE;
        }
     }
@@ -4067,13 +3832,14 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
    dynamic sections here.  */
 
 static bfd_boolean
-elf32_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
+                                 struct bfd_link_info *info,
+                                 struct elf_link_hash_entry *h,
+                                 Elf_Internal_Sym *sym)
 {
   struct elf32_hppa_link_hash_table *htab;
+  Elf_Internal_Rela rel;
+  bfd_byte *loc;
 
   htab = hppa_link_hash_table (info);
 
@@ -4101,44 +3867,28 @@ elf32_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
                      + h->root.u.def.section->output_section->vma);
        }
 
-      if (! ((struct elf32_hppa_link_hash_entry *) h)->pic_call)
+      /* Create a dynamic IPLT relocation for this entry.  */
+      rel.r_offset = (h->plt.offset
+                     + htab->splt->output_offset
+                     + htab->splt->output_section->vma);
+      if (h->dynindx != -1)
        {
-         Elf_Internal_Rela rel;
-         bfd_byte *loc;
-
-         /* Create a dynamic IPLT relocation for this entry.  */
-         rel.r_offset = (h->plt.offset
-                         + htab->splt->output_offset
-                         + htab->splt->output_section->vma);
-         if (h->dynindx != -1)
-           {
-             rel.r_info = ELF32_R_INFO (h->dynindx, R_PARISC_IPLT);
-             rel.r_addend = 0;
-           }
-         else
-           {
-             /* This symbol has been marked to become local, and is
-                used by a plabel so must be kept in the .plt.  */
-             rel.r_info = ELF32_R_INFO (0, R_PARISC_IPLT);
-             rel.r_addend = value;
-           }
-
-         loc = htab->srelplt->contents;
-         loc += htab->srelplt->reloc_count++ * sizeof (Elf32_External_Rela);
-         bfd_elf32_swap_reloca_out (htab->splt->output_section->owner,
-                                    &rel, loc);
+         rel.r_info = ELF32_R_INFO (h->dynindx, R_PARISC_IPLT);
+         rel.r_addend = 0;
        }
       else
        {
-         bfd_put_32 (htab->splt->owner,
-                     value,
-                     htab->splt->contents + h->plt.offset);
-         bfd_put_32 (htab->splt->owner,
-                     elf_gp (htab->splt->output_section->owner),
-                     htab->splt->contents + h->plt.offset + 4);
+         /* This symbol has been marked to become local, and is
+            used by a plabel so must be kept in the .plt.  */
+         rel.r_info = ELF32_R_INFO (0, R_PARISC_IPLT);
+         rel.r_addend = value;
        }
 
-      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
+      loc = htab->srelplt->contents;
+      loc += htab->srelplt->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (htab->splt->output_section->owner, &rel, loc);
+
+      if (!h->def_regular)
        {
          /* Mark the symbol as undefined, rather than as defined in
             the .plt section.  Leave the value alone.  */
@@ -4148,9 +3898,6 @@ elf32_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
 
   if (h->got.offset != (bfd_vma) -1)
     {
-      Elf_Internal_Rela rel;
-      bfd_byte *loc;
-
       /* This symbol has an entry in the global offset table.  Set it
         up.  */
 
@@ -4165,7 +3912,7 @@ elf32_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
         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
@@ -4176,8 +3923,7 @@ elf32_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
        {
          if ((h->got.offset & 1) != 0)
            abort ();
-         bfd_put_32 (output_bfd, (bfd_vma) 0,
-                     htab->sgot->contents + h->got.offset);
+         bfd_put_32 (output_bfd, 0, htab->sgot->contents + h->got.offset);
          rel.r_info = ELF32_R_INFO (h->dynindx, R_PARISC_DIR32);
          rel.r_addend = 0;
        }
@@ -4187,11 +3933,9 @@ elf32_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
       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;
-      Elf_Internal_Rela rel;
-      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -4226,8 +3970,7 @@ elf32_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
    dynamic linker, before writing them out.  */
 
 static enum elf_reloc_type_class
-elf32_hppa_reloc_type_class (rela)
-     const Elf_Internal_Rela *rela;
+elf32_hppa_reloc_type_class (const Elf_Internal_Rela *rela)
 {
   if (ELF32_R_SYM (rela->r_info) == 0)
     return reloc_class_relative;
@@ -4246,9 +3989,8 @@ elf32_hppa_reloc_type_class (rela)
 /* Finish up the dynamic sections.  */
 
 static bfd_boolean
-elf32_hppa_finish_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+elf32_hppa_finish_dynamic_sections (bfd *output_bfd,
+                                   struct bfd_link_info *info)
 {
   bfd *dynobj;
   struct elf32_hppa_link_hash_table *htab;
@@ -4267,7 +4009,7 @@ elf32_hppa_finish_dynamic_sections (output_bfd, info)
        abort ();
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
-      dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
+      dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
@@ -4292,7 +4034,7 @@ elf32_hppa_finish_dynamic_sections (output_bfd, info)
 
            case DT_PLTRELSZ:
              s = htab->srelplt;
-             dyn.d_un.d_val = s->_raw_size;
+             dyn.d_un.d_val = s->size;
              break;
 
            case DT_RELASZ:
@@ -4301,7 +4043,7 @@ elf32_hppa_finish_dynamic_sections (output_bfd, info)
              s = htab->srelplt;
              if (s == NULL)
                continue;
-             dyn.d_un.d_val -= s->_raw_size;
+             dyn.d_un.d_val -= s->size;
              break;
 
            case DT_RELA:
@@ -4313,7 +4055,7 @@ elf32_hppa_finish_dynamic_sections (output_bfd, info)
                continue;
              if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset)
                continue;
-             dyn.d_un.d_ptr += s->_raw_size;
+             dyn.d_un.d_ptr += s->size;
              break;
            }
 
@@ -4321,14 +4063,12 @@ elf32_hppa_finish_dynamic_sections (output_bfd, info)
        }
     }
 
-  if (htab->sgot != NULL && htab->sgot->_raw_size != 0)
+  if (htab->sgot != NULL && htab->sgot->size != 0)
     {
       /* Fill in the first entry in the global offset table.
         We use it to point to our dynamic section, if we have one.  */
       bfd_put_32 (output_bfd,
-                 (sdyn != NULL
-                  ? sdyn->output_section->vma + sdyn->output_offset
-                  : (bfd_vma) 0),
+                 sdyn ? sdyn->output_section->vma + sdyn->output_offset : 0,
                  htab->sgot->contents);
 
       /* The second entry is reserved for use by the dynamic linker.  */
@@ -4339,7 +4079,7 @@ elf32_hppa_finish_dynamic_sections (output_bfd, info)
        ->this_hdr.sh_entsize = GOT_ENTRY_SIZE;
     }
 
-  if (htab->splt != NULL && htab->splt->_raw_size != 0)
+  if (htab->splt != NULL && htab->splt->size != 0)
     {
       /* Set plt entry size.  */
       elf_section_data (htab->splt->output_section)
@@ -4349,12 +4089,12 @@ elf32_hppa_finish_dynamic_sections (output_bfd, info)
        {
          /* Set up the .plt stub.  */
          memcpy (htab->splt->contents
-                 + htab->splt->_raw_size - sizeof (plt_stub),
+                 + htab->splt->size - sizeof (plt_stub),
                  plt_stub, sizeof (plt_stub));
 
          if ((htab->splt->output_offset
               + htab->splt->output_section->vma
-              + htab->splt->_raw_size)
+              + htab->splt->size)
              != (htab->sgot->output_offset
                  + htab->sgot->output_section->vma))
            {
@@ -4371,9 +4111,8 @@ elf32_hppa_finish_dynamic_sections (output_bfd, info)
 /* Tweak the OSABI field of the elf header.  */
 
 static void
-elf32_hppa_post_process_headers (abfd, link_info)
-     bfd *abfd;
-     struct bfd_link_info *link_info ATTRIBUTE_UNUSED;
+elf32_hppa_post_process_headers (bfd *abfd,
+                                struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   Elf_Internal_Ehdr * i_ehdrp;
 
@@ -4383,6 +4122,10 @@ elf32_hppa_post_process_headers (abfd, link_info)
     {
       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;
@@ -4392,9 +4135,7 @@ elf32_hppa_post_process_headers (abfd, link_info)
 /* Called when writing out an object file to decide the type of a
    symbol.  */
 static int
-elf32_hppa_elf_get_symbol_type (elf_sym, type)
-     Elf_Internal_Sym *elf_sym;
-     int type;
+elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type)
 {
   if (ELF_ST_TYPE (elf_sym->st_info) == STT_PARISC_MILLI)
     return STT_PARISC_MILLI;
@@ -4412,7 +4153,6 @@ elf32_hppa_elf_get_symbol_type (elf_sym, type)
 #define bfd_elf32_bfd_final_link            elf32_hppa_final_link
 #define bfd_elf32_bfd_link_hash_table_create elf32_hppa_link_hash_table_create
 #define bfd_elf32_bfd_link_hash_table_free   elf32_hppa_link_hash_table_free
-#define elf_backend_add_symbol_hook         elf32_hppa_add_symbol_hook
 #define elf_backend_adjust_dynamic_symbol    elf32_hppa_adjust_dynamic_symbol
 #define elf_backend_copy_indirect_symbol     elf32_hppa_copy_indirect_symbol
 #define elf_backend_check_relocs            elf32_hppa_check_relocs
@@ -4455,3 +4195,10 @@ elf32_hppa_elf_get_symbol_type (elf_sym, 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.08121 seconds and 4 git commands to generate.