From patchwork Thu Mar 3 13:20:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lu, Hongjiu" X-Patchwork-Id: 11173 Received: (qmail 31705 invoked by alias); 3 Mar 2016 13:21:00 -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 31695 invoked by uid 89); 3 Mar 2016 13:20:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL, BAYES_05, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=fini, @PLT, testq, @plt X-HELO: mga11.intel.com X-ExtLoop1: 1 Date: Thu, 3 Mar 2016 05:20:55 -0800 From: "H.J. Lu" To: GNU C Library Subject: PATCH: Replace @PLT with @GOTPCREL(%rip) in call Message-ID: <20160303132054.GA3822@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Since both PREINIT_FUNCTION and __libc_start_main are defined externally, they are called via PLT. Use "call *func@GOTPCREL(%rip)" removes the extra branch to PLT entry. [BZ #19745] * sysdeps/x86_64/crti.S (_init): Replace @PLT with @GOTPCREL(%rip) in call. * sysdeps/x86_64/start.S (_start): Likewise. --- sysdeps/x86_64/crti.S | 2 +- sysdeps/x86_64/start.S | 2 +- sysdeps/x86_64/sysdep.h | 14 +++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sysdeps/x86_64/crti.S b/sysdeps/x86_64/crti.S index a345259..3dff141 100644 --- a/sysdeps/x86_64/crti.S +++ b/sysdeps/x86_64/crti.S @@ -66,7 +66,7 @@ _init: movq PREINIT_FUNCTION@GOTPCREL(%rip), %rax testq %rax, %rax je .Lno_weak_fn - call PREINIT_FUNCTION@PLT + call *PREINIT_FUNCTION@GOTPCREL(%rip) .Lno_weak_fn: #else call PREINIT_FUNCTION diff --git a/sysdeps/x86_64/start.S b/sysdeps/x86_64/start.S index 1374974..22b18ae 100644 --- a/sysdeps/x86_64/start.S +++ b/sysdeps/x86_64/start.S @@ -105,7 +105,7 @@ ENTRY (_start) /* Call the user's main function, and exit with its value. But let the libc call main. */ - call __libc_start_main@PLT + call *__libc_start_main@GOTPCREL(%rip) #else /* Pass address of our own entry points to .fini and .init. */ mov $__libc_csu_fini, %R8_LP