From patchwork Mon Jan 9 17:31:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 712882 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ty2Jt3Fcmz9s2G for ; Tue, 10 Jan 2017 04:31:58 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cQdnY-00043b-OM; Mon, 09 Jan 2017 17:31:56 +0000 Received: from smtprelay4.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQdnU-0003qm-Ub for linux-snps-arc@lists.infradead.org; Mon, 09 Jan 2017 17:31:54 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id F2BD124E041B; Mon, 9 Jan 2017 09:31:31 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id CF073B5A; Mon, 9 Jan 2017 09:31:31 -0800 (PST) Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2-vip.internal.synopsys.com [10.12.239.238]) by mailhost.synopsys.com (Postfix) with ESMTP id 7BA73B44; Mon, 9 Jan 2017 09:31:31 -0800 (PST) Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.104) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 9 Jan 2017 09:31:31 -0800 Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.105) by IN01WEHTCA.internal.synopsys.com (10.144.199.103) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 9 Jan 2017 23:01:30 +0530 Received: from vineetg-Latitude-E7450.internal.synopsys.com (10.10.161.54) by IN01WEHTCB.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 9 Jan 2017 23:01:29 +0530 From: Vineet Gupta To: Subject: [PATCH] ARC: ldso: don't use _DYNAMIC@gotpc construct to refer to GOT Date: Mon, 9 Jan 2017 09:31:19 -0800 Message-ID: <1483983079-28539-1-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.10.161.54] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170109_093153_053888_C64E2591 X-CRM114-Status: GOOD ( 11.52 ) X-Spam-Score: -5.1 (-----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-5.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -3.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.182.47.9 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cupertino.Miranda@synopsys.com, linux-snps-arc@lists.infradead.org, Vineet Gupta , Alexey.Brodkin@synopsys.com, Claudiu Zissulescu Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Historically we've used a special construct _DYNAMIC@gotpc to refer to base address of GOT This has been done with a special hack in binutils which tools guys now wish to get rid off. So rewrite the 2 callers of this construct to use the simpler and more obvious constructs. There's existing _GLOBAL_OFFSET_TABLE symbols provided by linker which can be used for same purposes. Signed-off-by: Vineet Gupta --- ldso/ldso/arc/dl-sysdep.h | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/ldso/ldso/arc/dl-sysdep.h b/ldso/ldso/arc/dl-sysdep.h index c6086e68e5c6..361a9bb9c0c3 100644 --- a/ldso/ldso/arc/dl-sysdep.h +++ b/ldso/ldso/arc/dl-sysdep.h @@ -119,37 +119,26 @@ extern unsigned __udivmodsi4(unsigned, unsigned) attribute_hidden; | (((type) == R_ARC_COPY) * ELF_RTYPE_CLASS_COPY)) /* - * Get the runtime address of GOT[0] + * Get build time address of .dynamic as setup in GOT[0] + * This is called very early in _dl_start() so it has not been relocated to + * runtime value */ static __always_inline Elf32_Addr elf_machine_dynamic(void) { - Elf32_Addr dyn; - - __asm__("ld %0,[pcl,_DYNAMIC@gotpc]\n\t" : "=r" (dyn)); - return dyn; + /* Declaring this hidden ensures that a PC-relative reference is used. */ + extern const Elf32_Addr _GLOBAL_OFFSET_TABLE_[] attribute_hidden; + return _GLOBAL_OFFSET_TABLE_[0]; } /* Return the run-time load address of the shared object. */ static __always_inline Elf32_Addr elf_machine_load_address(void) { - /* To find the loadaddr we subtract the runtime addr of a non-local symbol - * say _DYNAMIC from it's build-time addr. - * N.B., gotpc loads get optimized by the linker if it finds the symbol - * is resolved locally. - * A more robust - and efficient - solution would be to use a symbol - * set by the linker. To make it actually save space, we'd have to - * suppress the unwanted text relocation in the linked dso, though. - * (I.e. in ldso.so.*, though it's just another dso as far as bfd/ld - * are concerned.) - */ - Elf32_Addr addr, tmp; - __asm__ ( - "ld %1, [pcl, _DYNAMIC@gotpc] ;build addr of _DYNAMIC" "\n" - "add %0, pcl, _DYNAMIC@pcl ;runtime addr of _DYNAMIC" "\n" - "sub %0, %0, %1 ;delta" "\n" - : "=&r" (addr), "=r"(tmp) - ); - return addr; + Elf32_Addr build_addr, run_addr; + + build_addr = elf_machine_dynamic(); + __asm__ ("add %0, pcl, _DYNAMIC@pcl \n" : "=r" (run_addr)); + + return run_addr - build_addr; } static __always_inline void