]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Avoid an extra branch to PLT for -z now
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 24 May 2016 15:44:10 +0000 (08:44 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 24 May 2016 15:44:23 +0000 (08:44 -0700)
When --enable-bind-now is used to configure glibc build, we can avoid
an extra branch to the PLT entry by using indirect branch via the GOT
slot instead, which is similar to the first instructuon in the PLT
entry.  Changes in the shared library sizes in text sections:

Shared library    Before (bytes)   After (bytes)
libm.so             1060813          1060797
libmvec.so           160881           160805
libpthread.so         94992            94984
librt.so              25064            25048

* config.h.in (BIND_NOW): New.
* configure.ac (BIND_NOW): New.  Defined for --enable-bind-now.
* configure: Regenerated.
* sysdeps/x86_64/sysdep.h (JUMPTARGET)[BIND_NOW]: Defined to
indirect branch via the GOT slot.

ChangeLog
config.h.in
configure
configure.ac
sysdeps/x86_64/sysdep.h

index 3345a1d3796f01eecba70e06a3af789042c903a8..055316f86eb3b4d288bfb5938f61c062a4dc5fe6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-05-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * config.h.in (BIND_NOW): New.
+       * configure.ac (BIND_NOW): New.  Defined for --enable-bind-now.
+       * configure: Regenerated.
+       * sysdeps/x86_64/sysdep.h (JUMPTARGET)[BIND_NOW]: Defined to
+       indirect branch via the GOT slot.
+
 2016-05-24  Stefan Liebler  <stli@linux.vnet.ibm.com>
 
        [BZ #19765]
index 0147ba3c34111db42941ebcd26246ee15022efd6..2c902b0214f7a85893b39a93acf75110c3edabe7 100644 (file)
@@ -87,6 +87,9 @@
    include/libc-symbols.h that avoid PLT slots in the shared objects.  */
 #undef NO_HIDDEN
 
+/* Define this to disable lazy relocations in DSOs.  */
+#undef BIND_NOW
+
 /* AArch64 big endian ABI */
 #undef HAVE_AARCH64_BE
 
index 8fe59377eacfdb9e4c4d1618053f6fa6719aac65..19a482946648d81aa051d1fc408d3034c134c1b2 100755 (executable)
--- a/configure
+++ b/configure
@@ -3416,6 +3416,10 @@ else
 fi
 
 
+if test "x$bindnow" = xyes; then
+  $as_echo "#define BIND_NOW 1" >>confdefs.h
+
+fi
 
 # Check whether --enable-static-nss was given.
 if test "${enable_static_nss+set}" = set; then :
index 3c766b7409f7e3f389b4e1a7857125dd64abd2ab..123f0d26ee544f9192d467a7ff5cc4ed1532af4b 100644 (file)
@@ -231,6 +231,9 @@ AC_ARG_ENABLE([bind-now],
              [bindnow=$enableval],
              [bindnow=no])
 AC_SUBST(bindnow)
+if test "x$bindnow" = xyes; then
+  AC_DEFINE(BIND_NOW)
+fi
 
 dnl On some platforms we cannot use dynamic loading.  We must provide
 dnl static NSS modules.
index fbe3560588bf82a9c4b7786285ecb7ab467c9849..75ac747be8a8e20cc1c8cac9bf0726d36c30036f 100644 (file)
@@ -90,9 +90,13 @@ lose:                                                                              \
 
 #undef JUMPTARGET
 #ifdef PIC
-#define JUMPTARGET(name)       name##@PLT
+# ifdef BIND_NOW
+#  define JUMPTARGET(name)     *name##@GOTPCREL(%rip)
+# else
+#  define JUMPTARGET(name)     name##@PLT
+# endif
 #else
-#define JUMPTARGET(name)       name
+# define JUMPTARGET(name)      name
 #endif
 
 /* Local label name for asm code. */