This is the mail archive of the binutils@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]

[committed, PATCH] x86: Add POINTER_LOCAL_IFUNC_P/PLT_LOCAL_IFUNC_P


Add POINTER_LOCAL_IFUNC_P which returns TRUE for pointer reference to
local IFUNC symbol.  Add PLT_LOCAL_IFUNC_P which returns TRUE for PLT
reference to local IFUNC symbol.

	* elfxx-x86.h (POINTER_LOCAL_IFUNC_P): New.
	(PLT_LOCAL_IFUNC_P): Likewise.
	* elf32-i386.c (elf_i386_relocate_section): Use them.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
---
 bfd/ChangeLog      |  7 +++++++
 bfd/elf32-i386.c   | 10 ++--------
 bfd/elf64-x86-64.c | 10 ++--------
 bfd/elfxx-x86.h    | 14 ++++++++++++++
 4 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index afd14b8740..feff37e078 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,12 @@
 2017-10-06  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* elfxx-x86.h (POINTER_LOCAL_IFUNC_P): New.
+	(PLT_LOCAL_IFUNC_P): Likewise.
+	* elf32-i386.c (elf_i386_relocate_section): Use them.
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+
+2017-10-06  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* elfxx-x86.h (GENERATE_RELATIVE_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 198732cec3..b6c478d901 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2388,9 +2388,7 @@ do_ifunc_pointer:
 				     + input_section->output_offset
 				     + offset);
 
-		  if (h->dynindx == -1
-		      || h->forced_local
-		      || bfd_link_executable (info))
+		  if (POINTER_LOCAL_IFUNC_P (info, h))
 		    {
 		      info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
 					      h->root.root.string,
@@ -3732,11 +3730,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
 	  rel.r_offset = (gotplt->output_section->vma
 			  + gotplt->output_offset
 			  + got_offset);
-	  if (h->dynindx == -1
-	      || ((bfd_link_executable (info)
-		   || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
-		  && h->def_regular
-		  && h->type == STT_GNU_IFUNC))
+	  if (PLT_LOCAL_IFUNC_P (info, h))
 	    {
 	      info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
 				      h->root.root.string,
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index d443551b44..f5ba5a6cc9 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2687,9 +2687,7 @@ do_ifunc_pointer:
 		  outrel.r_offset += (input_section->output_section->vma
 				      + input_section->output_offset);
 
-		  if (h->dynindx == -1
-		      || h->forced_local
-		      || bfd_link_executable (info))
+		  if (POINTER_LOCAL_IFUNC_P (info, h))
 		    {
 		      info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
 					      h->root.root.string,
@@ -4058,11 +4056,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
 	  rela.r_offset = (gotplt->output_section->vma
 			   + gotplt->output_offset
 			   + got_offset);
-	  if (h->dynindx == -1
-	      || ((bfd_link_executable (info)
-		   || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
-		  && h->def_regular
-		  && h->type == STT_GNU_IFUNC))
+	  if (PLT_LOCAL_IFUNC_P (info, h))
 	    {
 	      info->callbacks->minfo (_("Local IFUNC function `%s' in %B\n"),
 				      h->root.root.string,
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index 02a388a368..3be85d085f 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -136,6 +136,20 @@
    && (H)->root.type != bfd_link_hash_undefweak \
    && bfd_link_pic (INFO))
 
+/* TRUE if this is a pointer reference to a local IFUNC.  */
+#define POINTER_LOCAL_IFUNC_P(INFO, H) \
+  ((H)->dynindx == -1 \
+   || (H)->forced_local \
+   || bfd_link_executable (INFO))
+
+/* TRUE if this is a PLT reference to a local IFUNC.  */
+#define PLT_LOCAL_IFUNC_P(INFO, H) \
+  ((H)->dynindx == -1 \
+   || ((bfd_link_executable (INFO) \
+	|| ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT) \
+	&& (H)->def_regular \
+	&& (H)->type == STT_GNU_IFUNC))
+
 /* TRUE if TLS IE->LE transition is OK.  */
 #define TLS_TRANSITION_IE_TO_LE_P(INFO, H, TLS_TYPE) \
   (bfd_link_executable (INFO) \
-- 
2.13.6


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