Change regcache list to be an hash map
[deliverable/binutils-gdb.git] / bfd / elf64-ia64-vms.c
index 4d371273555230c5f7e3e15c34450d4125603ae8..d0cb7e08e108dcd10c44daba7b279a52357b5436 100644 (file)
@@ -1,5 +1,5 @@
 /* IA-64 support for OpenVMS
-   Copyright (C) 1998-2018 Free Software Foundation, Inc.
+   Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -240,13 +240,24 @@ static asection *get_got
 
 /* Given a ELF reloc, return the matching HOWTO structure.  */
 
-static void
+static bfd_boolean
 elf64_ia64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
                          arelent *bfd_reloc,
                          Elf_Internal_Rela *elf_reloc)
 {
-  bfd_reloc->howto
-    = ia64_elf_lookup_howto ((unsigned int) ELF64_R_TYPE (elf_reloc->r_info));
+  unsigned int r_type = ELF32_R_TYPE (elf_reloc->r_info);
+
+  bfd_reloc->howto = ia64_elf_lookup_howto (r_type);
+  if (bfd_reloc->howto == NULL)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  return TRUE;
 }
 
 
@@ -584,9 +595,9 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec,
            {
              _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);
+               (_("%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;
            }
@@ -829,7 +840,7 @@ elf64_ia64_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr,
 {
   const char *name;
 
-  name = bfd_get_section_name (abfd, sec);
+  name = bfd_section_name (sec);
 
   if (is_unwind_section_name (abfd, name))
     {
@@ -1275,12 +1286,12 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
   s = bfd_make_section_anyway_with_flags (abfd, ".dynamic",
                                          flags | SEC_READONLY);
   if (s == NULL
-      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+      || !bfd_set_section_alignment (s, bed->s->log_file_align))
     return FALSE;
 
   s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags | SEC_READONLY);
   if (s == NULL
-      || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+      || !bfd_set_section_alignment (s, bed->plt_alignment))
     return FALSE;
   ia64_info->root.splt = s;
 
@@ -1296,7 +1307,7 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
                                           | SEC_IN_MEMORY
                                           | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, 0))
+      || !bfd_set_section_alignment (s, 0))
     return FALSE;
 
   /* Create a fixup section.  */
@@ -1306,7 +1317,7 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
                                           | SEC_IN_MEMORY
                                           | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, 3))
+      || !bfd_set_section_alignment (s, 3))
     return FALSE;
   ia64_info->fixups_sec = s;
 
@@ -1317,7 +1328,7 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
                                           | SEC_IN_MEMORY
                                           | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, 3))
+      || !bfd_set_section_alignment (s, 3))
     return FALSE;
   s->size = sizeof (struct elf64_vms_transfer);
   ia64_info->transfer_sec = s;
@@ -1329,7 +1340,7 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
                                           | SEC_IN_MEMORY
                                           | SEC_READONLY));
   if (s == NULL
-      || !bfd_set_section_alignment (abfd, s, 3))
+      || !bfd_set_section_alignment (s, 3))
     return FALSE;
   ia64_info->note_sec = s;
 
@@ -1727,7 +1738,7 @@ get_got (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
       got = bfd_make_section_anyway_with_flags (dynobj, ".got",
                                                flags | SEC_SMALL_DATA);
       if (got == NULL
-         || !bfd_set_section_alignment (dynobj, got, 3))
+         || !bfd_set_section_alignment (got, 3))
        return NULL;
       ia64_info->root.sgot = got;
     }
@@ -1763,7 +1774,7 @@ get_fptr (bfd *abfd, struct bfd_link_info *info,
                                                     : SEC_READONLY)
                                                  | SEC_LINKER_CREATED));
       if (!fptr
-         || !bfd_set_section_alignment (dynobj, fptr, 4))
+         || !bfd_set_section_alignment (fptr, 4))
        {
          BFD_ASSERT (0);
          return NULL;
@@ -1781,7 +1792,7 @@ get_fptr (bfd *abfd, struct bfd_link_info *info,
                                                          | SEC_LINKER_CREATED
                                                          | SEC_READONLY));
          if (fptr_rel == NULL
-             || !bfd_set_section_alignment (dynobj, fptr_rel, 3))
+             || !bfd_set_section_alignment (fptr_rel, 3))
            {
              BFD_ASSERT (0);
              return NULL;
@@ -1816,7 +1827,7 @@ get_pltoff (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
                                                    | SEC_SMALL_DATA
                                                    | SEC_LINKER_CREATED));
       if (!pltoff
-         || !bfd_set_section_alignment (dynobj, pltoff, 4))
+         || !bfd_set_section_alignment (pltoff, 4))
        {
          BFD_ASSERT (0);
          return NULL;
@@ -1844,11 +1855,9 @@ get_reloc_section (bfd *abfd,
     return NULL;
 
   BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela")
-              && strcmp (bfd_get_section_name (abfd, sec),
-                         srel_name+5) == 0)
+              && strcmp (bfd_section_name (sec), srel_name+5) == 0)
              || (CONST_STRNEQ (srel_name, ".rel")
-                 && strcmp (bfd_get_section_name (abfd, sec),
-                            srel_name+4) == 0));
+                 && strcmp (bfd_section_name (sec), srel_name+4) == 0));
 
   dynobj = ia64_info->root.dynobj;
   if (!dynobj)
@@ -1864,7 +1873,7 @@ get_reloc_section (bfd *abfd,
                                                  | SEC_LINKER_CREATED
                                                  | SEC_READONLY));
       if (srel == NULL
-         || !bfd_set_section_alignment (dynobj, srel, 3))
+         || !bfd_set_section_alignment (srel, 3))
        return NULL;
     }
 
@@ -2739,7 +2748,7 @@ elf64_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;
@@ -3278,8 +3287,8 @@ elf64_ia64_choose_gp (bfd *abfd, struct bfd_link_info *info, bfd_boolean final)
 overflow:
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B: short data segment overflowed (%#Lx >= 0x400000)"),
-            abfd, max_short_vma - min_short_vma);
+           (_("%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
@@ -3288,7 +3297,7 @@ overflow:
                   && max_short_vma - gp_val >= 0x200000))
        {
          _bfd_error_handler
-           (_("%B: __gp does not cover short data segment"), abfd);
+           (_("%pB: __gp does not cover short data segment"), abfd);
          return FALSE;
        }
     }
@@ -3425,16 +3434,20 @@ elf64_ia64_relocate_section (bfd *output_bfd,
       r_type = ELF64_R_TYPE (rel->r_info);
       if (r_type > R_IA64_MAX_RELOC_CODE)
        {
-         _bfd_error_handler
-           /* xgettext:c-format */
-           (_("%B: unknown relocation type %d"),
-            input_bfd, (int) r_type);
+         /* xgettext:c-format */
+         _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                             input_bfd, (int) r_type);
          bfd_set_error (bfd_error_bad_value);
          ret_val = FALSE;
          continue;
        }
 
       howto = ia64_elf_lookup_howto (r_type);
+      if (howto == NULL)
+       {
+         ret_val = FALSE;
+         continue;
+       }
       r_symndx = ELF64_R_SYM (rel->r_info);
       h = NULL;
       sym = NULL;
@@ -3554,7 +3567,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
                     shared libraries nor dynamic executables.  */
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("%B: non-pic code with imm relocation against"
+                   (_("%pB: non-pic code with imm relocation against"
                       " dynamic symbol `%s'"),
                     input_bfd,
                     h ? h->root.root.string
@@ -3618,7 +3631,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B: @gprel relocation against dynamic symbol %s"),
+               (_("%pB: @gprel relocation against dynamic symbol %s"),
                 input_bfd,
                 h ? h->root.root.string
                   : bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
@@ -3677,7 +3690,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
                      /* ??? 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"),
+                       (_("%pB: linking non-pic code in a position independent executable"),
                         input_bfd);
                      ret_val = FALSE;
                      continue;
@@ -3779,13 +3792,13 @@ elf64_ia64_relocate_section (bfd *output_bfd,
 
              if (r_type == R_IA64_PCREL21BI)
                /* xgettext:c-format */
-               msg = _("%B: @internal branch to dynamic symbol %s");
+               msg = _("%pB: @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");
+               msg = _("%pB: speculation fixup to dynamic symbol %s");
              else
                /* xgettext:c-format */
-               msg = _("%B: @pcrel relocation against dynamic symbol %s");
+               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,
@@ -3946,10 +3959,10 @@ elf64_ia64_relocate_section (bfd *output_bfd,
              case R_IA64_LTOFF_DTPREL22:
                _bfd_error_handler
                  /* xgettext:c-format */
-                 (_("%B: missing TLS section for relocation %s against `%s'"
-                    " at %#Lx in section `%A'."),
+                 (_("%pB: missing TLS section for relocation %s against `%s'"
+                    " at %#" PRIx64 " in section `%pA'."),
                   input_bfd, howto->name, name,
-                  rel->r_offset, input_section);
+                  (uint64_t) rel->r_offset, input_section);
                break;
 
              case R_IA64_PCREL21B:
@@ -3963,10 +3976,11 @@ elf64_ia64_relocate_section (bfd *output_bfd,
                       that the section is too big to relax.  */
                    _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);
+                     (_("%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.  */
@@ -4254,7 +4268,7 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   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"),
+       (_("%pB: linking trap-on-NULL-dereference with non-trapping files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4263,7 +4277,7 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   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"),
+       (_("%pB: linking big-endian files with little-endian files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4272,7 +4286,7 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   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"),
+       (_("%pB: linking 64-bit files with 32-bit files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4281,7 +4295,7 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   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"),
+       (_("%pB: linking constant-gp files with non-constant-gp files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4291,7 +4305,7 @@ elf64_ia64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
       != (out_flags & EF_IA_64_NOFUNCDESC_CONS_GP))
     {
       _bfd_error_handler
-       (_("%B: linking auto-pic files with non-auto-pic files"),
+       (_("%pB: linking auto-pic files with non-auto-pic files"),
         ibfd);
 
       bfd_set_error (bfd_error_bad_value);
@@ -4485,8 +4499,8 @@ elf64_vms_section_from_shdr (bfd *abfd,
     {
       asection *newsect = hdr->bfd_section;
 
-      if (! bfd_set_section_flags
-         (abfd, newsect, bfd_get_section_flags (abfd, newsect) | secflags))
+      if (!bfd_set_section_flags (newsect,
+                                 bfd_section_flags (newsect) | secflags))
        return FALSE;
     }
 
@@ -4597,14 +4611,18 @@ elf64_vms_object_p (bfd *abfd)
   return TRUE;
 }
 
-static void
-elf64_vms_post_process_headers (bfd *abfd,
-                               struct bfd_link_info *info ATTRIBUTE_UNUSED)
+static bfd_boolean
+elf64_vms_init_file_header (bfd *abfd, struct bfd_link_info *info)
 {
-  Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
+  Elf_Internal_Ehdr *i_ehdrp;
 
+  if (!_bfd_elf_init_file_header (abfd, info))
+    return FALSE;
+
+  i_ehdrp = elf_elfheader (abfd);
   i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_OPENVMS;
   i_ehdrp->e_ident[EI_ABIVERSION] = 2;
+  return TRUE;
 }
 
 static bfd_boolean
@@ -4613,7 +4631,7 @@ elf64_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED,
 {
   if (hdr->bfd_section != NULL)
     {
-      const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
+      const char *name = bfd_section_name (hdr->bfd_section);
 
       if (strcmp (name, ".text") == 0)
        hdr->sh_flags |= SHF_IA_64_VMS_SHARED;
@@ -4643,9 +4661,8 @@ elf64_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED,
 /* The final processing done just before writing out a VMS IA-64 ELF
    object file.  */
 
-static void
-elf64_vms_final_write_processing (bfd *abfd,
-                                 bfd_boolean linker ATTRIBUTE_UNUSED)
+static bfd_boolean
+elf64_vms_final_write_processing (bfd *abfd)
 {
   Elf_Internal_Shdr *hdr;
   asection *s;
@@ -4655,7 +4672,7 @@ elf64_vms_final_write_processing (bfd *abfd,
     {
       hdr = &elf_section_data (s)->this_hdr;
 
-      if (strcmp (bfd_get_section_name (abfd, hdr->bfd_section),
+      if (strcmp (bfd_section_name (hdr->bfd_section),
                  ".IA_64.unwind_info") == 0)
        unwind_info_sect_idx = elf_section_data (s)->this_idx;
 
@@ -4680,6 +4697,7 @@ elf64_vms_final_write_processing (bfd *abfd,
       elf_elfheader (abfd)->e_flags = flags;
       elf_flags_init (abfd) = TRUE;
     }
+  return _bfd_elf_final_write_processing (abfd);
 }
 
 static bfd_boolean
@@ -5134,15 +5152,15 @@ error_free_dyn:
                  if (normal_bfd == NULL)
                    _bfd_error_handler
                      /* xgettext:c-format */
-                     (_("Warning: alignment %u of common symbol `%s' in %B"
-                        " is greater than the alignment (%u) of its section %A"),
+                     (_("warning: alignment %u of common symbol `%s' in %pB"
+                        " is greater than the alignment (%u) of its section %pA"),
                       1 << common_align, name, common_bfd,
                       1 << normal_align, h->root.u.def.section);
                  else
                    _bfd_error_handler
                      /* xgettext:c-format */
-                     (_("Warning: alignment %u of symbol `%s' in %B"
-                        " is smaller than %u in %B"),
+                     (_("warning: alignment %u of symbol `%s' in %pB"
+                        " is smaller than %u in %pB"),
                       1 << normal_align, name, normal_bfd,
                       1 << common_align, common_bfd);
                }
@@ -5157,9 +5175,10 @@ error_free_dyn:
                  && ! size_change_ok)
                _bfd_error_handler
                  /* xgettext:c-format */
-                 (_("Warning: size of symbol `%s' changed"
-                    " from %Lu in %B to %Lu in %B"),
-                  name, h->size, old_bfd, isym->st_size, abfd);
+                 (_("warning: size of symbol `%s' changed"
+                    " from %" PRIu64 " in %pB to %" PRIu64 " in %pB"),
+                  name, (uint64_t) h->size, old_bfd,
+                  (uint64_t) isym->st_size, abfd);
 
              h->size = isym->st_size;
            }
@@ -5183,8 +5202,8 @@ error_free_dyn:
                  if (h->type != STT_NOTYPE && ! type_change_ok)
                    _bfd_error_handler
                      /* xgettext:c-format */
-                     (_("Warning: type of symbol `%s' changed"
-                        " from %d to %d in %B"),
+                     (_("warning: type of symbol `%s' changed"
+                        " from %d to %d in %pB"),
                       name, h->type, type, abfd);
 
                  h->type = type;
@@ -5481,7 +5500,7 @@ static const struct elf_size_info elf64_ia64_vms_size_info = {
 #define elf_backend_size_dynamic_sections \
        elf64_ia64_size_dynamic_sections
 #define elf_backend_omit_section_dynsym \
-  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true_any)
+       _bfd_elf_omit_section_dynsym_all
 #define elf_backend_relocate_section \
        elf64_ia64_relocate_section
 #define elf_backend_finish_dynamic_symbol \
@@ -5538,8 +5557,8 @@ static const struct elf_size_info elf64_ia64_vms_size_info = {
 #undef  elf_backend_section_from_shdr
 #define elf_backend_section_from_shdr elf64_vms_section_from_shdr
 
-#undef  elf_backend_post_process_headers
-#define elf_backend_post_process_headers elf64_vms_post_process_headers
+#undef  elf_backend_init_file_header
+#define elf_backend_init_file_header elf64_vms_init_file_header
 
 #undef  elf_backend_section_processing
 #define elf_backend_section_processing elf64_vms_section_processing
This page took 0.03202 seconds and 4 git commands to generate.