PowerPC fix for ifunc broken by d1eca1e4
[deliverable/binutils-gdb.git] / bfd / elf64-ia64-vms.c
index 9c2cb4c5eb9c469f7e196378c735ff62de0007c3..dd86e3c630807edc56c136cf684242606b94a3e6 100644 (file)
@@ -1,6 +1,5 @@
 /* IA-64 support for OpenVMS
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2012  Free Software Foundation, Inc.
+   Copyright (C) 1998-2014 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -539,7 +538,7 @@ elf64_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;
@@ -976,40 +975,6 @@ elf64_ia64_local_htab_eq (const void *ptr1, const void *ptr2)
   return entry1->id == entry2->id && entry1->r_sym == entry2->r_sym;
 }
 
-/* Create the derived linker hash table.  The IA-64 ELF port uses this
-   derived hash table to keep information specific to the IA-64 ElF
-   linker (without using static variables).  */
-
-static struct bfd_link_hash_table *
-elf64_ia64_hash_table_create (bfd *abfd)
-{
-  struct elf64_ia64_link_hash_table *ret;
-
-  ret = bfd_zmalloc ((bfd_size_type) sizeof (*ret));
-  if (!ret)
-    return NULL;
-
-  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                     elf64_ia64_new_elf_hash_entry,
-                                     sizeof (struct elf64_ia64_link_hash_entry),
-                                     IA64_ELF_DATA))
-    {
-      free (ret);
-      return NULL;
-    }
-
-  ret->loc_hash_table = htab_try_create (1024, elf64_ia64_local_htab_hash,
-                                        elf64_ia64_local_htab_eq, NULL);
-  ret->loc_hash_memory = objalloc_create ();
-  if (!ret->loc_hash_table || !ret->loc_hash_memory)
-    {
-      free (ret);
-      return NULL;
-    }
-
-  return &ret->root.root;
-}
-
 /* Free the global elf64_ia64_dyn_sym_info array.  */
 
 static bfd_boolean
@@ -1058,10 +1023,10 @@ elf64_ia64_local_dyn_info_free (void **slot,
 /* Destroy IA-64 linker hash table.  */
 
 static void
-elf64_ia64_hash_table_free (struct bfd_link_hash_table *hash)
+elf64_ia64_link_hash_table_free (bfd *obfd)
 {
   struct elf64_ia64_link_hash_table *ia64_info
-    = (struct elf64_ia64_link_hash_table *) hash;
+    = (struct elf64_ia64_link_hash_table *) obfd->link.hash;
   if (ia64_info->loc_hash_table)
     {
       htab_traverse (ia64_info->loc_hash_table,
@@ -1072,7 +1037,42 @@ elf64_ia64_hash_table_free (struct bfd_link_hash_table *hash)
     objalloc_free ((struct objalloc *) ia64_info->loc_hash_memory);
   elf_link_hash_traverse (&ia64_info->root,
                          elf64_ia64_global_dyn_info_free, NULL);
-  _bfd_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 *
+elf64_ia64_hash_table_create (bfd *abfd)
+{
+  struct elf64_ia64_link_hash_table *ret;
+
+  ret = bfd_zmalloc ((bfd_size_type) sizeof (*ret));
+  if (!ret)
+    return NULL;
+
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     elf64_ia64_new_elf_hash_entry,
+                                     sizeof (struct elf64_ia64_link_hash_entry),
+                                     IA64_ELF_DATA))
+    {
+      free (ret);
+      return NULL;
+    }
+
+  ret->loc_hash_table = htab_try_create (1024, elf64_ia64_local_htab_hash,
+                                        elf64_ia64_local_htab_eq, NULL);
+  ret->loc_hash_memory = objalloc_create ();
+  if (!ret->loc_hash_table || !ret->loc_hash_memory)
+    {
+      elf64_ia64_link_hash_table_free (abfd);
+      return NULL;
+    }
+  ret->root.root.hash_table_free = elf64_ia64_link_hash_table_free;
+
+  return &ret->root.root;
 }
 
 /* Traverse both local and global hash tables.  */
@@ -1270,12 +1270,13 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
 
   flags = bed->dynamic_sec_flags;
 
-  s = bfd_make_section_with_flags (abfd, ".dynamic", flags | SEC_READONLY);
+  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))
     return FALSE;
 
-  s = bfd_make_section_with_flags (abfd, ".plt", flags | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags | SEC_READONLY);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
@@ -1287,32 +1288,32 @@ elf64_ia64_create_dynamic_sections (bfd *abfd,
   if (!get_pltoff (abfd, ia64_info))
     return FALSE;
 
-  s = bfd_make_section_with_flags (abfd, ".vmsdynstr",
-                                  (SEC_ALLOC
-                                   | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY
-                                   | SEC_LINKER_CREATED));
+  s = bfd_make_section_anyway_with_flags (abfd, ".vmsdynstr",
+                                         (SEC_ALLOC
+                                          | SEC_HAS_CONTENTS
+                                          | SEC_IN_MEMORY
+                                          | SEC_LINKER_CREATED));
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 0))
     return FALSE;
 
   /* Create a fixup section.  */
-  s = bfd_make_section_with_flags (abfd, ".fixups",
-                                   (SEC_ALLOC
-                                    | SEC_HAS_CONTENTS
-                                    | SEC_IN_MEMORY
-                                    | SEC_LINKER_CREATED));
+  s = bfd_make_section_anyway_with_flags (abfd, ".fixups",
+                                         (SEC_ALLOC
+                                          | SEC_HAS_CONTENTS
+                                          | SEC_IN_MEMORY
+                                          | SEC_LINKER_CREATED));
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
   ia64_info->fixups_sec = s;
 
   /* Create the transfer fixup section.  */
-  s = bfd_make_section_with_flags (abfd, ".transfer",
-                                   (SEC_ALLOC
-                                    | SEC_HAS_CONTENTS
-                                    | SEC_IN_MEMORY
-                                    | SEC_LINKER_CREATED));
+  s = bfd_make_section_anyway_with_flags (abfd, ".transfer",
+                                         (SEC_ALLOC
+                                          | SEC_HAS_CONTENTS
+                                          | SEC_IN_MEMORY
+                                          | SEC_LINKER_CREATED));
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
@@ -1721,7 +1722,8 @@ get_got (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
 
       /* The .got section is always aligned at 8 bytes.  */
       flags = get_elf_backend_data (dynobj)->dynamic_sec_flags;
-      got = bfd_make_section_with_flags (dynobj, ".got", flags | SEC_SMALL_DATA);
+      got = bfd_make_section_anyway_with_flags (dynobj, ".got",
+                                               flags | SEC_SMALL_DATA);
       if (got == NULL
           || !bfd_set_section_alignment (dynobj, got, 3))
         return NULL;
@@ -1750,13 +1752,14 @@ get_fptr (bfd *abfd, struct bfd_link_info *info,
       if (!dynobj)
        ia64_info->root.dynobj = dynobj = abfd;
 
-      fptr = bfd_make_section_with_flags (dynobj, ".opd",
-                                         (SEC_ALLOC
-                                          | SEC_LOAD
-                                          | SEC_HAS_CONTENTS
-                                          | SEC_IN_MEMORY
-                                          | (info->pie ? 0 : SEC_READONLY)
-                                          | SEC_LINKER_CREATED));
+      fptr = bfd_make_section_anyway_with_flags (dynobj, ".opd",
+                                                (SEC_ALLOC
+                                                 | SEC_LOAD
+                                                 | SEC_HAS_CONTENTS
+                                                 | SEC_IN_MEMORY
+                                                 | (info->pie ? 0
+                                                    : SEC_READONLY)
+                                                 | SEC_LINKER_CREATED));
       if (!fptr
          || !bfd_set_section_alignment (dynobj, fptr, 4))
        {
@@ -1769,12 +1772,12 @@ get_fptr (bfd *abfd, struct bfd_link_info *info,
       if (info->pie)
        {
          asection *fptr_rel;
-         fptr_rel = bfd_make_section_with_flags (dynobj, ".rela.opd",
-                                                 (SEC_ALLOC | SEC_LOAD
-                                                  | SEC_HAS_CONTENTS
-                                                  | SEC_IN_MEMORY
-                                                  | SEC_LINKER_CREATED
-                                                  | SEC_READONLY));
+         fptr_rel = bfd_make_section_anyway_with_flags (dynobj, ".rela.opd",
+                                                        (SEC_ALLOC | SEC_LOAD
+                                                         | SEC_HAS_CONTENTS
+                                                         | SEC_IN_MEMORY
+                                                         | SEC_LINKER_CREATED
+                                                         | SEC_READONLY));
          if (fptr_rel == NULL
              || !bfd_set_section_alignment (dynobj, fptr_rel, 3))
            {
@@ -1802,14 +1805,14 @@ get_pltoff (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
       if (!dynobj)
        ia64_info->root.dynobj = dynobj = abfd;
 
-      pltoff = bfd_make_section_with_flags (dynobj,
-                                           ELF_STRING_ia64_pltoff,
-                                           (SEC_ALLOC
-                                            | SEC_LOAD
-                                            | SEC_HAS_CONTENTS
-                                            | SEC_IN_MEMORY
-                                            | SEC_SMALL_DATA
-                                            | SEC_LINKER_CREATED));
+      pltoff = bfd_make_section_anyway_with_flags (dynobj,
+                                                  ELF_STRING_ia64_pltoff,
+                                                  (SEC_ALLOC
+                                                   | SEC_LOAD
+                                                   | SEC_HAS_CONTENTS
+                                                   | SEC_IN_MEMORY
+                                                   | SEC_SMALL_DATA
+                                                   | SEC_LINKER_CREATED));
       if (!pltoff
          || !bfd_set_section_alignment (dynobj, pltoff, 4))
        {
@@ -1849,15 +1852,15 @@ get_reloc_section (bfd *abfd,
   if (!dynobj)
     ia64_info->root.dynobj = dynobj = abfd;
 
-  srel = bfd_get_section_by_name (dynobj, srel_name);
+  srel = bfd_get_linker_section (dynobj, srel_name);
   if (srel == NULL && create)
     {
-      srel = bfd_make_section_with_flags (dynobj, srel_name,
-                                         (SEC_ALLOC | SEC_LOAD
-                                          | SEC_HAS_CONTENTS
-                                          | SEC_IN_MEMORY
-                                          | SEC_LINKER_CREATED
-                                          | SEC_READONLY));
+      srel = bfd_make_section_anyway_with_flags (dynobj, srel_name,
+                                                (SEC_ALLOC | SEC_LOAD
+                                                 | SEC_HAS_CONTENTS
+                                                 | SEC_IN_MEMORY
+                                                 | SEC_LINKER_CREATED
+                                                 | SEC_READONLY));
       if (srel == NULL
          || !bfd_set_section_alignment (dynobj, srel, 3))
        return NULL;
@@ -2092,6 +2095,9 @@ elf64_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 = 1;
          h->ref_regular = 1;
        }
       else
@@ -2773,11 +2779,11 @@ elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       unsigned int time_hi, time_lo;
 
       /* The .dynamic section must exist and be empty.  */
-      dynsec = bfd_get_section_by_name (hash_table->dynobj, ".dynamic");
+      dynsec = bfd_get_linker_section (hash_table->dynobj, ".dynamic");
       BFD_ASSERT (dynsec != NULL);
       BFD_ASSERT (dynsec->size == 0);
 
-      dynstrsec = bfd_get_section_by_name (hash_table->dynobj, ".vmsdynstr");
+      dynstrsec = bfd_get_linker_section (hash_table->dynobj, ".vmsdynstr");
       BFD_ASSERT (dynstrsec != NULL);
       BFD_ASSERT (dynstrsec->size == 0);
       dynstrsec->size = 1;     /* Initial blank.  */
@@ -2813,7 +2819,7 @@ elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
         return FALSE;
 
       /* Add entries for shared libraries.  */
-      for (abfd = info->input_bfds; abfd; abfd = abfd->link_next)
+      for (abfd = info->input_bfds; abfd; abfd = abfd->link.next)
         {
           char *soname;
           size_t soname_len;
@@ -3489,13 +3495,13 @@ elf64_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;
@@ -3508,7 +3514,7 @@ elf64_ia64_relocate_section (bfd *output_bfd,
         section contents zeroed.  Avoid any special processing.  */
       if (sym_sec != NULL && discarded_section (sym_sec))
        RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-                                        rel, relend, howto, contents);
+                                        rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
        continue;
@@ -4027,7 +4033,7 @@ elf64_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;
@@ -4061,7 +4067,7 @@ elf64_ia64_finish_dynamic_sections (bfd *abfd,
       unsigned int unwind_seg = 0;
       unsigned int code_seg = 0;
 
-      sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+      sdyn = bfd_get_linker_section (dynobj, ".dynamic");
       BFD_ASSERT (sdyn != NULL);
       dyncon = (Elf64_External_Dyn *) sdyn->contents;
       dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
@@ -4307,7 +4313,9 @@ elf64_ia64_print_private_bfd_data (bfd *abfd, void * ptr)
 }
 
 static enum elf_reloc_type_class
-elf64_ia64_reloc_type_class (const Elf_Internal_Rela *rela)
+elf64_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) ELF64_R_TYPE (rela->r_info))
     {
@@ -5043,7 +5051,8 @@ error_free_dyn:
        h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
       *sym_hash = h;
-      h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
+      if (definition)
+       h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
 
       /* Set the alignment of a common symbol.  */
       if ((common || bfd_is_com_section (sec))
@@ -5450,8 +5459,6 @@ static const struct elf_size_info elf64_ia64_vms_size_info = {
 /* Stuff for the BFD linker: */
 #define bfd_elf64_bfd_link_hash_table_create \
        elf64_ia64_hash_table_create
-#define bfd_elf64_bfd_link_hash_table_free \
-       elf64_ia64_hash_table_free
 #define elf_backend_create_dynamic_sections \
        elf64_ia64_create_dynamic_sections
 #define elf_backend_check_relocs \
@@ -5504,7 +5511,7 @@ static const struct elf_size_info elf64_ia64_vms_size_info = {
 /* VMS-specific vectors.  */
 
 #undef  TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM              bfd_elf64_ia64_vms_vec
+#define TARGET_LITTLE_SYM              ia64_elf64_vms_vec
 #undef  TARGET_LITTLE_NAME
 #define TARGET_LITTLE_NAME             "elf64-ia64-vms"
 #undef  TARGET_BIG_SYM
This page took 0.043299 seconds and 4 git commands to generate.