This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] x86: Add VERIFY_COPY_RELOC


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ff38b4cc55dade4c9970cac2149a946d5dc0adc7

commit ff38b4cc55dade4c9970cac2149a946d5dc0adc7
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Oct 6 00:50:12 2017 -0700

    x86: Add VERIFY_COPY_RELOC
    
    Add VERIFY_COPY_RELOC to verify that symbol supports copy relocation.
    
    	* elfxx-x86.h (VERIFY_COPY_RELOC): New.
    	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Use it.
    	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.

Diff:
---
 bfd/ChangeLog      | 6 ++++++
 bfd/elf32-i386.c   | 8 +-------
 bfd/elf64-x86-64.c | 8 +-------
 bfd/elfxx-x86.h    | 9 +++++++++
 4 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2ad9e42..982d29d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
 2017-10-06  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* elfxx-x86.h (VERIFY_COPY_RELOC): New.
+	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Use it.
+	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
+
+2017-10-06  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* elfxx-x86.h (VERIFY_PLT_ENTRY): New.
 	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Use it.
 	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 822fe4f..5fbcd60 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -3908,13 +3908,7 @@ do_glob_dat:
       asection *s;
 
       /* This symbol needs a copy reloc.  Set it up.  */
-
-      if (h->dynindx == -1
-	  || (h->root.type != bfd_link_hash_defined
-	      && h->root.type != bfd_link_hash_defweak)
-	  || htab->elf.srelbss == NULL
-	  || htab->elf.sreldynrelro == NULL)
-	abort ();
+      VERIFY_COPY_RELOC (h, htab)
 
       rel.r_offset = (h->root.u.def.value
 		      + h->root.u.def.section->output_section->vma
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 1fb0a2d..c4cf7ae 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -4253,13 +4253,7 @@ do_glob_dat:
       asection *s;
 
       /* This symbol needs a copy reloc.  Set it up.  */
-
-      if (h->dynindx == -1
-	  || (h->root.type != bfd_link_hash_defined
-	      && h->root.type != bfd_link_hash_defweak)
-	  || htab->elf.srelbss == NULL
-	  || htab->elf.sreldynrelro == NULL)
-	abort ();
+      VERIFY_COPY_RELOC (h, htab)
 
       rela.r_offset = (h->root.u.def.value
 		       + h->root.u.def.section->output_section->vma
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index b81e145..ca270de 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -208,6 +208,15 @@
       || (RELPLT) == NULL) \
     abort ();
 
+/* Verify that the symbol supports copy relocation.  */
+#define VERIFY_COPY_RELOC(H, HTAB) \
+  if ((H)->dynindx == -1 \
+      || ((H)->root.type != bfd_link_hash_defined \
+	  && (H)->root.type != bfd_link_hash_defweak) \
+      || (HTAB)->elf.srelbss == NULL \
+      || (HTAB)->elf.sreldynrelro == NULL) \
+    abort ();
+
 /* x86 ELF linker hash entry.  */
 
 struct elf_x86_link_hash_entry


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]