This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[committed, PATCH] x86: Add _bfd_x86_elf_gc_mark_hook
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Fri, 1 Sep 2017 14:54:13 -0700
- Subject: [committed, PATCH] x86: Add _bfd_x86_elf_gc_mark_hook
- Authentication-results: sourceware.org; auth=none
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Since R_X86_64_GNU_VTINHERIT == R_386_GNU_VTINHERIT and
R_X86_64_GNU_VTENTRY == R_386_GNU_VTENTRY, we can share
_bfd_x86_elf_gc_mark_hook in elf32-i386.c and elf64-x86-64.c.
* elf32-i386.c (elf_i386_gc_mark_hook): Removed.
(elf_backend_gc_mark_hook): Likewise.
* elf64-x86-64.c (elf_x86_64_gc_mark_hook): Likewise.
(elf_backend_gc_mark_hook): Likewise.
* elfxx-x86.c (_bfd_x86_elf_gc_mark_hook): New function.
* elfxx-x86.h (_bfd_x86_elf_gc_mark_hook): New.
(elf_backend_gc_mark_hook): Likewise.
---
bfd/ChangeLog | 10 ++++++++++
bfd/elf32-i386.c | 22 ----------------------
bfd/elf64-x86-64.c | 22 ----------------------
bfd/elfxx-x86.c | 28 ++++++++++++++++++++++++++++
bfd/elfxx-x86.h | 6 ++++++
5 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9220235781..1b3276c45d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,15 @@
2017-09-01 H.J. Lu <hongjiu.lu@intel.com>
+ * elf32-i386.c (elf_i386_gc_mark_hook): Removed.
+ (elf_backend_gc_mark_hook): Likewise.
+ * elf64-x86-64.c (elf_x86_64_gc_mark_hook): Likewise.
+ (elf_backend_gc_mark_hook): Likewise.
+ * elfxx-x86.c (_bfd_x86_elf_gc_mark_hook): New function.
+ * elfxx-x86.h (_bfd_x86_elf_gc_mark_hook): New.
+ (elf_backend_gc_mark_hook): Likewise.
+
+2017-09-01 H.J. Lu <hongjiu.lu@intel.com>
+
* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Removed.
(elf_backend_adjust_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index c934f28a4b..0803bee909 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1974,27 +1974,6 @@ error_return:
return FALSE;
}
-/* Return the section that should be marked against GC for a given
- relocation. */
-
-static asection *
-elf_i386_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_386_GNU_VTINHERIT:
- case R_386_GNU_VTENTRY:
- return NULL;
- }
-
- return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
-}
-
/* Allocate space in .plt, .got and associated reloc sections for
dynamic relocs. */
@@ -5690,7 +5669,6 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
#define elf_backend_finish_dynamic_sections elf_i386_finish_dynamic_sections
#define elf_backend_finish_dynamic_symbol elf_i386_finish_dynamic_symbol
#define elf_backend_output_arch_local_syms elf_i386_output_arch_local_syms
-#define elf_backend_gc_mark_hook elf_i386_gc_mark_hook
#define elf_backend_grok_prstatus elf_i386_grok_prstatus
#define elf_backend_grok_psinfo elf_i386_grok_psinfo
#define elf_backend_reloc_type_class elf_i386_reloc_type_class
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index ef8ca1a565..63aff4630f 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2414,27 +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);
-}
-
/* Allocate space in .plt, .got and associated reloc sections for
dynamic relocs. */
@@ -6266,7 +6245,6 @@ elf_x86_64_special_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
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index cb5f6142c3..50d945ef0a 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -744,6 +744,34 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+asection *
+_bfd_x86_elf_gc_mark_hook (asection *sec,
+ struct bfd_link_info *info,
+ Elf_Internal_Rela *rel,
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
+{
+ /* Compiler should optimize this out. */
+ if (((unsigned int) R_X86_64_GNU_VTINHERIT
+ != (unsigned int) R_386_GNU_VTINHERIT)
+ || ((unsigned int) R_X86_64_GNU_VTENTRY
+ != (unsigned int) R_386_GNU_VTENTRY))
+ abort ();
+
+ 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);
+}
+
static bfd_vma
elf_i386_get_plt_got_vma (struct elf_x86_plt *plt_p ATTRIBUTE_UNUSED,
bfd_vma off,
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index 8f8fbeae87..edaab45533 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -422,6 +422,10 @@ extern bfd_boolean _bfd_x86_elf_hash_symbol
extern bfd_boolean _bfd_x86_elf_adjust_dynamic_symbol
(struct bfd_link_info *, struct elf_link_hash_entry *);
+extern asection * _bfd_x86_elf_gc_mark_hook
+ (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *, Elf_Internal_Sym *);
+
extern long _bfd_x86_elf_get_synthetic_symtab
(bfd *, long, long, bfd_vma, struct elf_x86_plt [], asymbol **,
asymbol **);
@@ -460,6 +464,8 @@ extern bfd * _bfd_x86_elf_link_setup_gnu_properties
_bfd_x86_elf_hash_symbol
#define elf_backend_adjust_dynamic_symbol \
_bfd_x86_elf_adjust_dynamic_symbol
+#define elf_backend_gc_mark_hook \
+ _bfd_x86_elf_gc_mark_hook
#define elf_backend_omit_section_dynsym \
((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
#define elf_backend_parse_gnu_properties \
--
2.13.5