]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf64-ia64-vms.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / bfd / elf64-ia64-vms.c
index d14b909e4043941e579214426885c3709a9f5926..b69c9cde7f1e0cd6f124ad11e3ecfaaf2578a183 100644 (file)
@@ -1,5 +1,5 @@
 /* IA-64 support for OpenVMS
-   Copyright (C) 1998-2014 Free Software Foundation, Inc.
+   Copyright (C) 1998-2021 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -170,8 +170,9 @@ struct elf64_ia64_allocate_data
 };
 
 #define elf64_ia64_hash_table(p) \
-  (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
-  == IA64_ELF_DATA ? ((struct elf64_ia64_link_hash_table *) ((p)->hash)) : NULL)
+  ((is_elf_hash_table ((p)->hash)                                      \
+    && elf_hash_table_id (elf_hash_table (p)) == IA64_ELF_DATA)                \
+   ? (struct elf64_ia64_link_hash_table *) (p)->hash : NULL)
 
 struct elf64_ia64_vms_obj_tdata
 {
@@ -240,13 +241,24 @@ static asection *get_got
 
 /* Given a ELF reloc, return the matching HOWTO structure.  */
 
-static void
+static bfd_boolean
 elf64_ia64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
                          arelent *bfd_reloc,
                          Elf_Internal_Rela *elf_reloc)
 {
-  bfd_reloc->howto
-    = ia64_elf_lookup_howto ((unsigned int) ELF64_R_TYPE (elf_reloc->r_info));
+  unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info);
+
+  bfd_reloc->howto = ia64_elf_lookup_howto (r_type);
+  if (bfd_reloc->howto == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  return TRUE;
 }
 
 
@@ -254,18 +266,18 @@ elf64_ia64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 
 static const bfd_byte plt_full_entry[PLT_FULL_ENTRY_SIZE] =
 {
-  0x0b, 0x78, 0x00, 0x02, 0x00, 0x24,  /*   [MMI]       addl r15=0,r1;;   */
-  0x00, 0x41, 0x3c, 0x70, 0x29, 0xc0,  /*               ld8.acq r16=[r15],8*/
-  0x01, 0x08, 0x00, 0x84,              /*               mov r14=r1;;      */
-  0x11, 0x08, 0x00, 0x1e, 0x18, 0x10,  /*   [MIB]       ld8 r1=[r15]      */
-  0x60, 0x80, 0x04, 0x80, 0x03, 0x00,  /*               mov b6=r16        */
-  0x60, 0x00, 0x80, 0x00               /*               br.few b6;;       */
+  0x0b, 0x78, 0x00, 0x02, 0x00, 0x24,  /*   [MMI]      addl r15=0,r1;;   */
+  0x00, 0x41, 0x3c, 0x70, 0x29, 0xc0,  /*              ld8.acq r16=[r15],8*/
+  0x01, 0x08, 0x00, 0x84,             /*               mov r14=r1;;      */
+  0x11, 0x08, 0x00, 0x1e, 0x18, 0x10,  /*   [MIB]      ld8 r1=[r15]      */
+  0x60, 0x80, 0x04, 0x80, 0x03, 0x00,  /*              mov b6=r16        */
+  0x60, 0x00, 0x80, 0x00              /*               br.few b6;;       */
 };
 
 static const bfd_byte oor_brl[16] =
 {
-  0x05, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MLX]        nop.m 0           */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /*               brl.sptk.few tgt;;*/
+  0x05, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MLX]       nop.m 0           */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /*              brl.sptk.few tgt;;*/
   0x00, 0x00, 0x00, 0xc0
 };
 
@@ -348,7 +360,7 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
      one pass.  */
   *again = FALSE;
 
-  if (link_info->relocatable)
+  if (bfd_link_relocatable (link_info))
     (*link_info->callbacks->einfo)
       (_("%P%F: --relax and -r may not be used together\n"));
 
@@ -555,7 +567,7 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
                  ia64_elf_relax_brl (contents, roff);
 
                  irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
-                                               R_IA64_PCREL21B);
+                                              R_IA64_PCREL21B);
 
                  /* If the original relocation offset points to slot
                     1, change it to slot 2.  */
@@ -570,7 +582,7 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
          else if (ia64_elf_relax_br (contents, roff))
            {
              irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
-                                           R_IA64_PCREL60B);
+                                          R_IA64_PCREL60B);
 
              /* Make the relocation offset point to slot 1.  */
              irel->r_offset = (irel->r_offset & ~((bfd_vma) 0x3)) + 1;
@@ -582,9 +594,11 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
          if (strcmp (sec->output_section->name, ".init") == 0
              || strcmp (sec->output_section->name, ".fini") == 0)
            {
-             (*_bfd_error_handler)
-               (_("%B: Can't relax br at 0x%lx in section `%A'. Please use brl or indirect branch."),
-                sec->owner, sec, (unsigned long) roff);
+             _bfd_error_handler
+               /* xgettext:c-format */
+               (_("%pB: can't relax br at %#" PRIx64 " in section `%pA';"
+                  " please use brl or indirect branch"),
+                sec->owner, (uint64_t) roff, sec);
              bfd_set_error (bfd_error_bad_value);
              goto error_return;
            }
@@ -640,10 +654,10 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
                }
              else
                {
-                  memcpy (contents + trampoff, oor_brl, size);
-                  irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
-                                               R_IA64_PCREL60B);
-                  irel->r_offset = trampoff + 2;
+                 memcpy (contents + trampoff, oor_brl, size);
+                 irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+                                              R_IA64_PCREL60B);
+                 irel->r_offset = trampoff + 2;
                }
 
              /* Record the fixup so we don't do it again this section.  */
@@ -701,9 +715,9 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
                                          ia64_info);
          else if (r_type == R_IA64_LTOFF22X)
            {
-              /* Can't deal yet correctly with ABS symbols.  */
-              if (bfd_is_abs_section (tsec))
-                continue;
+             /* Can't deal yet correctly with ABS symbols.  */
+             if (bfd_is_abs_section (tsec))
+               continue;
 
              irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
                                           R_IA64_GPREL22);
@@ -779,13 +793,11 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
   return TRUE;
 
  error_return:
-  if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
+  if ((unsigned char *) isymbuf != symtab_hdr->contents)
     free (isymbuf);
-  if (contents != NULL
-      && elf_section_data (sec)->this_hdr.contents != contents)
+  if (elf_section_data (sec)->this_hdr.contents != contents)
     free (contents);
-  if (internal_relocs != NULL
-      && elf_section_data (sec)->relocs != internal_relocs)
+  if (elf_section_data (sec)->relocs != internal_relocs)
     free (internal_relocs);
   return FALSE;
 }
@@ -809,11 +821,10 @@ is_unwind_section_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
    flag.  */
 
 static bfd_boolean
-elf64_ia64_section_flags (flagword *flags,
-                         const Elf_Internal_Shdr *hdr)
+elf64_ia64_section_flags (const Elf_Internal_Shdr *hdr)
 {
   if (hdr->sh_flags & SHF_IA_64_SHORT)
-    *flags |= SEC_SMALL_DATA;
+    hdr->bfd_section->flags |= SEC_SMALL_DATA;
 
   return TRUE;
 }
@@ -827,7 +838,7 @@ elf64_ia64_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr,
 {
   const char *name;
 
-  name = bfd_get_section_name (abfd, sec);
+  name = bfd_section_name (sec);
 
   if (is_unwind_section_name (abfd, name))
     {
@@ -858,7 +869,7 @@ elf64_ia64_add_symbol_hook (bfd *abfd,
                            bfd_vma *valp)
 {
   if (sym->st_shndx == SHN_COMMON
-      && !info->relocatable
+      && !bfd_link_relocatable (info)
       && sym->st_size <= elf_gp_size (abfd))
     {
       /* Common symbols less than or equal to -G nn bytes are
@@ -871,6 +882,7 @@ elf64_ia64_add_symbol_hook (bfd *abfd,
          scomm = bfd_make_section_with_flags (abfd, ".scommon",
                                               (SEC_ALLOC
                                                | SEC_IS_COMMON
+                                               | SEC_SMALL_DATA
                                                | SEC_LINKER_CREATED));
          if (scomm == NULL)
            return FALSE;
@@ -975,40 +987,6 @@ elf64_ia64_local_htab_eq (const void *ptr1, const void *ptr2)
   return entry1->id == entry2->id && entry1->r_sym == entry2->r_sym;
 }
 
-/* Create the derived linker hash table.  The IA-64 ELF port uses this
-   derived hash table to keep information specific to the IA-64 ElF
-   linker (without using static variables).  */
-
-static struct bfd_link_hash_table *
-elf64_ia64_hash_table_create (bfd *abfd)
-{
-  struct elf64_ia64_link_hash_table *ret;
-
-  ret = bfd_zmalloc ((bfd_size_type) sizeof (*ret));
-  if (!ret)
-    return NULL;
-
-  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                     elf64_ia64_new_elf_hash_entry,
-                                     sizeof (struct elf64_ia64_link_hash_entry),
-                                     IA64_ELF_DATA))
-    {
-      free (ret);
-      return NULL;
-    }
-
-  ret->loc_hash_table = htab_try_create (1024, elf64_ia64_local_htab_hash,
-                                        elf64_ia64_local_htab_eq, NULL);
-  ret->loc_hash_memory = objalloc_create ();
-  if (!ret->loc_hash_table || !ret->loc_hash_memory)
-    {
-      free (ret);
-      return NULL;
-    }
-
-  return &ret->root.root;
-}
-
 /* Free the global elf64_ia64_dyn_sym_info array.  */
 
 static bfd_boolean
@@ -1021,14 +999,11 @@ elf64_ia64_global_dyn_info_free (void **xentry,
   if (entry->root.root.type == bfd_link_hash_warning)
     entry = (struct elf64_ia64_link_hash_entry *) entry->root.root.u.i.link;
 
-  if (entry->info)
-    {
-      free (entry->info);
-      entry->info = NULL;
-      entry->count = 0;
-      entry->sorted_count = 0;
-      entry->size = 0;
-    }
+  free (entry->info);
+  entry->info = NULL;
+  entry->count = 0;
+  entry->sorted_count = 0;
+  entry->size = 0;
 
   return TRUE;
 }
@@ -1042,14 +1017,11 @@ elf64_ia64_local_dyn_info_free (void **slot,
   struct elf64_ia64_local_hash_entry *entry
     = (struct elf64_ia64_local_hash_entry *) *slot;
 
-  if (entry->info)
-    {
-      free (entry->info);
-      entry->info = NULL;
-      entry->count = 0;
-      entry->sorted_count = 0;
-      entry->size = 0;
-    }
+  free (entry->info);
+  entry->info = NULL;
+  entry->count = 0;
+  entry->sorted_count = 0;
+  entry->size = 0;
 
   return TRUE;
 }
@@ -1057,10 +1029,10 @@ elf64_ia64_local_dyn_info_free (void **slot,
 /* Destroy IA-64 linker hash table.  */
 
 static void
-elf64_ia64_hash_table_free (struct bfd_link_hash_table *hash)
+elf64_ia64_link_hash_table_free (bfd *obfd)
 {
   struct elf64_ia64_link_hash_table *ia64_info
-    = (struct elf64_ia64_link_hash_table *) hash;
+    = (struct elf64_ia64_link_hash_table *) obfd->link.hash;
   if (ia64_info->loc_hash_table)
     {
       htab_traverse (ia64_info->loc_hash_table,
@@ -1071,7 +1043,42 @@ elf64_ia64_hash_table_free (struct bfd_link_hash_table *hash)
     objalloc_free ((struct objalloc *) ia64_info->loc_hash_memory);
   elf_link_hash_traverse (&ia64_info->root,
                          elf64_ia64_global_dyn_info_free, NULL);
-  _bfd_elf_link_hash_table_free (hash);
+  _bfd_elf_link_hash_table_free (obfd);
+}
+
+/* Create the derived linker hash table.  The IA-64 ELF port uses this
+   derived hash table to keep information specific to the IA-64 ElF
+   linker (without using static variables).  */
+
+static struct bfd_link_hash_table *
+elf64_ia64_hash_table_create (bfd *abfd)
+{
+  struct elf64_ia64_link_hash_table *ret;
+
+  ret = bfd_zmalloc ((bfd_size_type) sizeof (*ret));
+  if (!ret)
+    return NULL;
+
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     elf64_ia64_new_elf_hash_entry,
+                                     sizeof (struct elf64_ia64_link_hash_entry),
+                                     IA64_ELF_DATA))
+    {
+      free (ret);
+      return NULL;
+    }
+
+  ret->loc_hash_table = htab_try_create (1024, elf64_ia64_local_htab_hash,
+                                        elf64_ia64_local_htab_eq, NULL);
+  ret->loc_hash_memory = objalloc_create ();
+  if (!ret->loc_hash_table || !ret->loc_hash_memory)
+    {
+      elf64_ia64_link_hash_table_free (abfd);
+      return NULL;
+    }
+  ret->root.root.hash_table_free = elf64_ia64_link_hash_table_free;
+
+  return &ret->root.root;
 }
 
 /* Traverse both local and global hash tables.  */
@@ -1142,7 +1149,7 @@ elf64_ia64_dyn_sym_traverse (struct elf64_ia64_link_hash_table *ia64_info,
 
 static bfd_boolean
 create_ia64_vms_notes (bfd *abfd, struct bfd_link_info *info,
-                       unsigned int time_hi, unsigned int time_lo)
+                      unsigned int time_hi, unsigned int time_lo)
 {
 #define NBR_NOTES 7
   Elf_Internal_Note notes[NBR_NOTES];
@@ -1272,12 +1279,12 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
   s = bfd_make_section_anyway_with_flags (abfd, ".dynamic",
                                          flags | SEC_READONLY);
   if (s == NULL
-      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+      || !bfd_set_section_alignment (s, bed->s->log_file_align))
     return FALSE;
 
   s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags | SEC_READONLY);
   if (s == NULL
-      || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+      || !bfd_set_section_alignment (s, bed->plt_alignment))
     return FALSE;
   ia64_info->root.splt = s;
 
@@ -1293,7 +1300,7 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
                                           | SEC_IN_MEMORY
                                           | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, 0))
+      || !bfd_set_section_alignment (s, 0))
     return FALSE;
 
   /* Create a fixup section.  */
@@ -1303,7 +1310,7 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
                                           | SEC_IN_MEMORY
                                           | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, 3))
+      || !bfd_set_section_alignment (s, 3))
     return FALSE;
   ia64_info->fixups_sec = s;
 
@@ -1314,19 +1321,19 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
                                           | SEC_IN_MEMORY
                                           | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, 3))
+      || !bfd_set_section_alignment (s, 3))
     return FALSE;
   s->size = sizeof (struct elf64_vms_transfer);
   ia64_info->transfer_sec = s;
 
   /* Create note section.  */
   s = bfd_make_section_anyway_with_flags (abfd, ".vms.note",
-                                          (SEC_LINKER_CREATED
-                                           | SEC_HAS_CONTENTS
-                                           | SEC_IN_MEMORY
-                                           | SEC_READONLY));
+                                         (SEC_LINKER_CREATED
+                                          | SEC_HAS_CONTENTS
+                                          | SEC_IN_MEMORY
+                                          | SEC_READONLY));
   if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, 3))
+      || !bfd_set_section_alignment (s, 3))
     return FALSE;
   ia64_info->note_sec = s;
 
@@ -1610,7 +1617,7 @@ get_dyn_sym_info (struct elf64_ia64_link_hash_table *ia64_info,
   if (create)
     {
       /* When we create the array, we don't check for duplicates,
-         except in the previously sorted section if one exists, and
+        except in the previously sorted section if one exists, and
         against the last inserted entry.  This allows insertions to
         be fast.  */
       if (info)
@@ -1660,7 +1667,7 @@ get_dyn_sym_info (struct elf64_ia64_link_hash_table *ia64_info,
       *size_p = size;
       *info_p = info;
 
-has_space:
+    has_space:
       /* Append the new one to the array.  */
       dyn_i = info + count;
       memset (dyn_i, 0, sizeof (*dyn_i));
@@ -1724,8 +1731,8 @@ get_got (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
       got = bfd_make_section_anyway_with_flags (dynobj, ".got",
                                                flags | SEC_SMALL_DATA);
       if (got == NULL
-          || !bfd_set_section_alignment (dynobj, got, 3))
-        return NULL;
+         || !bfd_set_section_alignment (got, 3))
+       return NULL;
       ia64_info->root.sgot = got;
     }
 
@@ -1756,11 +1763,11 @@ get_fptr (bfd *abfd, struct bfd_link_info *info,
                                                  | SEC_LOAD
                                                  | SEC_HAS_CONTENTS
                                                  | SEC_IN_MEMORY
-                                                 | (info->pie ? 0
+                                                 | (bfd_link_pie (info) ? 0
                                                     : SEC_READONLY)
                                                  | SEC_LINKER_CREATED));
       if (!fptr
-         || !bfd_set_section_alignment (dynobj, fptr, 4))
+         || !bfd_set_section_alignment (fptr, 4))
        {
          BFD_ASSERT (0);
          return NULL;
@@ -1768,7 +1775,7 @@ get_fptr (bfd *abfd, struct bfd_link_info *info,
 
       ia64_info->fptr_sec = fptr;
 
-      if (info->pie)
+      if (bfd_link_pie (info))
        {
          asection *fptr_rel;
          fptr_rel = bfd_make_section_anyway_with_flags (dynobj, ".rela.opd",
@@ -1778,7 +1785,7 @@ get_fptr (bfd *abfd, struct bfd_link_info *info,
                                                          | SEC_LINKER_CREATED
                                                          | SEC_READONLY));
          if (fptr_rel == NULL
-             || !bfd_set_section_alignment (dynobj, fptr_rel, 3))
+             || !bfd_set_section_alignment (fptr_rel, 3))
            {
              BFD_ASSERT (0);
              return NULL;
@@ -1813,7 +1820,7 @@ get_pltoff (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
                                                    | SEC_SMALL_DATA
                                                    | SEC_LINKER_CREATED));
       if (!pltoff
-         || !bfd_set_section_alignment (dynobj, pltoff, 4))
+         || !bfd_set_section_alignment (pltoff, 4))
        {
          BFD_ASSERT (0);
          return NULL;
@@ -1841,11 +1848,9 @@ get_reloc_section (bfd *abfd,
     return NULL;
 
   BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela")
-              && strcmp (bfd_get_section_name (abfd, sec),
-                         srel_name+5) == 0)
+              && strcmp (bfd_section_name (sec), srel_name+5) == 0)
              || (CONST_STRNEQ (srel_name, ".rel")
-                 && strcmp (bfd_get_section_name (abfd, sec),
-                            srel_name+4) == 0));
+                 && strcmp (bfd_section_name (sec), srel_name+4) == 0));
 
   dynobj = ia64_info->root.dynobj;
   if (!dynobj)
@@ -1861,7 +1866,7 @@ get_reloc_section (bfd *abfd,
                                                  | SEC_LINKER_CREATED
                                                  | SEC_READONLY));
       if (srel == NULL
-         || !bfd_set_section_alignment (dynobj, srel, 3))
+         || !bfd_set_section_alignment (srel, 3))
        return NULL;
     }
 
@@ -1921,7 +1926,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
   unsigned long r_symndx;
   bfd_boolean maybe_dynamic;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
@@ -1954,7 +1959,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
         locally or externally defined, as not all of the input files
         have yet been processed.  Do something with what we know, as
         this may help reduce memory usage and processing time later.  */
-      maybe_dynamic = (h && ((!info->executable
+      maybe_dynamic = (h && ((!bfd_link_executable (info)
                              && (!SYMBOLIC_BIND (info, h)
                                  || info->unresolved_syms_in_shared_libs == RM_IGNORE))
                             || !h->def_regular
@@ -1974,12 +1979,12 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_IA64_DTPMOD64MSB:
        case R_IA64_DTPMOD64LSB:
        case R_IA64_LTOFF_DTPMOD22:
-          abort ();
+         abort ();
          break;
 
        case R_IA64_IPLTMSB:
        case R_IA64_IPLTLSB:
-          break;
+         break;
 
        case R_IA64_LTOFF_FPTR22:
        case R_IA64_LTOFF_FPTR64I:
@@ -1995,7 +2000,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_IA64_FPTR32LSB:
        case R_IA64_FPTR64MSB:
        case R_IA64_FPTR64LSB:
-         if (info->shared || h)
+         if (bfd_link_pic (info) || h)
            need_entry = NEED_FPTR | NEED_DYNREL;
          else
            need_entry = NEED_FPTR;
@@ -2029,7 +2034,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
          break;
 
        case R_IA64_PCREL21B:
-        case R_IA64_PCREL60B:
+       case R_IA64_PCREL60B:
          /* Depending on where this symbol is defined, we may or may not
             need a full plt entry.  Only skip if we know we'll not need
             the entry -- static or symbolic, and the symbol definition
@@ -2046,7 +2051,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_IA64_DIR64MSB:
        case R_IA64_DIR64LSB:
          /* Shared objects will always need at least a REL relocation.  */
-         if (info->shared || maybe_dynamic)
+         if (bfd_link_pic (info) || maybe_dynamic)
            need_entry = NEED_DYNREL;
          break;
 
@@ -2096,7 +2101,6 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
          /* PR15323, ref flags aren't set for references in the same
             object.  */
-         h->root.non_ir_ref = 1;
          h->ref_regular = 1;
        }
       else
@@ -2106,7 +2110,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
         locally or externally defined, as not all of the input files
         have yet been processed.  Do something with what we know, as
         this may help reduce memory usage and processing time later.  */
-      maybe_dynamic = (h && ((!info->executable
+      maybe_dynamic = (h && ((!bfd_link_executable (info)
                              && (!SYMBOLIC_BIND (info, h)
                                  || info->unresolved_syms_in_shared_libs == RM_IGNORE))
                             || !h->def_regular
@@ -2126,7 +2130,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_IA64_DTPMOD64MSB:
        case R_IA64_DTPMOD64LSB:
        case R_IA64_LTOFF_DTPMOD22:
-          abort ();
+         abort ();
          break;
 
        case R_IA64_LTOFF_FPTR22:
@@ -2143,7 +2147,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_IA64_FPTR32LSB:
        case R_IA64_FPTR64MSB:
        case R_IA64_FPTR64LSB:
-         if (info->shared || h)
+         if (bfd_link_pic (info) || h)
            need_entry = NEED_FPTR | NEED_DYNREL;
          else
            need_entry = NEED_FPTR;
@@ -2172,7 +2176,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
          break;
 
        case R_IA64_PCREL21B:
-        case R_IA64_PCREL60B:
+       case R_IA64_PCREL60B:
          /* Depending on where this symbol is defined, we may or may not
             need a full plt entry.  Only skip if we know we'll not need
             the entry -- static or symbolic, and the symbol definition
@@ -2189,7 +2193,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_IA64_DIR64MSB:
        case R_IA64_DIR64LSB:
          /* Shared objects will always need at least a REL relocation.  */
-         if (info->shared || maybe_dynamic)
+         if (bfd_link_pic (info) || maybe_dynamic)
            need_entry = NEED_DYNREL;
          dynrel_type = R_IA64_DIR64LSB;
          break;
@@ -2234,7 +2238,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        }
       if (need_entry & NEED_FPTR)
        {
-          /* Create the .opd section.  */
+         /* Create the .opd section.  */
          if (!fptr)
            {
              fptr = get_fptr (abfd, info, ia64_info);
@@ -2247,7 +2251,7 @@ elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        dyn_i->want_ltoff_fptr = 1;
       if (need_entry & (NEED_MIN_PLT | NEED_FULL_PLT))
        {
-          if (!ia64_info->root.dynobj)
+         if (!ia64_info->root.dynobj)
            ia64_info->root.dynobj = abfd;
          h->needs_plt = 1;
          dyn_i->want_plt = 1;
@@ -2357,7 +2361,7 @@ allocate_fptr (struct elf64_ia64_dyn_sym_info *dyn_i, void * data)
 
       if (h == NULL || !h->def_dynamic)
        {
-          /*  A non dynamic symbol.  */
+         /*  A non dynamic symbol.  */
          dyn_i->fptr_offset = x->ofs;
          x->ofs += 16;
        }
@@ -2459,7 +2463,7 @@ allocate_dynrel_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
   /* Note that this can't be used in relation to FPTR relocs below.  */
   dynamic_symbol = elf64_ia64_dynamic_symbol_p (dyn_i->h);
 
-  shared = x->info->shared;
+  shared = bfd_link_pic (x->info);
   resolved_zero = (dyn_i->h
                   && ELF_ST_VISIBILITY (dyn_i->h->other)
                   && dyn_i->h->root.type == bfd_link_hash_undefweak);
@@ -2475,13 +2479,13 @@ allocate_dynrel_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
     {
       /* VMS: FIX64.  */
       if (dyn_i->h != NULL && dyn_i->h->def_dynamic)
-        {
-          h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
-          elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
-            sizeof (Elf64_External_VMS_IMAGE_FIXUP);
-          ia64_info->fixups_sec->size +=
-            sizeof (Elf64_External_VMS_IMAGE_FIXUP);
-        }
+       {
+         h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
+         elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
+           sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+         ia64_info->fixups_sec->size +=
+           sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+       }
     }
 
   if (ia64_info->rel_fptr_sec && dyn_i->want_fptr)
@@ -2495,13 +2499,13 @@ allocate_dynrel_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
     {
       /* VMS: FIXFD.  */
       if (dyn_i->h != NULL && dyn_i->h->def_dynamic)
-        {
-          h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
-          elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
-            sizeof (Elf64_External_VMS_IMAGE_FIXUP);
-          ia64_info->fixups_sec->size +=
-            sizeof (Elf64_External_VMS_IMAGE_FIXUP);
-        }
+       {
+         h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
+         elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
+           sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+         ia64_info->fixups_sec->size +=
+           sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+       }
     }
 
   /* Take care of the normal data relocations.  */
@@ -2518,7 +2522,7 @@ allocate_dynrel_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
             will be true only if we're actually allocating one statically
             in the main executable.  Position independent executables
             need a relative reloc.  */
-         if (dyn_i->want_fptr && !x->info->pie)
+         if (dyn_i->want_fptr && !bfd_link_pie (x->info))
            continue;
          break;
        case R_IA64_PCREL32LSB:
@@ -2550,13 +2554,13 @@ allocate_dynrel_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
 
       /* Add a fixup.  */
       if (!dynamic_symbol)
-        abort ();
+       abort ();
 
       h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
       elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
-        sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+       sizeof (Elf64_External_VMS_IMAGE_FIXUP);
       ia64_info->fixups_sec->size +=
-        sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+       sizeof (Elf64_External_VMS_IMAGE_FIXUP);
     }
 
   return TRUE;
@@ -2572,12 +2576,12 @@ elf64_ia64_adjust_dynamic_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED,
   /* 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->u.weakdef != NULL)
+  if (h->is_weakalias)
     {
-      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
-                  || h->u.weakdef->root.type == bfd_link_hash_defweak);
-      h->root.u.def.section = h->u.weakdef->root.u.def.section;
-      h->root.u.def.value = h->u.weakdef->root.u.def.value;
+      struct elf_link_hash_entry *def = weakdef (h);
+      BFD_ASSERT (def->root.type == bfd_link_hash_defined);
+      h->root.u.def.section = def->root.u.def.section;
+      h->root.u.def.value = def->root.u.def.value;
       return TRUE;
     }
 
@@ -2724,20 +2728,20 @@ elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        }
       else if (sec == ia64_info->fixups_sec)
        {
-          if (strip)
-            ia64_info->fixups_sec = NULL;
+         if (strip)
+           ia64_info->fixups_sec = NULL;
        }
       else if (sec == ia64_info->transfer_sec)
-        {
-          ;
-        }
+       {
+         ;
+       }
       else
        {
          const char *name;
 
          /* It's OK to base decisions on the section name, because none
             of the dynobj section names depend upon the input files.  */
-         name = bfd_get_section_name (dynobj, sec);
+         name = bfd_section_name (sec);
 
          if (strcmp (name, ".got.plt") == 0)
            strip = FALSE;
@@ -2791,125 +2795,125 @@ elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       vms_get_time (&time_hi, &time_lo);
 
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_IDENT, 0))
-        return FALSE;
+       return FALSE;
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_LINKTIME,
-                                       (((bfd_uint64_t)time_hi) << 32)
-                                       + time_lo))
-        return FALSE;
+                                      (((bfd_uint64_t)time_hi) << 32)
+                                      + time_lo))
+       return FALSE;
 
       /* Strtab.  */
       strdyn_off = dynsec->size;
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_STRTAB_OFFSET, 0))
-        return FALSE;
+       return FALSE;
       if (!_bfd_elf_add_dynamic_entry (info, DT_STRSZ, 0))
-        return FALSE;
+       return FALSE;
 
       /* PLTGOT  */
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_PLTGOT_SEG, 0))
-        return FALSE;
+       return FALSE;
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_PLTGOT_OFFSET, 0))
-        return FALSE;
+       return FALSE;
 
       /* Misc.  */
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FPMODE, 0x9800000))
-        return FALSE;
+       return FALSE;
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_LNKFLAGS,
-                                       VMS_LF_IMGSTA | VMS_LF_MAIN))
-        return FALSE;
+                                      VMS_LF_IMGSTA | VMS_LF_MAIN))
+       return FALSE;
 
       /* Add entries for shared libraries.  */
       for (abfd = info->input_bfds; abfd; abfd = abfd->link.next)
-        {
-          char *soname;
-          size_t soname_len;
-          bfd_size_type strindex;
-          bfd_byte *newcontents;
-          bfd_vma fixups_shl_off;
-
-          if (!(abfd->flags & DYNAMIC))
-            continue;
-          BFD_ASSERT (abfd->xvec == output_bfd->xvec);
-
-          if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_NEEDED_IDENT,
-                                           elf_ia64_vms_ident (abfd)))
-            return FALSE;
-
-          soname = vms_get_module_name (abfd->filename, TRUE);
-          if (soname == NULL)
-            return FALSE;
-          strindex = dynstrsec->size;
-          soname_len = strlen (soname) + 1;
-          newcontents = (bfd_byte *) bfd_realloc (dynstrsec->contents,
-                                                  strindex + soname_len);
-          if (newcontents == NULL)
-            return FALSE;
-          memcpy (newcontents + strindex, soname, soname_len);
-          dynstrsec->size += soname_len;
-          dynstrsec->contents = newcontents;
-
-          if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex))
-            return FALSE;
-
-          if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FIXUP_NEEDED,
-                                           shl_num))
-            return FALSE;
-          shl_num++;
-
-          /* The fixups_off was in fact containing the size of the fixup
-             section.  Remap into the offset.  */
-          fixups_shl_off = elf_ia64_vms_tdata (abfd)->fixups_off;
-          elf_ia64_vms_tdata (abfd)->fixups_off = fixups_off;
-
-          if (!_bfd_elf_add_dynamic_entry
-              (info, DT_IA_64_VMS_FIXUP_RELA_CNT,
-               fixups_shl_off / sizeof (Elf64_External_VMS_IMAGE_FIXUP)))
-            return FALSE;
-          if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FIXUP_RELA_OFF,
-                                           fixups_off))
-            return FALSE;
-          fixups_off += fixups_shl_off;
-        }
+       {
+         char *soname;
+         size_t soname_len;
+         bfd_size_type strindex;
+         bfd_byte *newcontents;
+         bfd_vma fixups_shl_off;
+
+         if (!(abfd->flags & DYNAMIC))
+           continue;
+         BFD_ASSERT (abfd->xvec == output_bfd->xvec);
+
+         if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_NEEDED_IDENT,
+                                          elf_ia64_vms_ident (abfd)))
+           return FALSE;
+
+         soname = vms_get_module_name (bfd_get_filename (abfd), TRUE);
+         if (soname == NULL)
+           return FALSE;
+         strindex = dynstrsec->size;
+         soname_len = strlen (soname) + 1;
+         newcontents = (bfd_byte *) bfd_realloc (dynstrsec->contents,
+                                                 strindex + soname_len);
+         if (newcontents == NULL)
+           return FALSE;
+         memcpy (newcontents + strindex, soname, soname_len);
+         dynstrsec->size += soname_len;
+         dynstrsec->contents = newcontents;
+
+         if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex))
+           return FALSE;
+
+         if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FIXUP_NEEDED,
+                                          shl_num))
+           return FALSE;
+         shl_num++;
+
+         /* The fixups_off was in fact containing the size of the fixup
+            section.  Remap into the offset.  */
+         fixups_shl_off = elf_ia64_vms_tdata (abfd)->fixups_off;
+         elf_ia64_vms_tdata (abfd)->fixups_off = fixups_off;
+
+         if (!_bfd_elf_add_dynamic_entry
+             (info, DT_IA_64_VMS_FIXUP_RELA_CNT,
+              fixups_shl_off / sizeof (Elf64_External_VMS_IMAGE_FIXUP)))
+           return FALSE;
+         if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FIXUP_RELA_OFF,
+                                          fixups_off))
+           return FALSE;
+         fixups_off += fixups_shl_off;
+       }
 
       /* Unwind.  */
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWINDSZ, 0))
-        return FALSE;
+       return FALSE;
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_CODSEG, 0))
-        return FALSE;
+       return FALSE;
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_INFOSEG, 0))
-        return FALSE;
+       return FALSE;
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_OFFSET, 0))
-        return FALSE;
+       return FALSE;
       if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_SEG, 0))
-        return FALSE;
+       return FALSE;
 
       if (!_bfd_elf_add_dynamic_entry (info, DT_NULL, 0xdead))
-            return FALSE;
+           return FALSE;
 
       /* Fix the strtab entries.  */
       bed = get_elf_backend_data (hash_table->dynobj);
 
       if (dynstrsec->size > 1)
-        dynstrsec->contents[0] = 0;
+       dynstrsec->contents[0] = 0;
       else
-        dynstrsec->size = 0;
+       dynstrsec->size = 0;
 
       /* Note: one 'spare' (ie DT_NULL) entry is added by
-         bfd_elf_size_dynsym_hash_dynstr.  */
+        bfd_elf_size_dynsym_hash_dynstr.  */
       dyn.d_tag = DT_IA_64_VMS_STRTAB_OFFSET;
       dyn.d_un.d_val = dynsec->size /* + sizeof (Elf64_External_Dyn) */;
       bed->s->swap_dyn_out (hash_table->dynobj, &dyn,
-                            dynsec->contents + strdyn_off);
+                           dynsec->contents + strdyn_off);
 
       dyn.d_tag = DT_STRSZ;
       dyn.d_un.d_val = dynstrsec->size;
       bed->s->swap_dyn_out (hash_table->dynobj, &dyn,
-                            dynsec->contents + strdyn_off + bed->s->sizeof_dyn);
+                           dynsec->contents + strdyn_off + bed->s->sizeof_dyn);
 
       elf_ia64_vms_tdata (output_bfd)->needed_count = shl_num;
 
       /* Note section.  */
       if (!create_ia64_vms_notes (output_bfd, info, time_hi, time_lo))
-        return FALSE;
+       return FALSE;
     }
 
   /* ??? Perhaps force __gp local.  */
@@ -2919,10 +2923,10 @@ elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
 static void
 elf64_ia64_install_fixup (bfd *output_bfd,
-                          struct elf64_ia64_link_hash_table *ia64_info,
-                          struct elf_link_hash_entry *h,
-                          unsigned int type, asection *sec, bfd_vma offset,
-                          bfd_vma addend)
+                         struct elf64_ia64_link_hash_table *ia64_info,
+                         struct elf_link_hash_entry *h,
+                         unsigned int type, asection *sec, bfd_vma offset,
+                         bfd_vma addend)
 {
   asection *relsec;
   Elf64_External_VMS_IMAGE_FIXUP *fixup;
@@ -2998,13 +3002,13 @@ set_got_entry (bfd *abfd, struct bfd_link_info *info,
       bfd_put_64 (abfd, value, got_sec->contents + got_offset);
 
       /* Install a dynamic relocation if needed.  */
-      if (((info->shared
+      if (((bfd_link_pic (info)
            && (!dyn_i->h
                || ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
                || dyn_i->h->root.type != bfd_link_hash_undefweak))
-           || elf64_ia64_dynamic_symbol_p (dyn_i->h))
+          || elf64_ia64_dynamic_symbol_p (dyn_i->h))
          && (!dyn_i->want_ltoff_fptr
-             || !info->pie
+             || !bfd_link_pie (info)
              || !dyn_i->h
              || dyn_i->h->root.type != bfd_link_hash_undefweak))
        {
@@ -3014,25 +3018,25 @@ set_got_entry (bfd *abfd, struct bfd_link_info *info,
              addend = value;
            }
 
-          /* VMS: install a FIX32 or FIX64.  */
-          switch (dyn_r_type)
-            {
-            case R_IA64_DIR32LSB:
-            case R_IA64_FPTR32LSB:
-              dyn_r_type = R_IA64_VMS_FIX32;
-              break;
-            case R_IA64_DIR64LSB:
-            case R_IA64_FPTR64LSB:
-              dyn_r_type = R_IA64_VMS_FIX64;
-              break;
-            default:
-              BFD_ASSERT (FALSE);
-              break;
-            }
-          elf64_ia64_install_fixup
-            (info->output_bfd, ia64_info, dyn_i->h,
-             dyn_r_type, got_sec, got_offset, addend);
-        }
+         /* VMS: install a FIX32 or FIX64.  */
+         switch (dyn_r_type)
+           {
+           case R_IA64_DIR32LSB:
+           case R_IA64_FPTR32LSB:
+             dyn_r_type = R_IA64_VMS_FIX32;
+             break;
+           case R_IA64_DIR64LSB:
+           case R_IA64_FPTR64LSB:
+             dyn_r_type = R_IA64_VMS_FIX64;
+             break;
+           default:
+             BFD_ASSERT (FALSE);
+             break;
+           }
+         elf64_ia64_install_fixup
+           (info->output_bfd, ia64_info, dyn_i->h,
+            dyn_r_type, got_sec, got_offset, addend);
+       }
     }
 
   /* Return the address of the linkage table entry.  */
@@ -3108,13 +3112,13 @@ set_pltoff_entry (bfd *abfd, struct bfd_link_info *info,
 
       /* Install dynamic relocations if needed.  */
       if (!is_plt
-         && info->shared
+         && bfd_link_pic (info)
          && (!dyn_i->h
              || ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
              || dyn_i->h->root.type != bfd_link_hash_undefweak))
        {
-          /* VMS:  */
-          abort ();
+         /* VMS:  */
+         abort ();
        }
 
       dyn_i->pltoff_done = 1;
@@ -3273,11 +3277,11 @@ elf64_ia64_choose_gp (bfd *abfd, struct bfd_link_info *info, bfd_boolean final)
     {
       if (max_short_vma - min_short_vma >= 0x400000)
        {
-overflow:
-         (*_bfd_error_handler)
-           (_("%s: short data segment overflowed (0x%lx >= 0x400000)"),
-            bfd_get_filename (abfd),
-            (unsigned long) (max_short_vma - min_short_vma));
+       overflow:
+         _bfd_error_handler
+           /* xgettext:c-format */
+           (_("%pB: short data segment overflowed (%#" PRIx64 " >= 0x400000)"),
+            abfd, (uint64_t) (max_short_vma - min_short_vma));
          return FALSE;
        }
       else if ((gp_val > min_short_vma
@@ -3285,9 +3289,8 @@ overflow:
               || (gp_val < max_short_vma
                   && max_short_vma - gp_val >= 0x200000))
        {
-         (*_bfd_error_handler)
-           (_("%s: __gp does not cover short data segment"),
-            bfd_get_filename (abfd));
+         _bfd_error_handler
+           (_("%pB: __gp does not cover short data segment"), abfd);
          return FALSE;
        }
     }
@@ -3308,7 +3311,7 @@ elf64_ia64_final_link (bfd *abfd, struct bfd_link_info *info)
     return FALSE;
 
   /* Make sure we've got ourselves a nice fat __gp value.  */
-  if (!info->relocatable)
+  if (!bfd_link_relocatable (info))
     {
       bfd_vma gp_val;
       struct elf_link_hash_entry *gp;
@@ -3321,7 +3324,7 @@ elf64_ia64_final_link (bfd *abfd, struct bfd_link_info *info)
       gp_val = _bfd_get_gp_value (abfd);
 
       gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
-                                FALSE, FALSE);
+                                FALSE, FALSE);
       if (gp)
        {
          gp->root.type = bfd_link_hash_defined;
@@ -3334,7 +3337,7 @@ elf64_ia64_final_link (bfd *abfd, struct bfd_link_info *info)
      of the .IA_64.unwind section.  Force this section to be relocated
      into memory rather than written immediately to the output file.  */
   unwind_output_sec = NULL;
-  if (!info->relocatable)
+  if (!bfd_link_relocatable (info))
     {
       asection *s = bfd_get_section_by_name (abfd, ELF_STRING_ia64_unwind);
       if (s)
@@ -3391,7 +3394,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
     return FALSE;
 
   /* Infect various flags from the input section to the output section.  */
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     {
       bfd_vma flags;
 
@@ -3424,15 +3427,20 @@ elf64_ia64_relocate_section (bfd *output_bfd,
       r_type = ELF64_R_TYPE (rel->r_info);
       if (r_type > R_IA64_MAX_RELOC_CODE)
        {
-         (*_bfd_error_handler)
-           (_("%B: unknown relocation type %d"),
-            input_bfd, (int) r_type);
+         /* xgettext:c-format */
+         _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                             input_bfd, (int) r_type);
          bfd_set_error (bfd_error_bad_value);
          ret_val = FALSE;
          continue;
        }
 
       howto = ia64_elf_lookup_howto (r_type);
+      if (howto == NULL)
+       {
+         ret_val = FALSE;
+         continue;
+       }
       r_symndx = ELF64_R_SYM (rel->r_info);
       h = NULL;
       sym = NULL;
@@ -3447,7 +3455,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
          sym_sec = local_sections[r_symndx];
          msec = sym_sec;
          value = _bfd_elf_rela_local_sym (output_bfd, sym, &msec, rel);
-         if (!info->relocatable
+         if (!bfd_link_relocatable (info)
              && (sym_sec->flags & SEC_MERGE) != 0
              && ELF_ST_TYPE (sym->st_info) == STT_SECTION
              && sym_sec->sec_info_type == SEC_INFO_TYPE_MERGE)
@@ -3515,7 +3523,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
        RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
                                         rel, 1, relend, howto, 0, contents);
 
-      if (info->relocatable)
+      if (bfd_link_relocatable (info))
        continue;
 
       hit_addr = contents + rel->r_offset;
@@ -3536,7 +3544,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
        case R_IA64_DIR64MSB:
        case R_IA64_DIR64LSB:
          /* Install a dynamic relocation for this reloc.  */
-         if ((dynamic_symbol_p || info->shared)
+         if ((dynamic_symbol_p || bfd_link_pic (info))
              && r_symndx != 0
              && (input_section->flags & SEC_ALLOC) != 0)
            {
@@ -3550,8 +3558,10 @@ elf64_ia64_relocate_section (bfd *output_bfd,
                case R_IA64_IMM64:
                  /* ??? People shouldn't be doing non-pic code in
                     shared libraries nor dynamic executables.  */
-                 (*_bfd_error_handler)
-                   (_("%B: non-pic code with imm relocation against dynamic symbol `%s'"),
+                 _bfd_error_handler
+                   /* xgettext:c-format */
+                   (_("%pB: non-pic code with imm relocation against"
+                      " dynamic symbol `%s'"),
                     input_bfd,
                     h ? h->root.root.string
                       : bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
@@ -3576,24 +3586,24 @@ elf64_ia64_relocate_section (bfd *output_bfd,
                  addend = value;
                }
 
-              /* VMS: install a FIX64.  */
-              switch (dyn_r_type)
-                {
-                case R_IA64_DIR32LSB:
-                  dyn_r_type = R_IA64_VMS_FIX32;
-                  break;
-                case R_IA64_DIR64LSB:
-                  dyn_r_type = R_IA64_VMS_FIX64;
-                  break;
-                default:
-                  BFD_ASSERT (FALSE);
-                  break;
-                }
-              elf64_ia64_install_fixup
-                (output_bfd, ia64_info, h,
-                 dyn_r_type, input_section, rel->r_offset, addend);
-              r = bfd_reloc_ok;
-              break;
+             /* VMS: install a FIX64.  */
+             switch (dyn_r_type)
+               {
+               case R_IA64_DIR32LSB:
+                 dyn_r_type = R_IA64_VMS_FIX32;
+                 break;
+               case R_IA64_DIR64LSB:
+                 dyn_r_type = R_IA64_VMS_FIX64;
+                 break;
+               default:
+                 BFD_ASSERT (FALSE);
+                 break;
+               }
+             elf64_ia64_install_fixup
+               (output_bfd, ia64_info, h,
+                dyn_r_type, input_section, rel->r_offset, addend);
+             r = bfd_reloc_ok;
+             break;
            }
          /* Fall through.  */
 
@@ -3612,8 +3622,9 @@ elf64_ia64_relocate_section (bfd *output_bfd,
        case R_IA64_GPREL64LSB:
          if (dynamic_symbol_p)
            {
-             (*_bfd_error_handler)
-               (_("%B: @gprel relocation against dynamic symbol %s"),
+             _bfd_error_handler
+               /* xgettext:c-format */
+               (_("%pB: @gprel relocation against dynamic symbol %s"),
                 input_bfd,
                 h ? h->root.root.string
                   : bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
@@ -3628,7 +3639,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
        case R_IA64_LTOFF22:
        case R_IA64_LTOFF22X:
        case R_IA64_LTOFF64I:
-          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
+         dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
          value = set_got_entry (input_bfd, info, dyn_i,
                                 rel->r_addend, value, R_IA64_DIR64LSB);
          value -= gp_val;
@@ -3639,7 +3650,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
        case R_IA64_PLTOFF64I:
        case R_IA64_PLTOFF64MSB:
        case R_IA64_PLTOFF64LSB:
-          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
+         dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
          value = set_pltoff_entry (output_bfd, info, dyn_i, value, FALSE);
          value -= gp_val;
          r = ia64_elf_install_value (hit_addr, value, r_type);
@@ -3650,13 +3661,13 @@ elf64_ia64_relocate_section (bfd *output_bfd,
        case R_IA64_FPTR32LSB:
        case R_IA64_FPTR64MSB:
        case R_IA64_FPTR64LSB:
-          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
+         dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
          if (dyn_i->want_fptr)
            {
              if (!undef_weak_ref)
                value = set_fptr_entry (output_bfd, info, dyn_i, value);
            }
-         if (!dyn_i->want_fptr || info->pie)
+         if (!dyn_i->want_fptr || bfd_link_pie (info))
            {
              /* Otherwise, we expect the dynamic linker to create
                 the entry.  */
@@ -3671,8 +3682,8 @@ elf64_ia64_relocate_section (bfd *output_bfd,
                         dynamic symbol table.  */
                      /* ??? People shouldn't be doing non-pic code in
                         shared libraries.  Hork.  */
-                     (*_bfd_error_handler)
-                       (_("%B: linking non-pic code in a position independent executable"),
+                     _bfd_error_handler
+                       (_("%pB: linking non-pic code in a position independent executable"),
                         input_bfd);
                      ret_val = FALSE;
                      continue;
@@ -3683,12 +3694,12 @@ elf64_ia64_relocate_section (bfd *output_bfd,
                  value = 0;
                }
 
-              /* VMS: FIXFD.  */
-              elf64_ia64_install_fixup
-                (output_bfd, ia64_info, h, R_IA64_VMS_FIXFD,
-                 input_section, rel->r_offset, 0);
-              r = bfd_reloc_ok;
-              break;
+             /* VMS: FIXFD.  */
+             elf64_ia64_install_fixup
+               (output_bfd, ia64_info, h, R_IA64_VMS_FIXFD,
+                input_section, rel->r_offset, 0);
+             r = bfd_reloc_ok;
+             break;
            }
 
          r = ia64_elf_install_value (hit_addr, value, r_type);
@@ -3700,20 +3711,20 @@ elf64_ia64_relocate_section (bfd *output_bfd,
        case R_IA64_LTOFF_FPTR32LSB:
        case R_IA64_LTOFF_FPTR64MSB:
        case R_IA64_LTOFF_FPTR64LSB:
-          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
-          if (dyn_i->want_fptr)
-            {
-              BFD_ASSERT (h == NULL || !h->def_dynamic);
-              if (!undef_weak_ref)
-                value = set_fptr_entry (output_bfd, info, dyn_i, value);
-            }
-          else
-            value = 0;
-
-          value = set_got_entry (output_bfd, info, dyn_i,
-                                 rel->r_addend, value, R_IA64_FPTR64LSB);
-          value -= gp_val;
-          r = ia64_elf_install_value (hit_addr, value, r_type);
+         dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
+         if (dyn_i->want_fptr)
+           {
+             BFD_ASSERT (h == NULL || !h->def_dynamic);
+             if (!undef_weak_ref)
+               value = set_fptr_entry (output_bfd, info, dyn_i, value);
+           }
+         else
+           value = 0;
+
+         value = set_got_entry (output_bfd, info, dyn_i,
+                                rel->r_addend, value, R_IA64_FPTR64LSB);
+         value -= gp_val;
+         r = ia64_elf_install_value (hit_addr, value, r_type);
          break;
 
        case R_IA64_PCREL32MSB:
@@ -3723,8 +3734,8 @@ elf64_ia64_relocate_section (bfd *output_bfd,
          /* Install a dynamic relocation for this reloc.  */
          if (dynamic_symbol_p && r_symndx != 0)
            {
-              /* VMS: doesn't exist ???  */
-              abort ();
+             /* VMS: doesn't exist ???  */
+             abort ();
            }
          goto finish_pcrel;
 
@@ -3773,17 +3784,20 @@ elf64_ia64_relocate_section (bfd *output_bfd,
              const char *msg;
 
              if (r_type == R_IA64_PCREL21BI)
-               msg = _("%B: @internal branch to dynamic symbol %s");
+               /* xgettext:c-format */
+               msg = _("%pB: @internal branch to dynamic symbol %s");
              else if (r_type == R_IA64_PCREL21F || r_type == R_IA64_PCREL21M)
-               msg = _("%B: speculation fixup to dynamic symbol %s");
+               /* xgettext:c-format */
+               msg = _("%pB: speculation fixup to dynamic symbol %s");
              else
-               msg = _("%B: @pcrel relocation against dynamic symbol %s");
-             (*_bfd_error_handler) (msg, input_bfd,
-                                    h ? h->root.root.string
-                                      : bfd_elf_sym_name (input_bfd,
-                                                          symtab_hdr,
-                                                          sym,
-                                                          sym_sec));
+               /* xgettext:c-format */
+               msg = _("%pB: @pcrel relocation against dynamic symbol %s");
+             _bfd_error_handler (msg, input_bfd,
+                                 h ? h->root.root.string
+                                 : bfd_elf_sym_name (input_bfd,
+                                                     symtab_hdr,
+                                                     sym,
+                                                     sym_sec));
              ret_val = FALSE;
              continue;
            }
@@ -3837,11 +3851,11 @@ elf64_ia64_relocate_section (bfd *output_bfd,
        case R_IA64_IPLTMSB:
        case R_IA64_IPLTLSB:
          /* Install a dynamic relocation for this reloc.  */
-         if ((dynamic_symbol_p || info->shared)
+         if ((dynamic_symbol_p || bfd_link_pic (info))
              && (input_section->flags & SEC_ALLOC) != 0)
            {
-              /* VMS: FIXFD ??  */
-              abort ();
+             /* VMS: FIXFD ??  */
+             abort ();
            }
 
          if (r_type == R_IA64_IPLTMSB)
@@ -3901,10 +3915,9 @@ elf64_ia64_relocate_section (bfd *output_bfd,
            else
              name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
                                       sym_sec);
-           if (!(*info->callbacks->warning) (info, _("unsupported reloc"),
-                                             name, input_bfd,
-                                             input_section, rel->r_offset))
-             return FALSE;
+           (*info->callbacks->warning) (info, _("unsupported reloc"),
+                                        name, input_bfd,
+                                        input_section, rel->r_offset);
            ret_val = FALSE;
          }
          break;
@@ -3937,10 +3950,12 @@ elf64_ia64_relocate_section (bfd *output_bfd,
              case R_IA64_LTOFF_TPREL22:
              case R_IA64_LTOFF_DTPMOD22:
              case R_IA64_LTOFF_DTPREL22:
-               (*_bfd_error_handler)
-                 (_("%B: missing TLS section for relocation %s against `%s' at 0x%lx in section `%A'."),
-                  input_bfd, input_section, howto->name, name,
-                  rel->r_offset);
+               _bfd_error_handler
+                 /* xgettext:c-format */
+                 (_("%pB: missing TLS section for relocation %s against `%s'"
+                    " at %#" PRIx64 " in section `%pA'."),
+                  input_bfd, howto->name, name,
+                  (uint64_t) rel->r_offset, input_section);
                break;
 
              case R_IA64_PCREL21B:
@@ -3952,22 +3967,25 @@ elf64_ia64_relocate_section (bfd *output_bfd,
                    /* Relaxtion is always performed for ELF output.
                       Overflow failures for those relocations mean
                       that the section is too big to relax.  */
-                   (*_bfd_error_handler)
-                     (_("%B: Can't relax br (%s) to `%s' at 0x%lx in section `%A' with size 0x%lx (> 0x1000000)."),
-                      input_bfd, input_section, howto->name, name,
-                      rel->r_offset, input_section->size);
+                   _bfd_error_handler
+                     /* xgettext:c-format */
+                     (_("%pB: Can't relax br (%s) to `%s' "
+                        "at %#" PRIx64 " in section `%pA' "
+                        "with size %#" PRIx64 " (> 0x1000000)."),
+                      input_bfd, howto->name, name, (uint64_t) rel->r_offset,
+                      input_section, (uint64_t) input_section->size);
                    break;
                  }
+               /* Fall through.  */
              default:
-               if (!(*info->callbacks->reloc_overflow) (info,
-                                                        &h->root,
-                                                        name,
-                                                        howto->name,
-                                                        (bfd_vma) 0,
-                                                        input_bfd,
-                                                        input_section,
-                                                        rel->r_offset))
-                 return FALSE;
+               (*info->callbacks->reloc_overflow) (info,
+                                                   &h->root,
+                                                   name,
+                                                   howto->name,
+                                                   (bfd_vma) 0,
+                                                   input_bfd,
+                                                   input_section,
+                                                   rel->r_offset);
                break;
              }
 
@@ -4026,9 +4044,9 @@ elf64_ia64_finish_dynamic_symbol (bfd *output_bfd,
 
       /* VMS: FIXFD.  */
       elf64_ia64_install_fixup
-        (output_bfd, ia64_info, h, R_IA64_VMS_FIXFD, ia64_info->pltoff_sec,
-         pltoff_addr - (ia64_info->pltoff_sec->output_section->vma
-                        + ia64_info->pltoff_sec->output_offset), 0);
+       (output_bfd, ia64_info, h, R_IA64_VMS_FIXFD, ia64_info->pltoff_sec,
+        pltoff_addr - (ia64_info->pltoff_sec->output_section->vma
+                       + ia64_info->pltoff_sec->output_offset), 0);
     }
 
   /* Mark some specially defined symbols as absolute.  */
@@ -4073,7 +4091,7 @@ elf64_ia64_finish_dynamic_sections (bfd *abfd,
 
       gp_val = _bfd_get_gp_value (abfd);
       phdr = _bfd_elf_find_segment_containing_section
-        (info->output_bfd, ia64_info->pltoff_sec->output_section);
+       (info->output_bfd, ia64_info->pltoff_sec->output_section);
       BFD_ASSERT (phdr != NULL);
       base_phdr = elf_tdata (info->output_bfd)->phdr;
       gp_seg = phdr - base_phdr;
@@ -4081,18 +4099,18 @@ elf64_ia64_finish_dynamic_sections (bfd *abfd,
 
       unwind_sec = bfd_get_section_by_name (abfd, ELF_STRING_ia64_unwind);
       if (unwind_sec != NULL)
-        {
-          asection *code_sec;
+       {
+         asection *code_sec;
 
-          phdr = _bfd_elf_find_segment_containing_section (abfd, unwind_sec);
-          BFD_ASSERT (phdr != NULL);
-          unwind_seg = phdr - base_phdr;
+         phdr = _bfd_elf_find_segment_containing_section (abfd, unwind_sec);
+         BFD_ASSERT (phdr != NULL);
+         unwind_seg = phdr - base_phdr;
 
-          code_sec = bfd_get_section_by_name (abfd, "$CODE$");
-          phdr = _bfd_elf_find_segment_containing_section (abfd, code_sec);
-          BFD_ASSERT (phdr != NULL);
-          code_seg = phdr - base_phdr;
-        }
+         code_sec = bfd_get_section_by_name (abfd, "$CODE$");
+         phdr = _bfd_elf_find_segment_containing_section (abfd, code_sec);
+         BFD_ASSERT (phdr != NULL);
+         code_seg = phdr - base_phdr;
+       }
 
       for (; dyncon < dynconend; dyncon++)
        {
@@ -4102,46 +4120,46 @@ elf64_ia64_finish_dynamic_sections (bfd *abfd,
 
          switch (dyn.d_tag)
            {
-            case DT_IA_64_VMS_FIXUP_RELA_OFF:
-              dyn.d_un.d_val +=
-                (ia64_info->fixups_sec->output_section->vma
-                 + ia64_info->fixups_sec->output_offset)
-                - (sdyn->output_section->vma + sdyn->output_offset);
-              break;
-
-            case DT_IA_64_VMS_PLTGOT_OFFSET:
-              dyn.d_un.d_val = gp_off;
-              break;
-
-            case DT_IA_64_VMS_PLTGOT_SEG:
-              dyn.d_un.d_val = gp_seg;
-              break;
-
-            case DT_IA_64_VMS_UNWINDSZ:
-              if (unwind_sec == NULL)
-                {
-                  dyn.d_tag = DT_NULL;
-                  dyn.d_un.d_val = 0xdead;
-                }
-              else
-                dyn.d_un.d_val = unwind_sec->size;
-              break;
-
-            case DT_IA_64_VMS_UNWIND_CODSEG:
-              dyn.d_un.d_val = code_seg;
-              break;
-
-            case DT_IA_64_VMS_UNWIND_INFOSEG:
-            case DT_IA_64_VMS_UNWIND_SEG:
-              dyn.d_un.d_val = unwind_seg;
-              break;
-
-            case DT_IA_64_VMS_UNWIND_OFFSET:
-              break;
-
-            default:
-              /* No need to rewrite the entry.  */
-              continue;
+           case DT_IA_64_VMS_FIXUP_RELA_OFF:
+             dyn.d_un.d_val +=
+               (ia64_info->fixups_sec->output_section->vma
+                + ia64_info->fixups_sec->output_offset)
+               - (sdyn->output_section->vma + sdyn->output_offset);
+             break;
+
+           case DT_IA_64_VMS_PLTGOT_OFFSET:
+             dyn.d_un.d_val = gp_off;
+             break;
+
+           case DT_IA_64_VMS_PLTGOT_SEG:
+             dyn.d_un.d_val = gp_seg;
+             break;
+
+           case DT_IA_64_VMS_UNWINDSZ:
+             if (unwind_sec == NULL)
+               {
+                 dyn.d_tag = DT_NULL;
+                 dyn.d_un.d_val = 0xdead;
+               }
+             else
+               dyn.d_un.d_val = unwind_sec->size;
+             break;
+
+           case DT_IA_64_VMS_UNWIND_CODSEG:
+             dyn.d_un.d_val = code_seg;
+             break;
+
+           case DT_IA_64_VMS_UNWIND_INFOSEG:
+           case DT_IA_64_VMS_UNWIND_SEG:
+             dyn.d_un.d_val = unwind_seg;
+             break;
+
+           case DT_IA_64_VMS_UNWIND_OFFSET:
+             break;
+
+           default:
+             /* No need to rewrite the entry.  */
+             continue;
            }
 
          bfd_elf64_swap_dyn_out (abfd, &dyn, dyncon);
@@ -4157,25 +4175,25 @@ elf64_ia64_finish_dynamic_sections (bfd *abfd,
     tfr = (struct elf64_vms_transfer *)tfr_sec->contents;
     bfd_putl32 (6 * 8, tfr->size);
     bfd_putl64 (tfr_sec->output_section->vma
-                + tfr_sec->output_offset
-                + 6 * 8, tfr->tfradr3);
+               + tfr_sec->output_offset
+               + 6 * 8, tfr->tfradr3);
 
     tfr3 = elf_link_hash_lookup (elf_hash_table (info), "ELF$TFRADR", FALSE,
-                                 FALSE, FALSE);
+                                FALSE, FALSE);
 
     if (tfr3
-        && (tfr3->root.type == bfd_link_hash_defined
-            || tfr3->root.type == bfd_link_hash_defweak))
+       && (tfr3->root.type == bfd_link_hash_defined
+           || tfr3->root.type == bfd_link_hash_defweak))
       {
-        asection *tfr3_sec = tfr3->root.u.def.section;
-        bfd_vma tfr3_val;
+       asection *tfr3_sec = tfr3->root.u.def.section;
+       bfd_vma tfr3_val;
 
-        tfr3_val = (tfr3->root.u.def.value
-                    + tfr3_sec->output_section->vma
-                    + tfr3_sec->output_offset);
+       tfr3_val = (tfr3->root.u.def.value
+                   + tfr3_sec->output_section->vma
+                   + tfr3_sec->output_offset);
 
-        bfd_putl64 (tfr3_val, tfr->tfr3_func);
-        bfd_putl64 (_bfd_get_gp_value (info->output_bfd), tfr->tfr3_gp);
+       bfd_putl64 (tfr3_val, tfr->tfr3_func);
+       bfd_putl64 (_bfd_get_gp_value (info->output_bfd), tfr->tfr3_gp);
       }
 
     /* FIXME: set linker flags,
@@ -4202,12 +4220,17 @@ elf64_ia64_set_private_flags (bfd *abfd, flagword flags)
 /* Merge backend specific data from an object file to the output
    object file when linking.  */
 static bfd_boolean
-elf64_ia64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+elf64_ia64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 {
+  bfd *obfd = info->output_bfd;
   flagword out_flags;
   flagword in_flags;
   bfd_boolean ok = TRUE;
 
+  /* FIXME: What should be checked when linking shared libraries?  */
+  if ((ibfd->flags & DYNAMIC) != 0)
+    return TRUE;
+
   /* Don't even pretend to support mixed-format linking.  */
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
@@ -4241,8 +4264,8 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 
   if ((in_flags & EF_IA_64_TRAPNIL) != (out_flags & EF_IA_64_TRAPNIL))
     {
-      (*_bfd_error_handler)
-       (_("%B: linking trap-on-NULL-dereference with non-trapping files"),
+      _bfd_error_handler
+       (_("%pB: linking trap-on-NULL-dereference with non-trapping files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4250,8 +4273,8 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
     }
   if ((in_flags & EF_IA_64_BE) != (out_flags & EF_IA_64_BE))
     {
-      (*_bfd_error_handler)
-       (_("%B: linking big-endian files with little-endian files"),
+      _bfd_error_handler
+       (_("%pB: linking big-endian files with little-endian files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4259,8 +4282,8 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
     }
   if ((in_flags & EF_IA_64_ABI64) != (out_flags & EF_IA_64_ABI64))
     {
-      (*_bfd_error_handler)
-       (_("%B: linking 64-bit files with 32-bit files"),
+      _bfd_error_handler
+       (_("%pB: linking 64-bit files with 32-bit files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4268,8 +4291,8 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
     }
   if ((in_flags & EF_IA_64_CONS_GP) != (out_flags & EF_IA_64_CONS_GP))
     {
-      (*_bfd_error_handler)
-       (_("%B: linking constant-gp files with non-constant-gp files"),
+      _bfd_error_handler
+       (_("%pB: linking constant-gp files with non-constant-gp files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4278,8 +4301,8 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
   if ((in_flags & EF_IA_64_NOFUNCDESC_CONS_GP)
       != (out_flags & EF_IA_64_NOFUNCDESC_CONS_GP))
     {
-      (*_bfd_error_handler)
-       (_("%B: linking auto-pic files with non-auto-pic files"),
+      _bfd_error_handler
+       (_("%pB: linking auto-pic files with non-auto-pic files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4335,9 +4358,9 @@ elf64_ia64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
 
 static const struct bfd_elf_special_section elf64_ia64_special_sections[] =
 {
-  { STRING_COMMA_LEN (".sbss"),  -1, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
+  { STRING_COMMA_LEN (".sbss"),         -1, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
   { STRING_COMMA_LEN (".sdata"), -1, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
-  { NULL,                    0,   0, 0,            0 }
+  { NULL,                   0,   0, 0,            0 }
 };
 
 static bfd_boolean
@@ -4348,7 +4371,7 @@ elf64_ia64_object_p (bfd *abfd)
   flagword flags;
   const char *name;
   char *unwi_name, *unw_name;
-  bfd_size_type amt;
+  size_t amt;
 
   if (abfd->flags & DYNAMIC)
     return TRUE;
@@ -4473,8 +4496,8 @@ elf64_vms_section_from_shdr (bfd *abfd,
     {
       asection *newsect = hdr->bfd_section;
 
-      if (! bfd_set_section_flags
-          (abfd, newsect, bfd_get_section_flags (abfd, newsect) | secflags))
+      if (!bfd_set_section_flags (newsect,
+                                 bfd_section_flags (newsect) | secflags))
        return FALSE;
     }
 
@@ -4585,14 +4608,18 @@ elf64_vms_object_p (bfd *abfd)
   return TRUE;
 }
 
-static void
-elf64_vms_post_process_headers (bfd *abfd,
-                               struct bfd_link_info *info ATTRIBUTE_UNUSED)
+static bfd_boolean
+elf64_vms_init_file_header (bfd *abfd, struct bfd_link_info *info)
 {
-  Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
+  Elf_Internal_Ehdr *i_ehdrp;
+
+  if (!_bfd_elf_init_file_header (abfd, info))
+    return FALSE;
 
+  i_ehdrp = elf_elfheader (abfd);
   i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_OPENVMS;
   i_ehdrp->e_ident[EI_ABIVERSION] = 2;
+  return TRUE;
 }
 
 static bfd_boolean
@@ -4601,7 +4628,7 @@ elf64_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED,
 {
   if (hdr->bfd_section != NULL)
     {
-      const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
+      const char *name = bfd_section_name (hdr->bfd_section);
 
       if (strcmp (name, ".text") == 0)
        hdr->sh_flags |= SHF_IA_64_VMS_SHARED;
@@ -4631,9 +4658,8 @@ elf64_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED,
 /* The final processing done just before writing out a VMS IA-64 ELF
    object file.  */
 
-static void
-elf64_vms_final_write_processing (bfd *abfd,
-                                 bfd_boolean linker ATTRIBUTE_UNUSED)
+static bfd_boolean
+elf64_vms_final_write_processing (bfd *abfd)
 {
   Elf_Internal_Shdr *hdr;
   asection *s;
@@ -4643,7 +4669,7 @@ elf64_vms_final_write_processing (bfd *abfd,
     {
       hdr = &elf_section_data (s)->this_hdr;
 
-      if (strcmp (bfd_get_section_name (abfd, hdr->bfd_section),
+      if (strcmp (bfd_section_name (hdr->bfd_section),
                  ".IA_64.unwind_info") == 0)
        unwind_info_sect_idx = elf_section_data (s)->this_idx;
 
@@ -4651,7 +4677,7 @@ elf64_vms_final_write_processing (bfd *abfd,
        {
        case SHT_IA_64_UNWIND:
          /* VMS requires sh_info to point to the unwind info section.  */
-          hdr->sh_info = unwind_info_sect_idx;
+         hdr->sh_info = unwind_info_sect_idx;
          break;
        }
     }
@@ -4668,6 +4694,7 @@ elf64_vms_final_write_processing (bfd *abfd,
       elf_elfheader (abfd)->e_flags = flags;
       elf_flags_init (abfd) = TRUE;
     }
+  return _bfd_elf_final_write_processing (abfd);
 }
 
 static bfd_boolean
@@ -4699,7 +4726,7 @@ elf64_vms_close_and_cleanup (bfd *abfd)
       if ((isize & 7) != 0)
        {
          int ishort = 8 - (isize & 7);
-          bfd_uint64_t pad = 0;
+         bfd_uint64_t pad = 0;
 
          bfd_seek (abfd, isize, SEEK_SET);
          bfd_bwrite (&pad, ishort, abfd);
@@ -4739,11 +4766,11 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
       /* You can't use -r against a dynamic object.  Also, there's no
         hope of using a dynamic object which does not exactly match
         the format of the output file.  */
-      if (info->relocatable
+      if (bfd_link_relocatable (info)
          || !is_elf_hash_table (htab)
          || info->output_bfd->xvec != abfd->xvec)
        {
-         if (info->relocatable)
+         if (bfd_link_relocatable (info))
            bfd_set_error (bfd_error_invalid_operation);
          else
            bfd_set_error (bfd_error_wrong_format);
@@ -4758,7 +4785,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
         so we attach them to this BFD, provided it is the right
         format.  FIXME: If there are no input BFD's of the same
         format as the output, we can't make a shared library.  */
-      if (info->shared
+      if (bfd_link_pic (info)
          && is_elf_hash_table (htab)
          && info->output_bfd->xvec == abfd->xvec
          && !htab->dynamic_sections_created)
@@ -4783,65 +4810,65 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 
       /* Be sure there are dynamic sections.  */
       if (! elf64_ia64_create_dynamic_sections (htab->dynobj, info))
-        goto error_return;
+       goto error_return;
 
       s = bfd_get_section_by_name (abfd, ".dynamic");
       if (s == NULL)
-        {
-          /* VMS libraries do not have dynamic sections.  Create one from
-             the segment.  */
-          Elf_Internal_Phdr *phdr;
-          unsigned int i, phnum;
-
-          phdr = elf_tdata (abfd)->phdr;
-          if (phdr == NULL)
-            goto error_return;
-          phnum = elf_elfheader (abfd)->e_phnum;
-          for (i = 0; i < phnum; phdr++)
-            if (phdr->p_type == PT_DYNAMIC)
-              {
-                s = bfd_make_section (abfd, ".dynamic");
-                if (s == NULL)
-                  goto error_return;
-                s->vma = phdr->p_vaddr;
-                s->lma = phdr->p_paddr;
-                s->size = phdr->p_filesz;
-                s->filepos = phdr->p_offset;
-                s->flags |= SEC_HAS_CONTENTS;
-                s->alignment_power = bfd_log2 (phdr->p_align);
-                break;
-              }
-          if (s == NULL)
-            goto error_return;
-        }
+       {
+         /* VMS libraries do not have dynamic sections.  Create one from
+            the segment.  */
+         Elf_Internal_Phdr *phdr;
+         unsigned int i, phnum;
+
+         phdr = elf_tdata (abfd)->phdr;
+         if (phdr == NULL)
+           goto error_return;
+         phnum = elf_elfheader (abfd)->e_phnum;
+         for (i = 0; i < phnum; phdr++)
+           if (phdr->p_type == PT_DYNAMIC)
+             {
+               s = bfd_make_section (abfd, ".dynamic");
+               if (s == NULL)
+                 goto error_return;
+               s->vma = phdr->p_vaddr;
+               s->lma = phdr->p_paddr;
+               s->size = phdr->p_filesz;
+               s->filepos = phdr->p_offset;
+               s->flags |= SEC_HAS_CONTENTS;
+               s->alignment_power = bfd_log2 (phdr->p_align);
+               break;
+             }
+         if (s == NULL)
+           goto error_return;
+       }
 
       /* Extract IDENT.  */
       if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
-        {
-error_free_dyn:
-          free (dynbuf);
-          goto error_return;
-        }
+       {
+       error_free_dyn:
+         free (dynbuf);
+         goto error_return;
+       }
 
       for (extdyn = dynbuf;
-           extdyn < dynbuf + s->size;
-           extdyn += bed->s->sizeof_dyn)
-        {
-          Elf_Internal_Dyn dyn;
-
-          bed->s->swap_dyn_in (abfd, extdyn, &dyn);
-          if (dyn.d_tag == DT_IA_64_VMS_IDENT)
-            {
-              bfd_uint64_t tagv = dyn.d_un.d_val;
-              elf_ia64_vms_ident (abfd) = tagv;
-              break;
-            }
-        }
+          extdyn < dynbuf + s->size;
+          extdyn += bed->s->sizeof_dyn)
+       {
+         Elf_Internal_Dyn dyn;
+
+         bed->s->swap_dyn_in (abfd, extdyn, &dyn);
+         if (dyn.d_tag == DT_IA_64_VMS_IDENT)
+           {
+             bfd_uint64_t tagv = dyn.d_un.d_val;
+             elf_ia64_vms_ident (abfd) = tagv;
+             break;
+           }
+       }
       if (extdyn >= dynbuf + s->size)
-        {
-          /* Ident not found.  */
-          goto error_free_dyn;
-        }
+       {
+         /* Ident not found.  */
+         goto error_free_dyn;
+       }
       free (dynbuf);
 
       /* We do not want to include any of the sections in a dynamic
@@ -4854,7 +4881,7 @@ error_free_dyn:
       bfd_section_list_clear (abfd);
 
       /* FIXME: should we detect if this library is already included ?
-         This should be harmless and shouldn't happen in practice.  */
+        This should be harmless and shouldn't happen in practice.  */
     }
 
   hdr = &elf_tdata (abfd)->symtab_hdr;
@@ -4998,12 +5025,12 @@ error_free_dyn:
       new_sec = sec;
 
       if (! bfd_is_und_section (sec))
-        h = elf_link_hash_lookup (htab, name, TRUE, FALSE, FALSE);
+       h = elf_link_hash_lookup (htab, name, TRUE, FALSE, FALSE);
       else
-        h = ((struct elf_link_hash_entry *) bfd_wrapped_link_hash_lookup
-             (abfd, info, name, TRUE, FALSE, FALSE));
+       h = ((struct elf_link_hash_entry *) bfd_wrapped_link_hash_lookup
+            (abfd, info, name, TRUE, FALSE, FALSE));
       if (h == NULL)
-        goto error_free_sym;
+       goto error_free_sym;
 
       *sym_hash = h;
 
@@ -5025,9 +5052,9 @@ error_free_dyn:
              break;
 
            case bfd_link_hash_defined:
-              if (abfd->selective_search)
-                continue;
-              /* Fall-through.  */
+             if (abfd->selective_search)
+               continue;
+             /* Fall-through.  */
            case bfd_link_hash_defweak:
              old_bfd = h->root.u.def.section->owner;
              break;
@@ -5120,17 +5147,19 @@ error_free_dyn:
                {
                  /* PR binutils/2735 */
                  if (normal_bfd == NULL)
-                   (*_bfd_error_handler)
-                     (_("Warning: alignment %u of common symbol `%s' in %B"
-                        " is greater than the alignment (%u) of its section %A"),
-                      common_bfd, h->root.u.def.section,
-                      1 << common_align, name, 1 << normal_align);
+                   _bfd_error_handler
+                     /* xgettext:c-format */
+                     (_("warning: alignment %u of common symbol `%s' in %pB"
+                        " is greater than the alignment (%u) of its section %pA"),
+                      1 << common_align, name, common_bfd,
+                      1 << normal_align, h->root.u.def.section);
                  else
-                   (*_bfd_error_handler)
-                     (_("Warning: alignment %u of symbol `%s' in %B"
-                        " is smaller than %u in %B"),
-                      normal_bfd, common_bfd,
-                      1 << normal_align, name, 1 << common_align);
+                   _bfd_error_handler
+                     /* xgettext:c-format */
+                     (_("warning: alignment %u of symbol `%s' in %pB"
+                        " is smaller than %u in %pB"),
+                      1 << normal_align, name, normal_bfd,
+                      1 << common_align, common_bfd);
                }
            }
 
@@ -5141,12 +5170,12 @@ error_free_dyn:
              if (h->size != 0
                  && h->size != isym->st_size
                  && ! size_change_ok)
-               (*_bfd_error_handler)
-                 (_("Warning: size of symbol `%s' changed"
-                    " from %lu in %B to %lu in %B"),
-                  old_bfd, abfd,
-                  name, (unsigned long) h->size,
-                  (unsigned long) isym->st_size);
+               _bfd_error_handler
+                 /* xgettext:c-format */
+                 (_("warning: size of symbol `%s' changed"
+                    " from %" PRIu64 " in %pB to %" PRIu64 " in %pB"),
+                  name, (uint64_t) h->size, old_bfd,
+                  (uint64_t) isym->st_size, abfd);
 
              h->size = isym->st_size;
            }
@@ -5168,10 +5197,11 @@ error_free_dyn:
              if (h->type != type)
                {
                  if (h->type != STT_NOTYPE && ! type_change_ok)
-                   (*_bfd_error_handler)
-                     (_("Warning: type of symbol `%s' changed"
-                        " from %d to %d in %B"),
-                      abfd, name, h->type, type);
+                   _bfd_error_handler
+                     /* xgettext:c-format */
+                     (_("warning: type of symbol `%s' changed"
+                        " from %d to %d in %pB"),
+                      name, h->type, type, abfd);
 
                  h->type = type;
                }
@@ -5192,25 +5222,22 @@ error_free_dyn:
                }
              else
                {
-                  BFD_ASSERT (!h->def_dynamic);
+                 BFD_ASSERT (!h->def_dynamic);
                  h->def_regular = 1;
                }
            }
          else
            {
              BFD_ASSERT (definition);
-              h->def_dynamic = 1;
-              h->dynindx = -2;
-              ((struct elf64_ia64_link_hash_entry *)h)->shl = abfd;
+             h->def_dynamic = 1;
+             h->dynindx = -2;
+             ((struct elf64_ia64_link_hash_entry *)h)->shl = abfd;
            }
        }
     }
 
-  if (isymbuf != NULL)
-    {
-      free (isymbuf);
-      isymbuf = NULL;
-    }
+  free (isymbuf);
+  isymbuf = NULL;
 
   /* If this object is the same format as the output object, and it is
      not a shared library, then let the backend look through the
@@ -5267,8 +5294,7 @@ error_free_dyn:
 
  error_free_vers:
  error_free_sym:
-  if (isymbuf != NULL)
-    free (isymbuf);
+  free (isymbuf);
  error_return:
   return FALSE;
 }
@@ -5314,10 +5340,10 @@ elf64_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
             entry if it is the tail, because that would lose any
             entries we add to the list later on.  */
          if (*pundef != info->hash->undefs_tail)
-            {
-              *pundef = *next_pundef;
-              next_pundef = pundef;
-            }
+           {
+             *pundef = *next_pundef;
+             next_pundef = pundef;
+           }
          continue;
        }
 
@@ -5334,33 +5360,33 @@ elf64_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
        return FALSE;
 
       if (element->archive_pass == -1 || element->archive_pass == pass)
-        {
-          /* Next symbol if this archive is wrong or already handled.  */
-          continue;
-        }
+       {
+         /* Next symbol if this archive is wrong or already handled.  */
+         continue;
+       }
 
       orig_element = element;
       if (bfd_is_thin_archive (abfd))
-        {
-          element = _bfd_vms_lib_get_imagelib_file (element);
-          if (element == NULL || !bfd_check_format (element, bfd_object))
-            {
-              orig_element->archive_pass = -1;
-              return FALSE;
-            }
-        }
+       {
+         element = _bfd_vms_lib_get_imagelib_file (element);
+         if (element == NULL || !bfd_check_format (element, bfd_object))
+           {
+             orig_element->archive_pass = -1;
+             return FALSE;
+           }
+       }
       else if (! bfd_check_format (element, bfd_object))
-        {
-          element->archive_pass = -1;
-          return FALSE;
-        }
+       {
+         element->archive_pass = -1;
+         return FALSE;
+       }
 
       /* Unlike the generic linker, we know that this element provides
         a definition for an undefined symbol and we know that we want
         to include it.  We don't need to check anything.  */
       if (! (*info->callbacks->add_archive_element) (info, element,
-                                                     h->root.string, &element))
-       return FALSE;
+                                                    h->root.string, &element))
+       continue;
       if (! elf64_vms_link_add_object_symbols (element, info))
        return FALSE;
 
@@ -5458,8 +5484,6 @@ static const struct elf_size_info elf64_ia64_vms_size_info = {
 /* Stuff for the BFD linker: */
 #define bfd_elf64_bfd_link_hash_table_create \
        elf64_ia64_hash_table_create
-#define bfd_elf64_bfd_link_hash_table_free \
-       elf64_ia64_hash_table_free
 #define elf_backend_create_dynamic_sections \
        elf64_ia64_create_dynamic_sections
 #define elf_backend_check_relocs \
@@ -5469,7 +5493,7 @@ static const struct elf_size_info elf64_ia64_vms_size_info = {
 #define elf_backend_size_dynamic_sections \
        elf64_ia64_size_dynamic_sections
 #define elf_backend_omit_section_dynsym \
-  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
+       _bfd_elf_omit_section_dynsym_all
 #define elf_backend_relocate_section \
        elf64_ia64_relocate_section
 #define elf_backend_finish_dynamic_symbol \
@@ -5526,8 +5550,8 @@ static const struct elf_size_info elf64_ia64_vms_size_info = {
 #undef  elf_backend_section_from_shdr
 #define elf_backend_section_from_shdr elf64_vms_section_from_shdr
 
-#undef  elf_backend_post_process_headers
-#define elf_backend_post_process_headers elf64_vms_post_process_headers
+#undef  elf_backend_init_file_header
+#define elf_backend_init_file_header elf64_vms_init_file_header
 
 #undef  elf_backend_section_processing
 #define elf_backend_section_processing elf64_vms_section_processing
@@ -5591,10 +5615,10 @@ static const struct elf_size_info elf64_ia64_vms_size_info = {
 
 /* VMS link methods.  */
 #undef  bfd_elf64_bfd_link_add_symbols
-#define bfd_elf64_bfd_link_add_symbols         elf64_vms_bfd_link_add_symbols
+#define bfd_elf64_bfd_link_add_symbols elf64_vms_bfd_link_add_symbols
 
 #undef  elf_backend_want_got_sym
-#define elf_backend_want_got_sym       0
+#define elf_backend_want_got_sym       0
 
 #undef  bfd_elf64_mkobject
 #define bfd_elf64_mkobject             elf64_ia64_vms_mkobject