From patchwork Fri Jul 29 13:26:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 654112 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s18dD6KpSz9rxm for ; Fri, 29 Jul 2016 23:26:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=embecosm-com.20150623.gappssmtp.com header.i=@embecosm-com.20150623.gappssmtp.com header.b=p+1ev2my; dkim-atps=neutral Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 4D40E10113; Fri, 29 Jul 2016 15:26:19 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by helium.openadk.org (Postfix) with ESMTPS id DBAD610112 for ; Fri, 29 Jul 2016 15:26:17 +0200 (CEST) Received: by mail-wm0-f54.google.com with SMTP id q128so290087968wma.1 for ; Fri, 29 Jul 2016 06:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=iMAcKb9Z0qEN5wp1hCGTDstHngNzLvbBhzHYP3nGri0=; b=p+1ev2myXL0OvYA/yY7Jw5IcWLUMGDZ8V7Cao2We464T+7V7BofEYOZypQeok43adV nzrlD/2R+991z4fVCrxJ8nZsdFEatqgssiqK6beagvKW8nfKFG05QIeMKEfiSKSJLY2Y 9WYxim5vNwEKQrBvPggQgnLi4qlR0pOHuf9BGLj+wknoVl94nKTArrjseAAWC/MB6p6w /I3KoEvCIhA8xZezNFGZW8fk96S/WO06vfw65FcJ8Yy309dcGf3d5lGAZko3VTe76LP3 eGWOtRxtPT8kqe2frXitgWPKhovBed90JN8z5LiXpU/xcL1qS8e6yBuRF5RZH4o+ZYgF cgRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=iMAcKb9Z0qEN5wp1hCGTDstHngNzLvbBhzHYP3nGri0=; b=ZQLS8a5Bk6uy8WXtcskonqrsrW+Xlk80uJhHb5g1LwoD5KqAa053TMg4el34DERVyI C09R63+KwISLMktWw0hWegR4ex9eGooK7LMjBz64dX5JLflQcmeHZnP6KSl3o8qTJi50 4TPnvHU1bHO80Oa7+Y4U49GKWJJWt6pNcy9R9gX8IDGyNtY3+xhqNgyROktYsPAiX1we GXNOLYq005kevokDlHSp+pn/MsNx9RkWkzPssQAEc7U1x5s2pBdSL3riY585pk6e+snb wmjyFY/POM7hDORUxsKgwZ6TAa7uUAk9dpwAPwhVcvpKFaVrd9Qhb3zFX+KzUnjygiuB kguw== X-Gm-Message-State: AEkooutDGAFAxyvheqiKHrKHmPgX9IVMPzw/PtaAOPK/PNzXL23m6wVlVsk4dtjn6E+fqw== X-Received: by 10.28.74.221 with SMTP id n90mr1161652wmi.16.1469798777336; Fri, 29 Jul 2016 06:26:17 -0700 (PDT) Received: from localhost (host86-165-30-37.range86-165.btcentralplus.com. [86.165.30.37]) by smtp.gmail.com with ESMTPSA id yz6sm16566457wjb.35.2016.07.29.06.26.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jul 2016 06:26:16 -0700 (PDT) Date: Fri, 29 Jul 2016 14:26:09 +0100 From: Andrew Burgess To: Alexey Brodkin Message-ID: <20160729132609.GO4517@embecosm.com> References: <16492d6d-b4d4-39af-18dd-15f78c1abeff@synopsys.com> <1e046cfd-bf55-c1fa-6083-6bd7acf0f705@synopsys.com> <1469782070.3088.10.camel@synopsys.com> <20160729094317.GM4517@embecosm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160729094317.GM4517@embecosm.com> X-Operating-System: Linux/4.4.10-200.fc22.x86_64 (x86_64) X-Uptime: 14:16:26 up 4 days, 4:52, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.6.1 (2016-04-27) Cc: "devel@uclibc-ng.org" , "noamca@mellanox.com" , Vineet Gupta , "rep.dot.nop@gmail.com" , "Vladislav.Zakharov@synopsys.com" , "linux-snps-arc@lists.infradead.org" Subject: Re: [uclibc-ng-devel] [PATCH 0/2] ARC Moving to @pcl relocations X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" * Andrew Burgess [2016-07-29 10:43:17 +0100]: > * Alexey Brodkin [2016-07-29 08:49:22 +0000]: > > > Hi Andrew, all, > > > > On Thu, 2016-07-28 at 15:40 -0700, Vineet Gupta wrote: > > > On 07/28/2016 03:04 PM, Bernhard Reutner-Fischer wrote: > > > > > > > > > > > > > > Indeed your 2/2 seems to be the most "past-proof" code change. So I > > > > > > > > > > > > would think it > > > > > > is indeed better and is something I should have done in the first > > > > > > place. > > > > > > > > > > > > @Alexey, @Vlad what say you ? > > > > uClibc traditionally supports the current stable release of binutils, which would make it patch #1 I think. > > > > > > > > > > But 2/2 works for both and makes actual binutils version moot. FWIW, ARC tools > > > don't as of last release didn't use the upstream/stable binutils, but we are > > > pretty close to that now though. > > > > Personally I'd prefer to not add more conditional defines in uClibc but > > make it a little-bit simpler. > > > > I.e. either Vlad's patch or #1 from this series IMHO looks better. > > It's been quite some time since we updated our tools with PCL support > > and I'm not really sure if there's anybody interested in using ages old > > tools with today's uClibc. We don't test such combinations and there could > > be issues already in such combos. > > > > BTW I noticed that Vlad's patch removes/reverts that thing as well: > > http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/ldso/ldso/arc/dl-sysdep.h?id=181d410ad00cddd1d6c9f4835e129136b74 > > c5187 > > > > While Andrew just replaces ".&" construction with "@pcl". > > I'm wondering which is the correct approach here? > > I left the second block in as the two blocks use different symbols, > the native threads block uses _DYNAMIC, while the non-native uses > _dl_start. > > I wasn't sure if this was significant, so left the the split in > place. If more knowledgeable folk believe these can be combined then > that's fine with me (so long as we combine on @pcl). Having looked at this a little more I think that we should merge the section Alexey mentioned above. In the second instance (the one I modified) we use the symbol _dl_start, while in the first we use _DYNAMIC. However, the comment in the first block makes it clear the symbol used should be a global symbol, not a local, and _dl_start is a local symbol. The consequence of using a local here is that we end up with a R_ARC_NONE relocation being generated again the .got. [ The generation of the R_ARC_NONE is probably a bug, or at least a lack of optimisation, but it is what happens with the current upstream tools. ] As the arc dynamic loader does not currently support patching R_ARC_NONE during the bootstrap phase, if uClibc(-ng) is configured without native threads, then currently we get a dynamic loader that does not work. So, I think we should collapse both sections, and make use of the _DYNAMIC symbol instead of _dl_start. I've included a revised version of patch 1/2 that includes this latest change. Thanks, Andrew ---- [PATCH] ARC: Update relocation syntax for old-thread model code This commit reverses a change introduced in commit 20554a78a9bba that split some of the ARC code into two based on whether uClibc was configured with native threads or not. The native thread code was updated to use the relocation syntax of modern binutils, while the non-native code path used a syntax only accepted in older versions of binutils. The problem with this is that the choice of old binutils or not is orthogonal to the choice of native threads or not, and so, inevitably a user with a recent version of binutils can make the choice to configure uClibc with non-native thread support, and run into code that will not assemble. The solution is either to abandon support for the old tools completely, or to add a new compile time flag for ARC that is set when the version of binutils being used is old; this new flag would allow the old relocation structure to be selected. In this commit I have simply dropped support for older versions of the tools. --- ldso/ldso/arc/dl-startup.h | 7 ------- ldso/ldso/arc/dl-sysdep.h | 10 ---------- 2 files changed, 17 deletions(-) diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h index ef89b53..664b860 100644 --- a/ldso/ldso/arc/dl-startup.h +++ b/ldso/ldso/arc/dl-startup.h @@ -34,15 +34,8 @@ __asm__( " ; skip the extra args calc by dl_start() \n" " ld_s r1, [sp] ; orig argc from aux-vec Tbl \n" -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ " ld r12, [pcl, _dl_skip_args@pcl] \n" - " add r2, pcl, _dl_fini@pcl ; finalizer \n" -#else - " add r12, pcl, _dl_skip_args-.+(.&2) \n" - " ld r12, [r12] \n" - " add r2, pcl, _dl_fini-.+(.&2) ; finalizer \n" -#endif " add2 sp, sp, r12 ; discard argv entries from stack\n" " sub_s r1, r1, r12 ; adjusted argc, on stack \n" diff --git a/ldso/ldso/arc/dl-sysdep.h b/ldso/ldso/arc/dl-sysdep.h index caece99..c6086e6 100644 --- a/ldso/ldso/arc/dl-sysdep.h +++ b/ldso/ldso/arc/dl-sysdep.h @@ -132,7 +132,6 @@ static __always_inline Elf32_Addr elf_machine_dynamic(void) /* Return the run-time load address of the shared object. */ static __always_inline Elf32_Addr elf_machine_load_address(void) { -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ /* 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 @@ -150,15 +149,6 @@ static __always_inline Elf32_Addr elf_machine_load_address(void) "sub %0, %0, %1 ;delta" "\n" : "=&r" (addr), "=r"(tmp) ); -#else - Elf32_Addr addr, tmp; - __asm__ ( - "ld %1, [pcl, _dl_start@gotpc] ;build addr of _dl_start \n" - "add %0, pcl, _dl_start-.+(.&2) ;runtime addr of _dl_start \n" - "sub %0, %0, %1 ;delta \n" - : "=&r" (addr), "=r"(tmp) - ); -#endif return addr; }