Message ID | 1466682675-5301-1-git-send-email-vgupta@synopsys.com |
---|---|
State | New |
Headers | show
Return-Path: <uclibc-bounces@uclibc.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rb0Dc28vFz9t15 for <incoming@patchwork.ozlabs.org>; Thu, 23 Jun 2016 21:51:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id F045095C9D; Thu, 23 Jun 2016 11:51:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vFspEpxjxujz; Thu, 23 Jun 2016 11:51:38 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id BA70D95CA1; Thu, 23 Jun 2016 11:51:38 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 2FA561C11A9 for <uclibc@lists.busybox.net>; Thu, 23 Jun 2016 11:51:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 0CA3DC0F82 for <uclibc@lists.busybox.net>; Thu, 23 Jun 2016 11:51:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jAm_9k5vN8Qo for <uclibc@lists.busybox.net>; Thu, 23 Jun 2016 11:51:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay.synopsys.com (us01smtprelay-2.synopsys.com [198.182.47.9]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 4BE45C0F80 for <uclibc@uclibc.org>; Thu, 23 Jun 2016 11:51:37 +0000 (UTC) Received: from us02secmta1.synopsys.com (us02secmta1.synopsys.com [10.12.235.96]) by smtprelay.synopsys.com (Postfix) with ESMTP id 8CB8024E1375; Thu, 23 Jun 2016 04:51:36 -0700 (PDT) Received: from us02secmta1.internal.synopsys.com (us02secmta1.internal.synopsys.com [127.0.0.1]) by us02secmta1.internal.synopsys.com (Service) with ESMTP id 597E54E213; Thu, 23 Jun 2016 04:51:36 -0700 (PDT) Received: from mailhost.synopsys.com (unknown [10.13.184.66]) by us02secmta1.internal.synopsys.com (Service) with ESMTP id 3827B4E202; Thu, 23 Jun 2016 04:51:36 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 28C8658B; Thu, 23 Jun 2016 04:51:36 -0700 (PDT) Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) by mailhost.synopsys.com (Postfix) with ESMTP id D1BC058A; Thu, 23 Jun 2016 04:51:35 -0700 (PDT) Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.106) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 23 Jun 2016 04:51:35 -0700 Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.103) by IN01WEHTCB.internal.synopsys.com (10.144.199.105) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 23 Jun 2016 17:21:33 +0530 Received: from vineet-E7440.internal.synopsys.com (10.12.197.158) by IN01WEHTCA.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 23 Jun 2016 17:21:31 +0530 From: Vineet Gupta <Vineet.Gupta1@synopsys.com> To: <devel@uclibc-ng.org> Subject: [PATCH v2] ARC: Enable shared crt1 Date: Thu, 23 Jun 2016 17:21:15 +0530 Message-ID: <1466682675-5301-1-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <20160616194910.GU2584@waldemar-brodkorb.de> References: <20160616194910.GU2584@waldemar-brodkorb.de> MIME-Version: 1.0 X-Originating-IP: [10.12.197.158] Cc: Cupertino Miranda <Cupertino.Miranda@synopsys.com>, "uclibc@uclibc.org" <uclibc@uclibc.org>, Vineet Gupta <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\)" <uclibc.uclibc.org> List-Unsubscribe: <http://lists.busybox.net/mailman/options/uclibc>, <mailto:uclibc-request@uclibc.org?subject=unsubscribe> List-Archive: <http://lists.busybox.net/pipermail/uclibc/> List-Post: <mailto:uclibc@uclibc.org> List-Help: <mailto:uclibc-request@uclibc.org?subject=help> List-Subscribe: <http://lists.busybox.net/mailman/listinfo/uclibc>, <mailto:uclibc-request@uclibc.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" <uclibc-bounces@uclibc.org> |
diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S index 95c41f888850..e38c8e81b2c0 100644 --- a/libc/sysdeps/linux/arc/crt1.S +++ b/libc/sysdeps/linux/arc/crt1.S @@ -41,11 +41,15 @@ __start: mov_s r5, r0 ; rltd_fini add_s r2, sp, 4 ; argv - +#ifdef L_Scrt1 + add r0, pcl, @main@pcl + add r3, pcl, @_init@pcl + add r4, pcl, @_fini@pcl +#else mov_s r0, main mov_s r3, _init mov r4, _fini - +#endif and sp, sp, -8 mov r6, sp
Currently crt1 takes address of functions (main,_init,_fini) directly which doesn't generate truely position independent code, but zero based values instead. e.g. | __start: | ... | add_s r2,sp,0x4 | mov_s r0, main generates to | 000156ec <__start>: | ... | 156f4: add_s r2,sp,0x4 | 156f6: mov_s r0,0x15f7c | ... | 00015f7c <main>: | 15f7c: push_s blink This works just fine for the normal (non PIE) dynamic executables since they are loaded at address 0. However this is not true for PIE executables. So for Scrt1 we use a true position independent way when taking function addresses. Cc: uclibc@uclibc.org <uclibc@uclibc.org> Cc: devel@uclibc-ng.org <devel@uclibc-ng.org> Cc: Cupertino Miranda <cmiranda@synopsys.com> Signed-off-by: Vineet Gupta <vgupta@synopsys.com> --- libc/sysdeps/linux/arc/crt1.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)