gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / bfd / elfnn-ia64.c
index 05c2f1b4db8e4c36e70d167fe61394f77c1270ba..d179bc45686b708d4a6420ac8a0ad8455a2c01ad 100644 (file)
@@ -1,6 +1,5 @@
 /* IA-64 support for 64-bit ELF
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -28,7 +27,6 @@
 #include "elf/ia64.h"
 #include "objalloc.h"
 #include "hashtab.h"
-#include "bfd_stdint.h"
 #include "elfxx-ia64.h"
 
 #define ARCH_SIZE      NN
 #define        LOG_SECTION_ALIGN       2
 #endif
 
+#define is_ia64_elf(bfd)                          \
+  (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+   && elf_object_id (bfd) == IA64_ELF_DATA)
+
 typedef struct bfd_hash_entry *(*new_hash_entry_func)
   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
 
@@ -198,13 +200,24 @@ static asection *get_pltoff
 
 /* Given a ELF reloc, return the matching HOWTO structure.  */
 
-static void
+static bfd_boolean
 elfNN_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) ELFNN_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;
 }
 \f
 #define PLT_HEADER_SIZE                (3 * 16)
@@ -214,54 +227,54 @@ elfNN_ia64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
 
 static const bfd_byte plt_header[PLT_HEADER_SIZE] =
 {
-  0x0b, 0x10, 0x00, 0x1c, 0x00, 0x21,  /*   [MMI]       mov r2=r14;;       */
-  0xe0, 0x00, 0x08, 0x00, 0x48, 0x00,  /*               addl r14=0,r2      */
-  0x00, 0x00, 0x04, 0x00,              /*               nop.i 0x0;;        */
-  0x0b, 0x80, 0x20, 0x1c, 0x18, 0x14,  /*   [MMI]       ld8 r16=[r14],8;;  */
-  0x10, 0x41, 0x38, 0x30, 0x28, 0x00,  /*               ld8 r17=[r14],8    */
-  0x00, 0x00, 0x04, 0x00,              /*               nop.i 0x0;;        */
-  0x11, 0x08, 0x00, 0x1c, 0x18, 0x10,  /*   [MIB]       ld8 r1=[r14]       */
-  0x60, 0x88, 0x04, 0x80, 0x03, 0x00,  /*               mov b6=r17         */
-  0x60, 0x00, 0x80, 0x00               /*               br.few b6;;        */
+  0x0b, 0x10, 0x00, 0x1c, 0x00, 0x21,  /*   [MMI]      mov r2=r14;;       */
+  0xe0, 0x00, 0x08, 0x00, 0x48, 0x00,  /*              addl r14=0,r2      */
+  0x00, 0x00, 0x04, 0x00,             /*               nop.i 0x0;;        */
+  0x0b, 0x80, 0x20, 0x1c, 0x18, 0x14,  /*   [MMI]      ld8 r16=[r14],8;;  */
+  0x10, 0x41, 0x38, 0x30, 0x28, 0x00,  /*              ld8 r17=[r14],8    */
+  0x00, 0x00, 0x04, 0x00,             /*               nop.i 0x0;;        */
+  0x11, 0x08, 0x00, 0x1c, 0x18, 0x10,  /*   [MIB]      ld8 r1=[r14]       */
+  0x60, 0x88, 0x04, 0x80, 0x03, 0x00,  /*              mov b6=r17         */
+  0x60, 0x00, 0x80, 0x00              /*               br.few b6;;        */
 };
 
 static const bfd_byte plt_min_entry[PLT_MIN_ENTRY_SIZE] =
 {
-  0x11, 0x78, 0x00, 0x00, 0x00, 0x24,  /*   [MIB]       mov r15=0          */
-  0x00, 0x00, 0x00, 0x02, 0x00, 0x00,  /*               nop.i 0x0          */
-  0x00, 0x00, 0x00, 0x40               /*               br.few 0 <PLT0>;;  */
+  0x11, 0x78, 0x00, 0x00, 0x00, 0x24,  /*   [MIB]      mov r15=0          */
+  0x00, 0x00, 0x00, 0x02, 0x00, 0x00,  /*              nop.i 0x0          */
+  0x00, 0x00, 0x00, 0x40              /*               br.few 0 <PLT0>;;  */
 };
 
 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;;        */
 };
 
 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
 
 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
 };
 
 static const bfd_byte oor_ip[48] =
 {
-  0x04, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MLX]        nop.m 0            */
-  0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,  /*               movl r15=0         */
+  0x04, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MLX]       nop.m 0            */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,  /*              movl r15=0         */
   0x01, 0x00, 0x00, 0x60,
-  0x03, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MII]        nop.m 0            */
-  0x00, 0x01, 0x00, 0x60, 0x00, 0x00,  /*               mov r16=ip;;       */
-  0xf2, 0x80, 0x00, 0x80,              /*               add r16=r15,r16;;  */
-  0x11, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MIB]        nop.m 0            */
-  0x60, 0x80, 0x04, 0x80, 0x03, 0x00,  /*               mov b6=r16         */
-  0x60, 0x00, 0x80, 0x00               /*               br b6;;            */
+  0x03, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MII]       nop.m 0            */
+  0x00, 0x01, 0x00, 0x60, 0x00, 0x00,  /*              mov r16=ip;;       */
+  0xf2, 0x80, 0x00, 0x80,             /*               add r16=r15,r16;;  */
+  0x11, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MIB]       nop.m 0            */
+  0x60, 0x80, 0x04, 0x80, 0x03, 0x00,  /*              mov b6=r16         */
+  0x60, 0x00, 0x80, 0x00              /*               br b6;;            */
 };
 
 static size_t oor_branch_size = sizeof (oor_brl);
@@ -347,7 +360,7 @@ elfNN_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"));
 
@@ -594,6 +607,9 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec,
                     1, change it to slot 2.  */
                  if ((irel->r_offset & 3) == 1)
                    irel->r_offset += 1;
+
+                 changed_contents = TRUE;
+                 changed_relocs = TRUE;
                }
 
              continue;
@@ -608,6 +624,9 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec,
 
              /* Make the relocation offset point to slot 1.  */
              irel->r_offset = (irel->r_offset & ~((bfd_vma) 0x3)) + 1;
+
+             changed_contents = TRUE;
+             changed_relocs = TRUE;
              continue;
            }
 
@@ -616,9 +635,11 @@ elfNN_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;
            }
@@ -832,7 +853,7 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec,
        {
          /* Resize .rela.got.  */
          ia64_info->root.srelgot->size = 0;
-         if (link_info->shared
+         if (bfd_link_pic (link_info)
              && ia64_info->self_dtpmod_offset != (bfd_vma) -1)
            ia64_info->root.srelgot->size += sizeof (ElfNN_External_Rela);
          data.only_got = TRUE;
@@ -852,13 +873,11 @@ elfNN_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;
 }
@@ -921,11 +940,10 @@ elfNN_ia64_section_from_shdr (bfd *abfd,
    flag.  */
 
 static bfd_boolean
-elfNN_ia64_section_flags (flagword *flags,
-                         const Elf_Internal_Shdr *hdr)
+elfNN_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;
 }
@@ -939,7 +957,7 @@ elfNN_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))
     {
@@ -985,9 +1003,8 @@ elfNN_ia64_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr,
 /* The final processing done just before writing out an IA-64 ELF
    object file.  */
 
-static void
-elfNN_ia64_final_write_processing (bfd *abfd,
-                                  bfd_boolean linker ATTRIBUTE_UNUSED)
+static bfd_boolean
+elfNN_ia64_final_write_processing (bfd *abfd)
 {
   Elf_Internal_Shdr *hdr;
   asection *s;
@@ -1019,6 +1036,7 @@ elfNN_ia64_final_write_processing (bfd *abfd,
       elf_elfheader(abfd)->e_flags = flags;
       elf_flags_init (abfd) = TRUE;
     }
+  return _bfd_elf_final_write_processing (abfd);
 }
 
 /* Hook called by the linker routine which adds symbols from an object
@@ -1034,7 +1052,7 @@ elfNN_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
@@ -1174,8 +1192,7 @@ elfNN_ia64_modify_segment_map (bfd *abfd,
    for SHF_IA_64_NORECOV on each.  */
 
 static bfd_boolean
-elfNN_ia64_modify_program_headers (bfd *abfd,
-                                  struct bfd_link_info *info ATTRIBUTE_UNUSED)
+elfNN_ia64_modify_headers (bfd *abfd, struct bfd_link_info *info)
 {
   struct elf_obj_tdata *tdata = elf_tdata (abfd);
   struct elf_segment_map *m;
@@ -1207,7 +1224,7 @@ elfNN_ia64_modify_program_headers (bfd *abfd,
       found:;
       }
 
-  return TRUE;
+  return _bfd_elf_modify_headers (abfd, info);
 }
 
 /* According to the Tahoe assembler spec, all labels starting with a
@@ -1274,7 +1291,8 @@ elfNN_ia64_hash_copy_indirect (struct bfd_link_info *info,
   /* Copy down any references that we may have already seen to the
      symbol which just became indirect.  */
 
-  dir->root.ref_dynamic |= ind->root.ref_dynamic;
+  if (dir->root.versioned != versioned_hidden)
+    dir->root.ref_dynamic |= ind->root.ref_dynamic;
   dir->root.ref_regular |= ind->root.ref_regular;
   dir->root.ref_regular_nonweak |= ind->root.ref_regular_nonweak;
   dir->root.needs_plt |= ind->root.needs_plt;
@@ -1290,8 +1308,7 @@ elfNN_ia64_hash_copy_indirect (struct bfd_link_info *info,
       struct elfNN_ia64_dyn_sym_info *dyn_i;
       unsigned int count;
 
-      if (dir->info)
-       free (dir->info);
+      free (dir->info);
 
       dir->info = ind->info;
       dir->count = ind->count;
@@ -1370,40 +1387,6 @@ elfNN_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 *
-elfNN_ia64_hash_table_create (bfd *abfd)
-{
-  struct elfNN_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,
-                                     elfNN_ia64_new_elf_hash_entry,
-                                     sizeof (struct elfNN_ia64_link_hash_entry),
-                                     IA64_ELF_DATA))
-    {
-      free (ret);
-      return NULL;
-    }
-
-  ret->loc_hash_table = htab_try_create (1024, elfNN_ia64_local_htab_hash,
-                                        elfNN_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 elfNN_ia64_dyn_sym_info array.  */
 
 static bfd_boolean
@@ -1413,14 +1396,11 @@ elfNN_ia64_global_dyn_info_free (void **xentry,
   struct elfNN_ia64_link_hash_entry *entry
     = (struct elfNN_ia64_link_hash_entry *) xentry;
 
-  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;
 }
@@ -1434,14 +1414,11 @@ elfNN_ia64_local_dyn_info_free (void **slot,
   struct elfNN_ia64_local_hash_entry *entry
     = (struct elfNN_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;
 }
@@ -1449,10 +1426,10 @@ elfNN_ia64_local_dyn_info_free (void **slot,
 /* Destroy IA-64 linker hash table.  */
 
 static void
-elfNN_ia64_hash_table_free (struct bfd_link_hash_table *hash)
+elfNN_ia64_link_hash_table_free (bfd *obfd)
 {
   struct elfNN_ia64_link_hash_table *ia64_info
-    = (struct elfNN_ia64_link_hash_table *) hash;
+    = (struct elfNN_ia64_link_hash_table *) obfd->link.hash;
   if (ia64_info->loc_hash_table)
     {
       htab_traverse (ia64_info->loc_hash_table,
@@ -1463,7 +1440,42 @@ elfNN_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,
                          elfNN_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 *
+elfNN_ia64_hash_table_create (bfd *abfd)
+{
+  struct elfNN_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,
+                                     elfNN_ia64_new_elf_hash_entry,
+                                     sizeof (struct elfNN_ia64_link_hash_entry),
+                                     IA64_ELF_DATA))
+    {
+      free (ret);
+      return NULL;
+    }
+
+  ret->loc_hash_table = htab_try_create (1024, elfNN_ia64_local_htab_hash,
+                                        elfNN_ia64_local_htab_eq, NULL);
+  ret->loc_hash_memory = objalloc_create ();
+  if (!ret->loc_hash_table || !ret->loc_hash_memory)
+    {
+      elfNN_ia64_link_hash_table_free (abfd);
+      return NULL;
+    }
+  ret->root.root.hash_table_free = elfNN_ia64_link_hash_table_free;
+
+  return &ret->root.root;
 }
 
 /* Traverse both local and global hash tables.  */
@@ -1542,11 +1554,11 @@ elfNN_ia64_create_dynamic_sections (bfd *abfd,
     return FALSE;
 
   {
-    flagword flags = bfd_get_section_flags (abfd, ia64_info->root.sgot);
-    bfd_set_section_flags (abfd, ia64_info->root.sgot,
-                          SEC_SMALL_DATA | flags);
+    flagword flags = bfd_section_flags (ia64_info->root.sgot);
+    bfd_set_section_flags (ia64_info->root.sgot, SEC_SMALL_DATA | flags);
     /* The .got section is always aligned at 8 bytes.  */
-    bfd_set_section_alignment (abfd, ia64_info->root.sgot, 3);
+    if (!bfd_set_section_alignment (ia64_info->root.sgot, 3))
+      return FALSE;
   }
 
   if (!get_pltoff (abfd, info, ia64_info))
@@ -1559,7 +1571,7 @@ elfNN_ia64_create_dynamic_sections (bfd *abfd,
                                           | SEC_LINKER_CREATED
                                           | SEC_READONLY));
   if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, LOG_SECTION_ALIGN))
+      || !bfd_set_section_alignment (s, LOG_SECTION_ALIGN))
     return FALSE;
   ia64_info->rel_pltoff_sec = s;
 
@@ -1842,7 +1854,7 @@ get_dyn_sym_info (struct elfNN_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)
@@ -1892,7 +1904,7 @@ get_dyn_sym_info (struct elfNN_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));
@@ -1952,16 +1964,17 @@ get_got (bfd *abfd, struct bfd_link_info *info,
       if (!dynobj)
        ia64_info->root.dynobj = dynobj = abfd;
       if (!_bfd_elf_create_got_section (dynobj, info))
-       return 0;
+       return NULL;
 
       got = ia64_info->root.sgot;
 
       /* The .got section is always aligned at 8 bytes.  */
-      if (!bfd_set_section_alignment (abfd, got, 3))
-       return 0;
+      if (!bfd_set_section_alignment (got, 3))
+       return NULL;
 
-      flags = bfd_get_section_flags (abfd, got);
-      bfd_set_section_flags (abfd, got, SEC_SMALL_DATA | flags);
+      flags = bfd_section_flags (got);
+      if (!bfd_set_section_flags (got, SEC_SMALL_DATA | flags))
+       return NULL;
     }
 
   return got;
@@ -1991,11 +2004,11 @@ get_fptr (bfd *abfd, struct bfd_link_info *info,
                                                  | SEC_LOAD
                                                  | SEC_HAS_CONTENTS
                                                  | SEC_IN_MEMORY
-                                                 | (info->pie ? 0
-                                                    : SEC_READONLY)
+                                                 | (bfd_link_pie (info)
+                                                    ? 0 : SEC_READONLY)
                                                  | SEC_LINKER_CREATED));
       if (!fptr
-         || !bfd_set_section_alignment (abfd, fptr, 4))
+         || !bfd_set_section_alignment (fptr, 4))
        {
          BFD_ASSERT (0);
          return NULL;
@@ -2003,7 +2016,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",
@@ -2013,8 +2026,7 @@ get_fptr (bfd *abfd, struct bfd_link_info *info,
                                                          | SEC_LINKER_CREATED
                                                          | SEC_READONLY));
          if (fptr_rel == NULL
-             || !bfd_set_section_alignment (abfd, fptr_rel,
-                                            LOG_SECTION_ALIGN))
+             || !bfd_set_section_alignment (fptr_rel, LOG_SECTION_ALIGN))
            {
              BFD_ASSERT (0);
              return NULL;
@@ -2050,7 +2062,7 @@ get_pltoff (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED,
                                                    | SEC_SMALL_DATA
                                                    | SEC_LINKER_CREATED));
       if (!pltoff
-         || !bfd_set_section_alignment (abfd, pltoff, 4))
+         || !bfd_set_section_alignment (pltoff, 4))
        {
          BFD_ASSERT (0);
          return NULL;
@@ -2091,8 +2103,7 @@ get_reloc_section (bfd *abfd,
                                                  | SEC_LINKER_CREATED
                                                  | SEC_READONLY));
       if (srel == NULL
-         || !bfd_set_section_alignment (dynobj, srel,
-                                        LOG_SECTION_ALIGN))
+         || !bfd_set_section_alignment (srel, LOG_SECTION_ALIGN))
        return NULL;
     }
 
@@ -2156,7 +2167,7 @@ elfNN_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;
@@ -2185,11 +2196,14 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
       else
        h = NULL;
 
+      if (h && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
+       continue;
+
       /* We can only get preliminary data on whether a symbol is
         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
@@ -2200,13 +2214,13 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        {
        case R_IA64_TPREL64MSB:
        case R_IA64_TPREL64LSB:
-         if (info->shared || maybe_dynamic)
+         if (bfd_link_pic (info) || maybe_dynamic)
            need_entry = NEED_DYNREL;
          break;
 
        case R_IA64_LTOFF_TPREL22:
          need_entry = NEED_TPREL;
-         if (info->shared)
+         if (bfd_link_pic (info))
            info->flags |= DF_STATIC_TLS;
          break;
 
@@ -2214,7 +2228,7 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_IA64_DTPREL32LSB:
        case R_IA64_DTPREL64MSB:
        case R_IA64_DTPREL64LSB:
-         if (info->shared || maybe_dynamic)
+         if (bfd_link_pic (info) || maybe_dynamic)
            need_entry = NEED_DYNREL;
          break;
 
@@ -2224,7 +2238,7 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
        case R_IA64_DTPMOD64MSB:
        case R_IA64_DTPMOD64LSB:
-         if (info->shared || maybe_dynamic)
+         if (bfd_link_pic (info) || maybe_dynamic)
            need_entry = NEED_DYNREL;
          break;
 
@@ -2246,7 +2260,7 @@ elfNN_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;
@@ -2280,7 +2294,7 @@ elfNN_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
@@ -2297,14 +2311,14 @@ elfNN_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;
 
        case R_IA64_IPLTMSB:
        case R_IA64_IPLTLSB:
          /* 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;
 
@@ -2354,17 +2368,19 @@ elfNN_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
        h = NULL;
 
+      if (h && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
+       continue;
+
       /* We can only get preliminary data on whether a symbol is
         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
@@ -2375,16 +2391,16 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        {
        case R_IA64_TPREL64MSB:
        case R_IA64_TPREL64LSB:
-         if (info->shared || maybe_dynamic)
+         if (bfd_link_pic (info) || maybe_dynamic)
            need_entry = NEED_DYNREL;
          dynrel_type = R_IA64_TPREL64LSB;
-         if (info->shared)
+         if (bfd_link_pic (info))
            info->flags |= DF_STATIC_TLS;
          break;
 
        case R_IA64_LTOFF_TPREL22:
          need_entry = NEED_TPREL;
-         if (info->shared)
+         if (bfd_link_pic (info))
            info->flags |= DF_STATIC_TLS;
          break;
 
@@ -2392,7 +2408,7 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_IA64_DTPREL32LSB:
        case R_IA64_DTPREL64MSB:
        case R_IA64_DTPREL64LSB:
-         if (info->shared || maybe_dynamic)
+         if (bfd_link_pic (info) || maybe_dynamic)
            need_entry = NEED_DYNREL;
          dynrel_type = R_IA64_DTPRELNNLSB;
          break;
@@ -2403,7 +2419,7 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
        case R_IA64_DTPMOD64MSB:
        case R_IA64_DTPMOD64LSB:
-         if (info->shared || maybe_dynamic)
+         if (bfd_link_pic (info) || maybe_dynamic)
            need_entry = NEED_DYNREL;
          dynrel_type = R_IA64_DTPMOD64LSB;
          break;
@@ -2426,7 +2442,7 @@ elfNN_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;
@@ -2455,7 +2471,7 @@ elfNN_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
@@ -2472,7 +2488,7 @@ elfNN_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_DIRNNLSB;
          break;
@@ -2480,7 +2496,7 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_IA64_IPLTMSB:
        case R_IA64_IPLTLSB:
          /* 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_IPLTLSB;
          break;
@@ -2538,7 +2554,7 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
          /* FPTRs for shared libraries are allocated by the dynamic
             linker.  Make sure this local symbol will appear in the
             dynamic symbol table.  */
-         if (!h && info->shared)
+         if (!h && bfd_link_pic (info))
            {
              if (! (bfd_elf_link_record_local_dynamic_symbol
                     (info, abfd, (long) r_symndx)))
@@ -2551,7 +2567,7 @@ elfNN_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;
@@ -2710,9 +2726,10 @@ allocate_fptr (struct elfNN_ia64_dyn_sym_info *dyn_i, void * data)
               || h->root.type == bfd_link_hash_warning)
          h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
-      if (!x->info->executable
+      if (!bfd_link_executable (x->info)
          && (!h
-             || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+             || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+                 && !UNDEFWEAK_NO_DYNAMIC_RELOC (x->info, h))
              || (h->root.type != bfd_link_hash_undefweak
                  && h->root.type != bfd_link_hash_undefined)))
        {
@@ -2839,10 +2856,10 @@ allocate_dynrel_entries (struct elfNN_ia64_dyn_sym_info *dyn_i,
   /* Note that this can't be used in relation to FPTR relocs below.  */
   dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info, 0);
 
-  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);
+                  && UNDEFWEAK_NO_DYNAMIC_RELOC (x->info,
+                                                      dyn_i->h));
 
   /* Take care of the GOT and PLT relocations.  */
 
@@ -2854,7 +2871,7 @@ allocate_dynrel_entries (struct elfNN_ia64_dyn_sym_info *dyn_i,
          && dyn_i->h->dynindx != -1))
     {
       if (!dyn_i->want_ltoff_fptr
-         || !x->info->pie
+         || !bfd_link_pie (x->info)
          || dyn_i->h == NULL
          || dyn_i->h->root.type != bfd_link_hash_undefweak)
        ia64_info->root.srelgot->size += sizeof (ElfNN_External_Rela);
@@ -2904,7 +2921,7 @@ allocate_dynrel_entries (struct elfNN_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:
@@ -2951,12 +2968,12 @@ elfNN_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;
     }
 
@@ -2980,17 +2997,17 @@ elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   bfd *dynobj;
   bfd_boolean relplt = FALSE;
 
-  dynobj = elf_hash_table(info)->dynobj;
   ia64_info = elfNN_ia64_hash_table (info);
   if (ia64_info == NULL)
     return FALSE;
+  dynobj = ia64_info->root.dynobj;
   ia64_info->self_dtpmod_offset = (bfd_vma) -1;
   BFD_ASSERT(dynobj != NULL);
   data.info = info;
 
   /* Set the contents of the .interp section to the interpreter.  */
   if (ia64_info->root.dynamic_sections_created
-      && info->executable)
+      && bfd_link_executable (info) && !info->nointerp)
     {
       sec = bfd_get_linker_section (dynobj, ".interp");
       BFD_ASSERT (sec != NULL);
@@ -3049,8 +3066,7 @@ elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
       /* If we've got a .plt, we need some extra memory for the dynamic
         linker.  We stuff these in .got.plt.  */
-      sec = bfd_get_linker_section (dynobj, ".got.plt");
-      sec->size = 8 * PLT_RESERVED_WORDS;
+      ia64_info->root.sgotplt->size = 8 * PLT_RESERVED_WORDS;
     }
 
   /* Allocate the PLTOFF entries.  */
@@ -3067,7 +3083,7 @@ elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Allocate space for the dynamic relocations that turned out to be
         required.  */
 
-      if (info->shared && ia64_info->self_dtpmod_offset != (bfd_vma) -1)
+      if (bfd_link_pic (info) && ia64_info->self_dtpmod_offset != (bfd_vma) -1)
        ia64_info->root.srelgot->size += sizeof (ElfNN_External_Rela);
       data.only_got = FALSE;
       elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_dynrel_entries, &data);
@@ -3145,7 +3161,7 @@ elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
          /* 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;
@@ -3173,13 +3189,13 @@ elfNN_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        }
     }
 
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (ia64_info->root.dynamic_sections_created)
     {
       /* Add some entries to the .dynamic section.  We fill in the values
         later (in finish_dynamic_sections) but we must add the entries now
         so that we get the correct size for the .dynamic section.  */
 
-      if (info->executable)
+      if (bfd_link_executable (info))
        {
          /* The DT_DEBUG entry is filled in by the dynamic linker and used
             by the debugger.  */
@@ -3313,18 +3329,19 @@ 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
+               || (ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
+                   && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, dyn_i->h))
                || dyn_i->h->root.type != bfd_link_hash_undefweak)
            && dyn_r_type != R_IA64_DTPREL32LSB
            && dyn_r_type != R_IA64_DTPREL64LSB)
-           || elfNN_ia64_dynamic_symbol_p (dyn_i->h, info, dyn_r_type)
+          || elfNN_ia64_dynamic_symbol_p (dyn_i->h, info, dyn_r_type)
           || (dynindx != -1
               && (dyn_r_type == R_IA64_FPTR32LSB
                   || dyn_r_type == R_IA64_FPTR64LSB)))
          && (!dyn_i->want_ltoff_fptr
-             || !info->pie
+             || !bfd_link_pie (info)
              || !dyn_i->h
              || dyn_i->h->root.type != bfd_link_hash_undefweak))
        {
@@ -3477,9 +3494,10 @@ 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
+             || (ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
+                 && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, dyn_i->h))
              || dyn_i->h->root.type != bfd_link_hash_undefweak))
        {
          unsigned int dyn_r_type;
@@ -3678,11 +3696,11 @@ elfNN_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
@@ -3690,9 +3708,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;
        }
     }
@@ -3713,7 +3730,7 @@ elfNN_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;
@@ -3726,7 +3743,7 @@ elfNN_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;
@@ -3739,7 +3756,7 @@ elfNN_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)
@@ -3797,7 +3814,7 @@ elfNN_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;
 
@@ -3831,15 +3848,21 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
       r_type = ELFNN_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 = ELFNN_R_SYM (rel->r_info);
       h = NULL;
       sym = NULL;
@@ -3854,7 +3877,7 @@ elfNN_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)
@@ -3901,17 +3924,17 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
       else
        {
          bfd_boolean unresolved_reloc;
-         bfd_boolean warned;
+         bfd_boolean warned, ignored;
          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,
                                   h, sym_sec, value,
-                                  unresolved_reloc, warned);
+                                  unresolved_reloc, warned, ignored);
 
          if (h->root.type == bfd_link_hash_undefweak)
            undef_weak_ref = TRUE;
-         else if (warned)
+         else if (warned || (ignored && bfd_link_executable (info)))
            continue;
        }
 
@@ -3919,7 +3942,7 @@ elfNN_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;
@@ -3940,7 +3963,8 @@ elfNN_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))
+             && !(h && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
              && r_symndx != STN_UNDEF
              && (input_section->flags & SEC_ALLOC) != 0)
            {
@@ -3957,8 +3981,9 @@ elfNN_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,
@@ -4024,8 +4049,9 @@ elfNN_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,
@@ -4040,7 +4066,7 @@ elfNN_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, (h ? h->dynindx : -1),
                                 rel->r_addend, value, R_IA64_DIRNNLSB);
          value -= gp_val;
@@ -4051,7 +4077,7 @@ elfNN_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);
@@ -4062,13 +4088,13 @@ elfNN_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))
            {
              long dynindx;
              unsigned int dyn_r_type = r_type;
@@ -4087,8 +4113,8 @@ elfNN_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;
@@ -4135,15 +4161,15 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
            if (dyn_i->want_fptr)
              {
                BFD_ASSERT (h == NULL || h->dynindx == -1);
-               if (!undef_weak_ref)
-                 value = set_fptr_entry (output_bfd, info, dyn_i, value);
+               if (!undef_weak_ref)
+                 value = set_fptr_entry (output_bfd, info, dyn_i, value);
                dynindx = -1;
              }
            else
              {
-               /* Otherwise, we expect the dynamic linker to create
+               /* Otherwise, we expect the dynamic linker to create
                   the entry.  */
-               if (h)
+               if (h)
                  {
                    if (h->dynindx != -1)
                      dynindx = h->dynindx;
@@ -4225,17 +4251,20 @@ elfNN_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;
            }
@@ -4289,7 +4318,7 @@ elfNN_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)
            {
              BFD_ASSERT (srel != NULL);
@@ -4366,7 +4395,7 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
                  {
                    if (elf_hash_table (info)->tls_sec == NULL)
                      goto missing_tls_sec;
-                   if (!info->shared)
+                   if (!bfd_link_pic (info))
                      value -= elfNN_ia64_tprel_base (info);
                    else
                      {
@@ -4377,7 +4406,7 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
                got_r_type = R_IA64_TPREL64LSB;
                break;
              case R_IA64_LTOFF_DTPMOD22:
-               if (!dynamic_symbol_p && !info->shared)
+               if (!dynamic_symbol_p && !bfd_link_pic (info))
                  value = 1;
                got_r_type = R_IA64_DTPMOD64LSB;
                break;
@@ -4426,10 +4455,9 @@ elfNN_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;
@@ -4438,7 +4466,7 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
        case bfd_reloc_outofrange:
        case bfd_reloc_overflow:
        default:
-missing_tls_sec:
+       missing_tls_sec:
          {
            const char *name;
 
@@ -4463,10 +4491,12 @@ missing_tls_sec:
              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:
@@ -4478,22 +4508,25 @@ missing_tls_sec:
                    /* 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;
              }
 
@@ -4610,14 +4643,14 @@ elfNN_ia64_finish_dynamic_sections (bfd *abfd,
 
   dynobj = ia64_info->root.dynobj;
 
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (ia64_info->root.dynamic_sections_created)
     {
       ElfNN_External_Dyn *dyncon, *dynconend;
       asection *sdyn, *sgotplt;
       bfd_vma gp_val;
 
       sdyn = bfd_get_linker_section (dynobj, ".dynamic");
-      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+      sgotplt = ia64_info->root.sgotplt;
       BFD_ASSERT (sdyn != NULL);
       dyncon = (ElfNN_External_Dyn *) sdyn->contents;
       dynconend = (ElfNN_External_Dyn *) (sdyn->contents + sdyn->size);
@@ -4653,13 +4686,6 @@ elfNN_ia64_finish_dynamic_sections (bfd *abfd,
              dyn.d_un.d_ptr = (sgotplt->output_section->vma
                                + sgotplt->output_offset);
              break;
-
-           case DT_RELASZ:
-             /* Do not have RELASZ include JMPREL.  This makes things
-                easier on ld.so.  This is not what the rest of BFD set up.  */
-             dyn.d_un.d_val -= (ia64_info->minplt_entries
-                                * sizeof (ElfNN_External_Rela));
-             break;
            }
 
          bfd_elfNN_swap_dyn_out (abfd, &dyn, dyncon);
@@ -4700,17 +4726,21 @@ elfNN_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
-elfNN_ia64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+elfNN_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;
 
-  /* 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)
-    return FALSE;
+  /* FIXME: What should be checked when linking shared libraries?  */
+  if ((ibfd->flags & DYNAMIC) != 0)
+    return TRUE;
+
+  if (!is_ia64_elf (ibfd) || !is_ia64_elf (obfd))
+    return TRUE;
 
   in_flags  = elf_elfheader (ibfd)->e_flags;
   out_flags = elf_elfheader (obfd)->e_flags;
@@ -4740,8 +4770,8 @@ elfNN_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);
@@ -4749,8 +4779,8 @@ elfNN_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);
@@ -4758,8 +4788,8 @@ elfNN_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);
@@ -4767,8 +4797,8 @@ elfNN_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);
@@ -4777,8 +4807,8 @@ elfNN_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);
@@ -4834,9 +4864,9 @@ elfNN_ia64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
 
 static const struct bfd_elf_special_section elfNN_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
@@ -4847,7 +4877,7 @@ elfNN_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;
@@ -4935,18 +4965,22 @@ elfNN_ia64_object_p (bfd *abfd)
 static bfd_boolean
 elfNN_ia64_hpux_vec (const bfd_target *vec)
 {
-  extern const bfd_target bfd_elfNN_ia64_hpux_big_vec;
-  return (vec == & bfd_elfNN_ia64_hpux_big_vec);
+  extern const bfd_target ia64_elfNN_hpux_be_vec;
+  return (vec == &ia64_elfNN_hpux_be_vec);
 }
 
-static void
-elfNN_hpux_post_process_headers (bfd *abfd,
-                                struct bfd_link_info *info ATTRIBUTE_UNUSED)
+static bfd_boolean
+elfNN_hpux_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] = get_elf_backend_data (abfd)->elf_osabi;
   i_ehdrp->e_ident[EI_ABIVERSION] = 1;
+  return TRUE;
 }
 
 static bfd_boolean
@@ -4976,10 +5010,15 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
       break;
     }
 }
+
+static void
+ignore_errors (const char *fmt ATTRIBUTE_UNUSED, ...)
+{
+}
 \f
-#define TARGET_LITTLE_SYM              bfd_elfNN_ia64_little_vec
+#define TARGET_LITTLE_SYM              ia64_elfNN_le_vec
 #define TARGET_LITTLE_NAME             "elfNN-ia64-little"
-#define TARGET_BIG_SYM                 bfd_elfNN_ia64_big_vec
+#define TARGET_BIG_SYM                 ia64_elfNN_be_vec
 #define TARGET_BIG_NAME                        "elfNN-ia64-big"
 #define ELF_ARCH                       bfd_arch_ia64
 #define ELF_TARGET_ID                  IA64_ELF_DATA
@@ -5003,8 +5042,8 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
        elfNN_ia64_additional_program_headers
 #define elf_backend_modify_segment_map \
        elfNN_ia64_modify_segment_map
-#define elf_backend_modify_program_headers \
-       elfNN_ia64_modify_program_headers
+#define elf_backend_modify_headers \
+       elfNN_ia64_modify_headers
 #define elf_info_to_howto \
        elfNN_ia64_info_to_howto
 
@@ -5023,8 +5062,6 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
 /* Stuff for the BFD linker: */
 #define bfd_elfNN_bfd_link_hash_table_create \
        elfNN_ia64_hash_table_create
-#define bfd_elfNN_bfd_link_hash_table_free \
-       elfNN_ia64_hash_table_free
 #define elf_backend_create_dynamic_sections \
        elfNN_ia64_create_dynamic_sections
 #define elf_backend_check_relocs \
@@ -5034,7 +5071,7 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
 #define elf_backend_size_dynamic_sections \
        elfNN_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 \
        elfNN_ia64_relocate_section
 #define elf_backend_finish_dynamic_symbol \
@@ -5052,6 +5089,7 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
        elfNN_ia64_print_private_bfd_data
 
 #define elf_backend_plt_readonly       1
+#define elf_backend_can_gc_sections    1
 #define elf_backend_want_plt_sym       0
 #define elf_backend_plt_alignment      5
 #define elf_backend_got_header_size    0
@@ -5065,6 +5103,7 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
 #define elf_backend_fixup_symbol       _bfd_elf_link_hash_fixup_symbol
 #define elf_backend_reloc_type_class   elfNN_ia64_reloc_type_class
 #define elf_backend_rela_normal                1
+#define elf_backend_dtrel_excludes_plt 1
 #define elf_backend_special_sections   elfNN_ia64_special_sections
 #define elf_backend_default_execstack  0
 
@@ -5073,7 +5112,7 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
    We don't want to flood users with so many error messages. We turn
    off the warning for now. It will be turned on later when the Intel
    compiler is fixed.   */
-#define elf_backend_link_order_error_handler NULL
+#define elf_backend_link_order_error_handler ignore_errors
 
 #include "elfNN-target.h"
 
@@ -5082,14 +5121,14 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
 #undef  TARGET_LITTLE_SYM
 #undef  TARGET_LITTLE_NAME
 #undef  TARGET_BIG_SYM
-#define TARGET_BIG_SYM                  bfd_elfNN_ia64_hpux_big_vec
-#undef  TARGET_BIG_NAME
-#define TARGET_BIG_NAME                 "elfNN-ia64-hpux-big"
+#define TARGET_BIG_SYM                 ia64_elfNN_hpux_be_vec
+#undef TARGET_BIG_NAME
+#define TARGET_BIG_NAME                        "elfNN-ia64-hpux-big"
 
 /* These are HP-UX specific functions.  */
 
-#undef  elf_backend_post_process_headers
-#define elf_backend_post_process_headers elfNN_hpux_post_process_headers
+#undef  elf_backend_init_file_header
+#define elf_backend_init_file_header elfNN_hpux_init_file_header
 
 #undef  elf_backend_section_from_bfd_section
 #define elf_backend_section_from_bfd_section elfNN_hpux_backend_section_from_bfd_section
This page took 0.060413 seconds and 4 git commands to generate.