From patchwork Wed May 4 18:17:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lu, Hongjiu" X-Patchwork-Id: 12015 Received: (qmail 119950 invoked by alias); 4 May 2016 18:17:29 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 119801 invoked by uid 89); 4 May 2016 18:17:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=909, $as_echo, Regenerated, as_echo X-HELO: mga11.intel.com X-ExtLoop1: 1 Date: Wed, 4 May 2016 11:17:17 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] Avoid an extra branch to PLT for -z now Message-ID: <20160504181716.GA21077@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) 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 Tested on x86-64. OK for master? H.J. --- * config.h.in (BIND_NOW): New. * configure.ac (BIND_NOW): New. Defined for --enable-bind-now. * configure: Regenerated. * sysdeps/x86_64/sysdep.h (JUMPTARGET): Defined to indirect branch via the GOT slot. --- config.h.in | 3 +++ configure | 4 ++++ configure.ac | 3 +++ sysdeps/x86_64/sysdep.h | 8 ++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/config.h.in b/config.h.in index 0147ba3..2c902b0 100644 --- a/config.h.in +++ b/config.h.in @@ -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 diff --git a/configure b/configure index 8fe5937..19a4829 100755 --- 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 : diff --git a/configure.ac b/configure.ac index 3c766b7..123f0d2 100644 --- a/configure.ac +++ b/configure.ac @@ -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. diff --git a/sysdeps/x86_64/sysdep.h b/sysdeps/x86_64/sysdep.h index fbe3560..75ac747 100644 --- a/sysdeps/x86_64/sysdep.h +++ b/sysdeps/x86_64/sysdep.h @@ -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. */