[PATCH/committed 2.24] X86_64: Don't use PLT nor GOT in static archives [BZ #20750]

Mike Frysinger vapier@gentoo.org
Sun Jan 1 00:00:00 GMT 2017


From: "H.J. Lu" <hjl.tools@gmail.com>

There is no need to use PLT nor GOT in static archives to branch to a
function, regardless whether static archives is compiled with PIC or
not.  When static archives are used to create dynamic executable,
PLT/GOT may be used.  The resulting executable still works correctly.

	[BZ #20750]
	* sysdeps/x86_64/sysdep.h (JUMPTARGET): Check SHARED instead
	of PIC.

(cherry picked from commit c9070e6305c08365c5f8b604bdca39c699d70cfa)
---
 ChangeLog               | 6 ++++++
 sysdeps/x86_64/sysdep.h | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index bf89bd33bcb2..a9b7540017d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-11-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #20750]
+	* sysdeps/x86_64/sysdep.h (JUMPTARGET): Check SHARED instead
+	of PIC.
+
 2016-12-31  Florian Weimer  <fweimer@redhat.com>
 
 	[BZ #18784]
diff --git a/sysdeps/x86_64/sysdep.h b/sysdeps/x86_64/sysdep.h
index 75ac747be8a8..4b67fa80c19a 100644
--- a/sysdeps/x86_64/sysdep.h
+++ b/sysdeps/x86_64/sysdep.h
@@ -89,13 +89,14 @@ lose:									      \
   END (name)
 
 #undef JUMPTARGET
-#ifdef PIC
+#ifdef SHARED
 # ifdef BIND_NOW
 #  define JUMPTARGET(name)	*name##@GOTPCREL(%rip)
 # else
 #  define JUMPTARGET(name)	name##@PLT
 # endif
 #else
+/* For static archives, branch to target directly.  */
 # define JUMPTARGET(name)	name
 #endif
 
-- 
2.11.0



More information about the Libc-stable mailing list