Update check for invalid values in pe_bfd_read_buildid function.
[deliverable/binutils-gdb.git] / bfd / elfnn-ia64.c
index 7021ff5355907263eac116b34256eacb81cfb98d..8a2f5e3005f1ea575255916a6ca9898b0de03c60 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-2017 Free Software Foundation, Inc.
    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -347,7 +346,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"));
 
@@ -570,7 +569,7 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec,
             .plt section.  After the first relaxation pass, linker may
             increase the gap between the .plt and .text sections up
             to 32byte.  We assume linker will always insert 32byte
-            between the .plt and .text sections after the the first
+            between the .plt and .text sections after the first
             relaxation pass.  */
          if (tsec == ia64_info->root.splt)
            offset = -0x1000000 + 32;
@@ -616,9 +615,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 */
+               (_("%B: Can't relax br at %#Lx in section `%A'."
+                  " Please use brl or indirect branch."),
+                sec->owner, roff, sec);
              bfd_set_error (bfd_error_bad_value);
              goto error_return;
            }
@@ -832,7 +833,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;
@@ -1034,7 +1035,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
@@ -1094,7 +1095,7 @@ elfNN_ia64_modify_segment_map (bfd *abfd,
   s = bfd_get_section_by_name (abfd, ELF_STRING_ia64_archext);
   if (s && (s->flags & SEC_LOAD))
     {
-      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+      for (m = elf_seg_map (abfd); m != NULL; m = m->next)
        if (m->p_type == PT_IA_64_ARCHEXT)
          break;
       if (m == NULL)
@@ -1109,7 +1110,7 @@ elfNN_ia64_modify_segment_map (bfd *abfd,
          m->sections[0] = s;
 
          /* We want to put it after the PHDR and INTERP segments.  */
-         pm = &elf_tdata (abfd)->segment_map;
+         pm = &elf_seg_map (abfd);
          while (*pm != NULL
                 && ((*pm)->p_type == PT_PHDR
                     || (*pm)->p_type == PT_INTERP))
@@ -1129,7 +1130,7 @@ elfNN_ia64_modify_segment_map (bfd *abfd,
 
       if (s && (s->flags & SEC_LOAD))
        {
-         for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+         for (m = elf_seg_map (abfd); m != NULL; m = m->next)
            if (m->p_type == PT_IA_64_UNWIND)
              {
                int i;
@@ -1158,7 +1159,7 @@ elfNN_ia64_modify_segment_map (bfd *abfd,
              m->next = NULL;
 
              /* We want to put it last.  */
-             pm = &elf_tdata (abfd)->segment_map;
+             pm = &elf_seg_map (abfd);
              while (*pm != NULL)
                pm = &(*pm)->next;
              *pm = m;
@@ -1181,7 +1182,7 @@ elfNN_ia64_modify_program_headers (bfd *abfd,
   struct elf_segment_map *m;
   Elf_Internal_Phdr *p;
 
-  for (p = tdata->phdr, m = tdata->segment_map; m != NULL; m = m->next, p++)
+  for (p = tdata->phdr, m = elf_seg_map (abfd); m != NULL; m = m->next, p++)
     if (m->p_type == PT_LOAD)
       {
        int i;
@@ -1274,7 +1275,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;
@@ -1370,40 +1372,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
@@ -1449,10 +1417,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 +1431,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_generic_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.  */
@@ -1546,7 +1549,8 @@ elfNN_ia64_create_dynamic_sections (bfd *abfd,
     bfd_set_section_flags (abfd, 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 (abfd, ia64_info->root.sgot, 3))
+      return FALSE;
   }
 
   if (!get_pltoff (abfd, info, ia64_info))
@@ -1952,16 +1956,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;
+       return NULL;
 
       flags = bfd_get_section_flags (abfd, got);
-      bfd_set_section_flags (abfd, got, SEC_SMALL_DATA | flags);
+      if (! bfd_set_section_flags (abfd, got, SEC_SMALL_DATA | flags))
+       return NULL;
     }
 
   return got;
@@ -1991,8 +1996,8 @@ 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))
@@ -2003,7 +2008,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",
@@ -2156,7 +2161,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 +2190,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 +2208,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 +2222,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 +2232,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 +2254,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;
@@ -2297,14 +2305,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;
 
@@ -2352,16 +2360,22 @@ elfNN_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
                 || h->root.type == bfd_link_hash_warning)
            h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
+         /* PR15323, ref flags aren't set for references in the same
+            object.  */
+         h->root.non_ir_ref_regular = 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
@@ -2372,16 +2386,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;
 
@@ -2389,7 +2403,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;
@@ -2400,7 +2414,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;
@@ -2423,7 +2437,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;
@@ -2469,7 +2483,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;
@@ -2477,7 +2491,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;
@@ -2535,7 +2549,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)))
@@ -2707,9 +2721,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)))
        {
@@ -2836,10 +2851,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.  */
 
@@ -2851,7 +2866,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);
@@ -2901,7 +2916,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:
@@ -2977,17 +2992,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);
@@ -3046,8 +3061,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.  */
@@ -3064,7 +3078,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);
@@ -3170,13 +3184,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.  */
@@ -3310,9 +3324,10 @@ 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)
@@ -3321,7 +3336,7 @@ set_got_entry (bfd *abfd, struct bfd_link_info *info,
               && (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))
        {
@@ -3474,9 +3489,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;
@@ -3676,10 +3692,10 @@ 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));
+         _bfd_error_handler
+           /* xgettext:c-format */
+           (_("%B: short data segment overflowed (%#Lx >= 0x400000)"),
+            abfd, max_short_vma - min_short_vma);
          return FALSE;
        }
       else if ((gp_val > min_short_vma
@@ -3687,9 +3703,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
+           (_("%B: __gp does not cover short data segment"), abfd);
          return FALSE;
        }
     }
@@ -3710,7 +3725,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;
@@ -3736,7 +3751,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)
@@ -3794,7 +3809,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;
 
@@ -3828,9 +3843,9 @@ 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);
+         _bfd_error_handler
+           /* xgettext:c-format */
+           (_("%B: unknown relocation type %d"), input_bfd, (int) r_type);
          bfd_set_error (bfd_error_bad_value);
          ret_val = FALSE;
          continue;
@@ -3851,7 +3866,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)
@@ -3898,17 +3913,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;
        }
 
@@ -3916,7 +3931,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;
@@ -3937,7 +3952,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)
            {
@@ -3954,7 +3970,8 @@ 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)
+                 _bfd_error_handler
+                   /* xgettext:c-format */
                    (_("%B: non-pic code with imm relocation against dynamic symbol `%s'"),
                     input_bfd,
                     h ? h->root.root.string
@@ -4021,7 +4038,8 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
        case R_IA64_GPREL64LSB:
          if (dynamic_symbol_p)
            {
-             (*_bfd_error_handler)
+             _bfd_error_handler
+               /* xgettext:c-format */
                (_("%B: @gprel relocation against dynamic symbol %s"),
                 input_bfd,
                 h ? h->root.root.string
@@ -4065,7 +4083,7 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
              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;
@@ -4084,7 +4102,7 @@ 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)
+                     _bfd_error_handler
                        (_("%B: linking non-pic code in a position independent executable"),
                         input_bfd);
                      ret_val = FALSE;
@@ -4222,17 +4240,20 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
              const char *msg;
 
              if (r_type == R_IA64_PCREL21BI)
+               /* xgettext:c-format */
                msg = _("%B: @internal branch to dynamic symbol %s");
              else if (r_type == R_IA64_PCREL21F || r_type == R_IA64_PCREL21M)
+               /* xgettext:c-format */
                msg = _("%B: speculation fixup to dynamic symbol %s");
              else
+               /* xgettext:c-format */
                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));
+             _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;
            }
@@ -4286,7 +4307,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);
@@ -4363,7 +4384,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
                      {
@@ -4374,7 +4395,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;
@@ -4423,10 +4444,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;
@@ -4460,10 +4480,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 */
+                 (_("%B: missing TLS section for relocation %s against `%s'"
+                    " at %#Lx in section `%A'."),
+                  input_bfd, howto->name, name,
+                  rel->r_offset, input_section);
                break;
 
              case R_IA64_PCREL21B:
@@ -4475,22 +4497,24 @@ 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 */
+                     (_("%B: Can't relax br (%s) to `%s' at %#Lx"
+                        " in section `%A' with size %#Lx (> 0x1000000)."),
+                      input_bfd, howto->name, name, rel->r_offset,
+                      input_section, 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;
              }
 
@@ -4586,7 +4610,7 @@ elfNN_ia64_finish_dynamic_symbol (bfd *output_bfd,
     }
 
   /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == ia64_info->root.hdynamic
       || h == ia64_info->root.hgot
       || h == ia64_info->root.hplt)
     sym->st_shndx = SHN_ABS;
@@ -4607,14 +4631,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);
@@ -4650,13 +4674,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);
@@ -4698,8 +4715,9 @@ 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;
@@ -4737,7 +4755,7 @@ 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)
+      _bfd_error_handler
        (_("%B: linking trap-on-NULL-dereference with non-trapping files"),
         ibfd);
 
@@ -4746,7 +4764,7 @@ 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)
+      _bfd_error_handler
        (_("%B: linking big-endian files with little-endian files"),
         ibfd);
 
@@ -4755,7 +4773,7 @@ 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)
+      _bfd_error_handler
        (_("%B: linking 64-bit files with 32-bit files"),
         ibfd);
 
@@ -4764,7 +4782,7 @@ 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)
+      _bfd_error_handler
        (_("%B: linking constant-gp files with non-constant-gp files"),
         ibfd);
 
@@ -4774,7 +4792,7 @@ 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)
+      _bfd_error_handler
        (_("%B: linking auto-pic files with non-auto-pic files"),
         ibfd);
 
@@ -4808,7 +4826,9 @@ elfNN_ia64_print_private_bfd_data (bfd *abfd, void * ptr)
 }
 
 static enum elf_reloc_type_class
-elfNN_ia64_reloc_type_class (const Elf_Internal_Rela *rela)
+elfNN_ia64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                            const asection *rel_sec ATTRIBUTE_UNUSED,
+                            const Elf_Internal_Rela *rela)
 {
   switch ((int) ELFNN_R_TYPE (rela->r_info))
     {
@@ -4930,8 +4950,8 @@ 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
@@ -4972,9 +4992,9 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd 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
@@ -5018,8 +5038,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 \
@@ -5060,6 +5078,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
 
@@ -5077,7 +5096,7 @@ 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
+#define TARGET_BIG_SYM                  ia64_elfNN_hpux_be_vec
 #undef  TARGET_BIG_NAME
 #define TARGET_BIG_NAME                 "elfNN-ia64-hpux-big"
 
This page took 0.04454 seconds and 4 git commands to generate.