From patchwork Tue May 24 16:26:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 12493 Received: (qmail 12162 invoked by alias); 24 May 2016 16:26:17 -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 11504 invoked by uid 89); 24 May 2016 16:26:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=876, hongjiuluintelcom, hongjiu.lu@intel.com, sk:hongjiu X-HELO: mail-qg0-f52.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=ryn2Xg2DLMhUdNlV43jF/a33xSxQTIsDBb/kW/+DU8U=; b=Y/FduObV6V3of5SqLI2M+J9SnucV0/KsjkhHxSifWHA/UPZ1Tjii9PfQIbcXes/WOY 34whEC/h0rRFo79sZVIBXY/OJMd0h435c+8lIci9OI5jFgdnU9E+G57ocHXfrjGEPr3j M444NSP3gsKLLsfdx8MR5HKd7qgXelb+0DzoG8JpfPwrHhTGdrD7lIZyVyXgROZW6wFX q17RE1NlzimCuCeHNaf6UfqixSaefTMweyMKhGznRbZnFWNEvjfWq4H5O3H2cnWq7j1I u95I+ASnKAoRUW2GwL80VHAplrMy510n51iT8XgsQPMFKF3IePTYJlny+++CEWnwM78Q 6ZPw== X-Gm-Message-State: ALyK8tKAv2z5vNtDZt4/+e+1+9b4nhipky0cGDswyWu+I+FHwI3daLjkuH1XbbAATnNHNcC3sA0QdnBj78Cqcw== MIME-Version: 1.0 X-Received: by 10.140.230.81 with SMTP id a78mr828263qhc.68.1464107163623; Tue, 24 May 2016 09:26:03 -0700 (PDT) In-Reply-To: <20160520222916.F28972C3D3D@topped-with-meat.com> References: <20160504181716.GA21077@intel.com> <20160520222916.F28972C3D3D@topped-with-meat.com> Date: Tue, 24 May 2016 09:26:03 -0700 Message-ID: Subject: Re: [PATCH] Avoid an extra branch to PLT for -z now From: "H.J. Lu" To: Roland McGrath Cc: GNU C Library On Fri, May 20, 2016 at 3:29 PM, Roland McGrath wrote: >> * 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. > > Should be: > * sysdeps/x86_64/sysdep.h (JUMPTARGET) [BIND_NOW]: > Defined to indirect branch via the GOT slot. > > Otherwise this seems OK to me. This is what I checked in. Thanks. From 6901def689b5c77465d34f07822989ec67e80c1e Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 24 May 2016 08:44:10 -0700 Subject: [PATCH] Avoid an extra branch to PLT for -z now 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 | 8 ++++++++ config.h.in | 3 +++ configure | 4 ++++ configure.ac | 3 +++ sysdeps/x86_64/sysdep.h | 8 ++++++-- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3345a1d..055316f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-05-24 H.J. Lu + + * 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 [BZ #19765] 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. */ -- 2.5.5