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_PLT_ENTRY


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

commit f3180fa9ee8917fa9547cd5f79c822761f5d87a0
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Oct 6 00:46:56 2017 -0700

    x86: Add VERIFY_PLT_ENTRY
    
    Add VERIFY_PLT_ENTRY to verify that symbol has an entry in the procedure
    linkage table.
    
    	* 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:
---
 bfd/ChangeLog      |  6 ++++++
 bfd/elf32-i386.c   | 13 +------------
 bfd/elf64-x86-64.c | 12 +-----------
 bfd/elfxx-x86.h    | 12 ++++++++++++
 4 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 6f2f9a2..2ad9e42 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_PLT_ENTRY): 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 (COPY_INPUT_RELOC_P): New.
 	* elf32-i386.c (elf_i386_relocate_section): Use it.
 	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 4adb70a..822fe4f 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -3577,18 +3577,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
 	  relplt = htab->elf.irelplt;
 	}
 
-      /* This symbol has an entry in the procedure linkage table.  Set
-	 it up.  */
-
-      if ((h->dynindx == -1
-	   && !local_undefweak
-	   && !((h->forced_local || bfd_link_executable (info))
-		&& h->def_regular
-		&& h->type == STT_GNU_IFUNC))
-	  || plt == NULL
-	  || gotplt == NULL
-	  || relplt == NULL)
-	abort ();
+      VERIFY_PLT_ENTRY (info, h, plt, gotplt, relplt, local_undefweak)
 
       /* Get the index in the procedure linkage table which
 	 corresponds to this symbol.  This is the index of this symbol
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index fcc7f55..1fb0a2d 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -3939,17 +3939,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
 	  relplt = htab->elf.irelplt;
 	}
 
-      /* This symbol has an entry in the procedure linkage table.  Set
-	 it up.	 */
-      if ((h->dynindx == -1
-	   && !local_undefweak
-	   && !((h->forced_local || bfd_link_executable (info))
-		&& h->def_regular
-		&& h->type == STT_GNU_IFUNC))
-	  || plt == NULL
-	  || gotplt == NULL
-	  || relplt == NULL)
-	abort ();
+      VERIFY_PLT_ENTRY (info, h, plt, gotplt, relplt, local_undefweak)
 
       /* Get the index in the procedure linkage table which
 	 corresponds to this symbol.  This is the index of this symbol
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index be438c0..b81e145 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -196,6 +196,18 @@
    && (H)->dynindx == -1 \
    && (TLS_TYPE & GOT_TLS_IE))
 
+/* Verify that the symbol has an entry in the procedure linkage table.  */
+#define VERIFY_PLT_ENTRY(INFO, H, PLT, GOTPLT, RELPLT, LOCAL_UNDEFWEAK) \
+  if (((H)->dynindx == -1 \
+       && !LOCAL_UNDEFWEAK \
+       && !(((H)->forced_local || bfd_link_executable (INFO)) \
+	    && (H)->def_regular \
+	    && (H)->type == STT_GNU_IFUNC)) \
+      || (PLT) == NULL \
+      || (GOTPLT) == NULL \
+      || (RELPLT) == 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]