From patchwork Thu Jul 28 18:20:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 653849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s0gCN1PRfz9t1q for ; Fri, 29 Jul 2016 04:20:48 +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=CHWAblJj; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 577843163A; Thu, 28 Jul 2016 18:20:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7lI5CIUq3o3f; Thu, 28 Jul 2016 18:20:41 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 66B4731616; Thu, 28 Jul 2016 18:20:41 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 8BB831C0FFC for ; Thu, 28 Jul 2016 18:20:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 89A0B8F9D4 for ; Thu, 28 Jul 2016 18:20:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SnHyPrqyDPTf for ; Thu, 28 Jul 2016 18:20:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by whitealder.osuosl.org (Postfix) with ESMTPS id 208C68BC45 for ; Thu, 28 Jul 2016 18:20:37 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id i5so120068284wmg.0 for ; Thu, 28 Jul 2016 11:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Or+h1fyzo2qg16n6nqbdvQ5J+bD5I9GvHK1kH16bV34=; b=CHWAblJjXdEsZTE/4K6HX+y4wMe+tZei/Aia3NEYz4PdbjiM87LqMFAQyG9OUmWZB6 XVczs8FUJuZRFBYCxVKGt1TjaGwqJpOph19Sw1WXQc2b83v+8VRBghUeDQTd/RWjkt6d ksAAip2D9iybDzWPrTQIzmhzjZuj9kdXoA1gFS4KxtHTTnPu7IS/y7DdbP7q6r+iv3Yp TI5z6Kizjl12zYnNRxMDJtXdBZLW7BNlGG/ho0M9ctr3JcR9cDwyrj7SyReHerFghcFb Y24Q3vm5hla4ns4Z7UxdIluKEWSYHyVfHjwWPGzq3p/Dn4cYQNJilvFUXAg5nXnNy7MC vL/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Or+h1fyzo2qg16n6nqbdvQ5J+bD5I9GvHK1kH16bV34=; b=SWZ/8cPIjM0NCSm9F+y9giOx4KRAwmfFuJSYUA89yuzQPrzxpZPizkv2p0ZQIpnNMh /VRSzTA5o8qCsJMXmR2IyK+LZ/OMpJ/ojRA8pQ/0/wx2BLwg0+EPOPx1GNaOGSKcYJp6 GSQnKVtekUQK/J71krcbI8eaHrO/AsgWwHTGmiUu6yW3HxmJTCrYTh3g5htiiMshMlmN jfObaTo37YzliAdJIDEnAzv70TbXBxKlMJ1m0RbHMM8WJk6w985gzGbHRZ60uuB5cPo6 AIXGAO1cQ2S+b9OCz99QIWrrt46PkiCqnZjpN3ZB1vEuRgTEwcAZ5/FJuK2PHJOimtin x50w== X-Gm-Message-State: AEkoout9fSmrAe2CCiiapwHx3xHUOUPOKgsa725mMsZqJZDg5q8FzQfh5hQEuTtQzcxs3g== X-Received: by 10.194.85.97 with SMTP id g1mr33831893wjz.72.1469730035522; Thu, 28 Jul 2016 11:20:35 -0700 (PDT) Received: from localhost (host86-165-30-37.range86-165.btcentralplus.com. [86.165.30.37]) by smtp.gmail.com with ESMTPSA id yt6sm12679953wjc.23.2016.07.28.11.20.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 11:20:34 -0700 (PDT) From: Andrew Burgess To: uclibc@uclibc.org, devel@uclibc-ng.org Subject: [PATCH 2/2] ARC: Add new compiler define to indicate @pcl relocation support Date: Thu, 28 Jul 2016 19:20:13 +0100 Message-Id: <1469730034-8068-1-git-send-email-andrew.burgess@embecosm.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: References: In-Reply-To: References: Cc: noamca@mellanox.com, Vineet.Gupta1@synopsys.com, Alexey.Brodkin@synopsys.com X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" Some old versions of binutils did not support @pcl relocations. This commit adds a new flag to the uClibc configuration system that detects if the toolchain supports @pcl relocations or not. If this relocation is supported then the define ARC_HAS_AT_PCL_RELOC will be passed to the compiler, which is then used in the arc ldso to choose between generating old or new style code. This commit addresses and issue that was worked around in commit 181d410ad00cddd1d6c9f4835e129136b74c5187 (ARC: Conditionalise certain relocations as provided by TLS tools only). In this commit the choice between old or new style relocations was made based on whether uClibc was configured with native threads or not. The problem is that a user of a new toolchain might choose to configure without native threads. --- Rules.mak | 2 ++ ldso/ldso/arc/dl-startup.h | 2 +- ldso/ldso/arc/dl-sysdep.h | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Rules.mak b/Rules.mak index 3c80016..04ff02f 100644 --- a/Rules.mak +++ b/Rules.mak @@ -507,9 +507,11 @@ ifeq ($(TARGET_ARCH),c6x) endif ifeq ($(TARGET_ARCH),arc) + ARC_HAS_AT_PCL_RELOC:=$(shell echo -e "\t.text\n\tadd r0,pcl,_symbol@pcl" | $(CC) -c -x assembler -o /dev/null - 2> /dev/null && echo -n y || echo -n n) CPU_CFLAGS-y += -mlock -mswape CPU_CFLAGS-$(CONFIG_ARC_CPU_700) += -mA7 CPU_CFLAGS-$(CONFIG_ARC_CPU_HS) += -mcpu=archs + CPU_CFLAGS-$(ARC_HAS_AT_PCL_RELOC) += -DARC_HAS_AT_PCL_RELOC CPU_LDFLAGS-y += $(CPU_CFLAGS) -marclinux endif diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h index ef89b53..80ffd79 100644 --- a/ldso/ldso/arc/dl-startup.h +++ b/ldso/ldso/arc/dl-startup.h @@ -34,7 +34,7 @@ __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__ +#ifdef ARC_HAS_AT_PCL_RELOC " ld r12, [pcl, _dl_skip_args@pcl] \n" " add r2, pcl, _dl_fini@pcl ; finalizer \n" diff --git a/ldso/ldso/arc/dl-sysdep.h b/ldso/ldso/arc/dl-sysdep.h index caece99..27463f0 100644 --- a/ldso/ldso/arc/dl-sysdep.h +++ b/ldso/ldso/arc/dl-sysdep.h @@ -154,7 +154,11 @@ static __always_inline Elf32_Addr elf_machine_load_address(void) Elf32_Addr addr, tmp; __asm__ ( "ld %1, [pcl, _dl_start@gotpc] ;build addr of _dl_start \n" +#ifdef ARC_HAS_AT_PCL_RELOC + "add %0, pcl, _dl_start@pcl ;runtime addr of _dl_start \n" +#else "add %0, pcl, _dl_start-.+(.&2) ;runtime addr of _dl_start \n" +#endif /* ARC_HAS_AT_PCL_RELOC */ "sub %0, %0, %1 ;delta \n" : "=&r" (addr), "=r"(tmp) );