x86: Add _bfd_x86_elf_gc_mark_hook
[deliverable/binutils-gdb.git] / bfd / elf64-x86-64.c
index 547173b0a700cc8e6a125278defaf53bacd0c370..63aff4630f5f00a7ac9e3d9be5473c0ae3e59d7e 100644 (file)
@@ -985,13 +985,6 @@ static const struct elf_x86_64_backend_data elf_x86_64_arch_bed =
    && elf_tdata (bfd) != NULL                          \
    && elf_object_id (bfd) == X86_64_ELF_DATA)
 
-static bfd_boolean
-elf_x86_64_mkobject (bfd *abfd)
-{
-  return bfd_elf_allocate_object (abfd, sizeof (struct elf_x86_obj_tdata),
-                                 X86_64_ELF_DATA);
-}
-
 #define elf_x86_64_compute_jump_table_size(htab) \
   ((htab)->elf.srelplt->reloc_count * GOT_ENTRY_SIZE)
 
@@ -2421,220 +2414,6 @@ error_return:
   return FALSE;
 }
 
-/* Return the section that should be marked against GC for a given
-   relocation. */
-
-static asection *
-elf_x86_64_gc_mark_hook (asection *sec,
-                        struct bfd_link_info *info,
-                        Elf_Internal_Rela *rel,
-                        struct elf_link_hash_entry *h,
-                        Elf_Internal_Sym *sym)
-{
-  if (h != NULL)
-    switch (ELF32_R_TYPE (rel->r_info))
-      {
-      case R_X86_64_GNU_VTINHERIT:
-      case R_X86_64_GNU_VTENTRY:
-       return NULL;
-      }
-
-  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
-}
-
-/* Adjust a symbol defined by a dynamic object and referenced by a
-   regular object.  The current definition is in some section of the
-   dynamic object, but we're not including those sections.  We have to
-   change the definition to something the rest of the link can
-   understand. */
-
-static bfd_boolean
-elf_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info,
-                                 struct elf_link_hash_entry *h)
-{
-  struct elf_x86_link_hash_table *htab;
-  asection *s, *srel;
-  struct elf_x86_link_hash_entry *eh;
-  struct elf_dyn_relocs *p;
-
-  /* STT_GNU_IFUNC symbol must go through PLT. */
-  if (h->type == STT_GNU_IFUNC)
-    {
-      /* All local STT_GNU_IFUNC references must be treate as local
-        calls via local PLT.  */
-      if (h->ref_regular
-         && SYMBOL_CALLS_LOCAL (info, h))
-       {
-         bfd_size_type pc_count = 0, count = 0;
-         struct elf_dyn_relocs **pp;
-
-         eh = (struct elf_x86_link_hash_entry *) h;
-         for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
-           {
-             pc_count += p->pc_count;
-             p->count -= p->pc_count;
-             p->pc_count = 0;
-             count += p->count;
-             if (p->count == 0)
-               *pp = p->next;
-             else
-               pp = &p->next;
-           }
-
-         if (pc_count || count)
-           {
-             h->non_got_ref = 1;
-             if (pc_count)
-               {
-                 /* Increment PLT reference count only for PC-relative
-                    references.  */
-                 h->needs_plt = 1;
-                 if (h->plt.refcount <= 0)
-                   h->plt.refcount = 1;
-                 else
-                   h->plt.refcount += 1;
-               }
-           }
-       }
-
-      if (h->plt.refcount <= 0)
-       {
-         h->plt.offset = (bfd_vma) -1;
-         h->needs_plt = 0;
-       }
-      return TRUE;
-    }
-
-  /* If this is a function, put it in the procedure linkage table.  We
-     will fill in the contents of the procedure linkage table later,
-     when we know the address of the .got section.  */
-  if (h->type == STT_FUNC
-      || h->needs_plt)
-    {
-      if (h->plt.refcount <= 0
-         || SYMBOL_CALLS_LOCAL (info, h)
-         || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-             && h->root.type == bfd_link_hash_undefweak))
-       {
-         /* This case can occur if we saw a PLT32 reloc in an input
-            file, but the symbol was never referred to by a dynamic
-            object, or if all references were garbage collected.  In
-            such a case, we don't actually need to build a procedure
-            linkage table, and we can just do a PC32 reloc instead.  */
-         h->plt.offset = (bfd_vma) -1;
-         h->needs_plt = 0;
-       }
-
-      return TRUE;
-    }
-  else
-    /* It's possible that we incorrectly decided a .plt reloc was
-       needed for an R_X86_64_PC32 reloc to a non-function sym in
-       check_relocs.  We can't decide accurately between function and
-       non-function syms in check-relocs;  Objects loaded later in
-       the link may change h->type.  So fix it now.  */
-    h->plt.offset = (bfd_vma) -1;
-
-  eh = (struct elf_x86_link_hash_entry *) h;
-
-  /* If this is a weak symbol, and there is a real definition, the
-     processor independent code will have arranged for us to see the
-     real definition first, and we can just use the same value.         */
-  if (h->u.weakdef != NULL)
-    {
-      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
-                 || h->u.weakdef->root.type == bfd_link_hash_defweak);
-      h->root.u.def.section = h->u.weakdef->root.u.def.section;
-      h->root.u.def.value = h->u.weakdef->root.u.def.value;
-      if (ELIMINATE_COPY_RELOCS
-         || info->nocopyreloc
-         || SYMBOL_NO_COPYRELOC (info, eh))
-       {
-         h->non_got_ref = h->u.weakdef->non_got_ref;
-         eh->needs_copy = h->u.weakdef->needs_copy;
-       }
-      return TRUE;
-    }
-
-  /* This is a reference to a symbol defined by a dynamic object which
-     is not a function.         */
-
-  /* If we are creating a shared library, we must presume that the
-     only references to the symbol are via the global offset table.
-     For such cases we need not do anything here; the relocations will
-     be handled correctly by relocate_section. */
-  if (!bfd_link_executable (info))
-    return TRUE;
-
-  /* If there are no references to this symbol that do not use the
-     GOT, we don't need to generate a copy reloc.  */
-  if (!h->non_got_ref)
-    return TRUE;
-
-  /* If -z nocopyreloc was given, we won't generate them either.  */
-  if (info->nocopyreloc || SYMBOL_NO_COPYRELOC (info, eh))
-    {
-      h->non_got_ref = 0;
-      return TRUE;
-    }
-
-  if (ELIMINATE_COPY_RELOCS)
-    {
-      eh = (struct elf_x86_link_hash_entry *) h;
-      for (p = eh->dyn_relocs; p != NULL; p = p->next)
-       {
-         s = p->sec->output_section;
-         if (s != NULL && (s->flags & SEC_READONLY) != 0)
-           break;
-       }
-
-      /* If we didn't find any dynamic relocs in read-only sections, then
-        we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
-      if (p == NULL)
-       {
-         h->non_got_ref = 0;
-         return TRUE;
-       }
-    }
-
-  /* We must allocate the symbol in our .dynbss section, which will
-     become part of the .bss section of the executable.         There will be
-     an entry for this symbol in the .dynsym section.  The dynamic
-     object will contain position independent code, so all references
-     from the dynamic object to this symbol will go through the global
-     offset table.  The dynamic linker will use the .dynsym entry to
-     determine the address it must put in the global offset table, so
-     both the dynamic object and the regular object will refer to the
-     same memory location for the variable.  */
-
-  htab = elf_x86_hash_table (info, X86_64_ELF_DATA);
-  if (htab == NULL)
-    return FALSE;
-
-  /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker
-     to copy the initial value out of the dynamic object and into the
-     runtime process image.  */
-  if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
-    {
-      s = htab->elf.sdynrelro;
-      srel = htab->elf.sreldynrelro;
-    }
-  else
-    {
-      s = htab->elf.sdynbss;
-      srel = htab->elf.srelbss;
-    }
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
-    {
-      const struct elf_backend_data *bed;
-      bed = get_elf_backend_data (info->output_bfd);
-      srel->size += bed->s->sizeof_rela;
-      h->needs_copy = 1;
-    }
-
-  return _bfd_elf_adjust_dynamic_copy (info, h, s);
-}
-
 /* Allocate space in .plt, .got and associated reloc sections for
    dynamic relocs.  */
 
@@ -6460,14 +6239,12 @@ elf_x86_64_special_sections[]=
 #define bfd_elf64_bfd_reloc_name_lookup \
   elf_x86_64_reloc_name_lookup
 
-#define elf_backend_adjust_dynamic_symbol   elf_x86_64_adjust_dynamic_symbol
 #define elf_backend_relocs_compatible      elf_x86_64_relocs_compatible
 #define elf_backend_check_relocs           elf_x86_64_check_relocs
 #define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
 #define elf_backend_finish_dynamic_sections elf_x86_64_finish_dynamic_sections
 #define elf_backend_finish_dynamic_symbol   elf_x86_64_finish_dynamic_symbol
 #define elf_backend_output_arch_local_syms  elf_x86_64_output_arch_local_syms
-#define elf_backend_gc_mark_hook           elf_x86_64_gc_mark_hook
 #define elf_backend_grok_prstatus          elf_x86_64_grok_prstatus
 #define elf_backend_grok_psinfo                    elf_x86_64_grok_psinfo
 #ifdef CORE_HEADER
@@ -6478,7 +6255,6 @@ elf_x86_64_special_sections[]=
 #define elf_backend_size_dynamic_sections   elf_x86_64_size_dynamic_sections
 #define elf_backend_init_index_section     _bfd_elf_init_1_index_section
 #define elf_backend_object_p               elf64_x86_64_elf_object_p
-#define bfd_elf64_mkobject                 elf_x86_64_mkobject
 #define bfd_elf64_get_synthetic_symtab     elf_x86_64_get_synthetic_symtab
 
 #define elf_backend_section_from_shdr \
@@ -6766,8 +6542,6 @@ elf32_x86_64_nacl_elf_object_p (bfd *abfd)
   elf_x86_64_reloc_type_lookup
 #define bfd_elf32_bfd_reloc_name_lookup \
   elf_x86_64_reloc_name_lookup
-#define bfd_elf32_mkobject \
-  elf_x86_64_mkobject
 #define bfd_elf32_get_synthetic_symtab \
   elf_x86_64_get_synthetic_symtab
 
This page took 0.02597 seconds and 4 git commands to generate.