Update check for invalid values in pe_bfd_read_buildid function.
[deliverable/binutils-gdb.git] / bfd / elfnn-ia64.c
index 22582976e82beffbf21f7dcafe486cd5d25264b4..8a2f5e3005f1ea575255916a6ca9898b0de03c60 100644 (file)
@@ -1,5 +1,5 @@
 /* IA-64 support for 64-bit ELF
-   Copyright (C) 1998-2016 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.
@@ -615,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;
            }
@@ -1273,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;
@@ -2187,6 +2190,9 @@ 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
@@ -2356,12 +2362,15 @@ 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->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
@@ -2714,7 +2723,8 @@ allocate_fptr (struct elfNN_ia64_dyn_sym_info *dyn_i, void * data)
 
       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)))
        {
@@ -2843,8 +2853,8 @@ allocate_dynrel_entries (struct elfNN_ia64_dyn_sym_info *dyn_i,
 
   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.  */
 
@@ -2982,10 +2992,10 @@ 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;
@@ -3051,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.  */
@@ -3175,7 +3184,7 @@ 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
@@ -3317,7 +3326,8 @@ set_got_entry (bfd *abfd, struct bfd_link_info *info,
       /* Install a dynamic relocation if needed.  */
       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)
@@ -3481,7 +3491,8 @@ set_pltoff_entry (bfd *abfd, struct bfd_link_info *info,
       if (!is_plt
          && 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;
@@ -3681,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
@@ -3692,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;
        }
     }
@@ -3833,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;
@@ -3943,6 +3953,7 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
        case R_IA64_DIR64LSB:
          /* Install a dynamic relocation for this reloc.  */
          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)
            {
@@ -3959,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
@@ -4026,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
@@ -4089,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;
@@ -4227,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;
            }
@@ -4428,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;
@@ -4465,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:
@@ -4480,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;
              }
 
@@ -4612,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);
@@ -4655,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);
@@ -4703,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;
@@ -4742,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);
 
@@ -4751,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);
 
@@ -4760,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);
 
@@ -4769,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);
 
@@ -4779,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);
 
@@ -5065,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
 
This page took 0.034571 seconds and 4 git commands to generate.