From patchwork Tue Jun 21 05:06:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 70505 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1830769qgy; Mon, 20 Jun 2016 22:09:06 -0700 (PDT) X-Received: by 10.98.103.198 with SMTP id t67mr25919514pfj.158.1466485746595; Mon, 20 Jun 2016 22:09:06 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 2si37783528pfh.24.2016.06.20.22.09.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jun 2016 22:09:06 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-70815-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-70815-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-70815-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=C5VtN 9AiBHaBzp3GoM40+VAnhxBD+P0vNk+y7kyWYzQ275ZWLa9p9Z4iVl03HbYQcvKmi leveudnPvCsuc4IyI2fJ8smdu3352mNvn5pREai2TheIkowCGV4cbyqHHcj+IIE5 H+/GAqzN0OxpGeDeHdiraWF8iuVccAAy8aHwY4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=BNbOhh36zcw GWtKvgIZiHAt3mVs=; b=Fro2sOA6Lsw88xyThHGwnNkbrPIPeyQxAw4AuNp0lbu yAL6eZhC2TKRkRPYesA2mL276Hx2hqmfaLR3ULkIzy/qmnlzYG7qEKz6KWTBsVbD SCyRZS6LETL+HTUdo4SCksN/WvL4WFluaHEvn1xGh43AqJYM/LBalsyHND9ZDLpw = Received: (qmail 107475 invoked by alias); 21 Jun 2016 05:08:56 -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 107455 invoked by uid 89); 21 Jun 2016 05:08:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=39, 7, cbz X-HELO: na01-bn1-obe.outbound.protection.outlook.com Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , CC: , , , , , , , , , Andrew Pinski , Yury Norov Subject: [PATCH 05/27] [AARCH64] Use PTR_REG in crti.S. Date: Tue, 21 Jun 2016 08:06:49 +0300 Message-ID: <1466485631-3532-7-git-send-email-ynorov@caviumnetworks.com> In-Reply-To: <1466485631-3532-1-git-send-email-ynorov@caviumnetworks.com> References: <1466485631-3532-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-ClientProxiedBy: HE1PR03CA0022.eurprd03.prod.outlook.com (10.163.170.160) To BN4PR07MB2242.namprd07.prod.outlook.com (10.164.63.148) X-MS-Office365-Filtering-Correlation-Id: 28d977c0-d8a2-4b87-bb9e-08d399921bf7 X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2242; 2:/FT9SuBesrHUYXMzohmf6yyBxe+m0Fa8HduHffVXh/ctvTpV8USmF6+i5Hu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yzW4AsCqymYVZzitGXKjeyfgYZIsia3tiGVDoE9wVs+PXhBmXKKwvNm6vQKdm2eotzgNdVKMG4Ett4N3cKFeXGSpmFKkWAVNYc5nDHQBoO3Is07mzQt5oTT0Dt21ZcPU1LBPy0tvCdCOicS2H6JTJEqoHfEuBE7thId+r1kTmivOH7l8NWOml7aKN/N1E8kZTlShrBQRhU3bfS5Bcntz/pST6frjSYimw3RDX3Le9qgvbdrcEe+dKsuEo4P6e9NMRgvzToaUqVczzX+3mPrndE6zgxqCV6PK38/Q3IABMnLdtGNZAK29HVqii+l3JDl6Qja+kcaxAUO0Mxr3Aj9Hs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001); SRVR:BN4PR07MB2242; BCL:0; PCL:0; RULEID:; SRVR:BN4PR07MB2242; X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2242; 4:4dqQ7M9qmduEcIhx63T1sHS1W0A8i7B2RFi3735rOTowabKxqV/hIV1Rod7FBLfv1DJlTDlQTiARBLJUOrvysDu86tdw62baXCBNNirB+Cb8iXxVcvLRvDPw7ePHiHWEjfH8zcM3rI8KUMEA2D5O79C8FU/rlz8qtS5HnKCC3An4FX2PvkoT2jginxNOf8Tp3t9FfCK4H9nduAPGb5WlFEIz3ytVnl2ZffuGVl2vmAbfNOgllRFr4rttahhVUv4MxGU905GaWyPRsAt0dtWzszr4NEU2XDcvEpvSts/0+B6zCYgxxrRrRQPUV0JqkSI06kiVhwgWe94h9hUwnkAxyZs5WXVGarNzQFo3qUJ8aaeLZ6pgKR50xz18+QydxL8M X-Forefront-PRVS: 098076C36C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(199003)(57704003)(189002)(19580395003)(42186005)(19580405001)(77096005)(76506005)(229853001)(5003940100001)(7736002)(586003)(3846002)(6116002)(4001430100002)(105586002)(92566002)(81156014)(107886002)(2906002)(48376002)(5001770100001)(4326007)(2950100001)(76176999)(7846002)(50986999)(66066001)(50466002)(33646002)(50226002)(47776003)(8676002)(101416001)(106356001)(36756003)(189998001)(97736004)(68736007)(81166006)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN4PR07MB2242; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN4PR07MB2242; 23:H4rJuDHyRg+8cbb56Bf8XdQOC9oCd5kvo2aMG8Zht?= =?us-ascii?Q?0ra0BdWRgi9v7IXhMkfdeoxYIpP1jQmYx61I5/uqQPjvb++zCPe5yoT0mbx3?= =?us-ascii?Q?J7qiAhjjuI+U8SNentn3Gb1PuC+zI/aatTmwfXaGKkfMyXPUuTM7bEoDc86k?= =?us-ascii?Q?2mXxbQxWY61/3lghrsfZ5vEYtP/e6ZdkSOXId/WTGG3CuoZreIoS+skDD+Yv?= =?us-ascii?Q?p+mYIoWG9AB1OaCzoF5hRoVXPm5RFPZyw2JVcUSoAuIvoZJYNDLvrw22cVvb?= =?us-ascii?Q?6jYfQWFIDGQbCDHQ9318t6Dao7A002dwwlaMoq/nuKbBMfi1eRMXpiu1kJxZ?= =?us-ascii?Q?hrni2tikgTbkrL3CjokcBCIhODSYomzwBcmqxi8jg2Gq5MyQQP6XqPdVVt+X?= =?us-ascii?Q?h93qpgFwIoz1YtxVbqb4MGiv2xaiKSVZvpVUVTDIaozHMh0BzL9+JjC+nVdt?= =?us-ascii?Q?dOvl/rAZK3dIlB+rAIICbch5jqNboDvohLKiR9JG93Llhgl3QPXMCp4L0Veh?= =?us-ascii?Q?MG6eDblZl59AhMwEp7PwxIi6sdWLteHK8TRsjF7RB9KPnQH5bBdcTjNQ41Ud?= =?us-ascii?Q?r2TT5dWWka22HmUg5P3HA/vlk81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XXMEpH8fdUKYW8B1/QK0k8qqSaIlJwi9nWugViQT1nMhglNGXXKpIeY7lZ1tvopV2iYqZhrltCIsY1dQS6tA==; 24:BYHnM2xPs+GFfb+OqUaC/SxTpdQTqQ9OfCC79BLtCzHZEyNHYCGqcMarIZ8OvwJD4Rovkg9jZGVCTc1cwCMYpTWfBsJQhScCbGnEVG54ipQ=; 7:hxo/FPN5mnSQKpOjRrc7RgHSxcW+7vo/+H/6nKVM7T+IEQvaWL0JpkUAxYLgKZQnrb4BbwjPk2A9VRSIzZ7lMMJU6wFzhhp2A5RmvXNYN5kXlpKxrlUTwKLd/oK5vQGxboxj+EqxP6Ln9obP/C4C9WM6j4/t5M6lnzL+naNL5OjqhChtj0Ob74YTs00KY4+EcJ5+ObD9TvTic1tKVk+FUhNEhqFY/lb3iTdhmStxRhX4rUlXH1HMdwHruDVb2+zy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2016 05:08:39.8623 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR07MB2242 From: Andrew Pinski call_weak_fn loads from a pointer, so use PTR_REG so the load is 32bits for ILP32. * sysdeps/aarch64/crti.S: Include sysdep.h (call_weak_fn): Use PTR_REG when loading from PREINIT_FUNCTION. AARCH64: Make RTLD_START paramatizable Make RTLD_START paramatizable for ILP32 and LP64 usage and provides common code between ILP32. * sysdeps/aarch64/dl-machine.h (RTLD_START): Rename to ... (RTLD_START_1): This and add PTR, PTR_SIZE_LOG, and PTR_SP arguments. (RTLD_START): New macro which uses RTLD_START_1. Signed-off-by: Yury Norov --- sysdeps/aarch64/crti.S | 3 +- sysdeps/aarch64/dl-machine.h | 128 ++++++++++++++++++++++--------------------- 2 files changed, 69 insertions(+), 62 deletions(-) -- 2.7.4 diff --git a/sysdeps/aarch64/crti.S b/sysdeps/aarch64/crti.S index 53ccb42..6e149b5 100644 --- a/sysdeps/aarch64/crti.S +++ b/sysdeps/aarch64/crti.S @@ -39,6 +39,7 @@ they can be called as functions. The symbols _init and _fini are magic and cause the linker to emit DT_INIT and DT_FINI. */ +#include #include #ifndef PREINIT_FUNCTION @@ -60,7 +61,7 @@ .type call_weak_fn, %function call_weak_fn: adrp x0, :got:PREINIT_FUNCTION - ldr x0, [x0, #:got_lo12:PREINIT_FUNCTION] + ldr PTR_REG(0), [x0, #:got_lo12:PREINIT_FUNCTION] cbz x0, 1f b PREINIT_FUNCTION 1: diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h index a16cb11..7a49852 100644 --- a/sysdeps/aarch64/dl-machine.h +++ b/sysdeps/aarch64/dl-machine.h @@ -126,68 +126,74 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) /* Initial entry point for the dynamic linker. The C function _dl_start is the real entry point, its return value is the user program's entry point */ +#ifdef __LP64__ +#define RTLD_START RTLD_START_1("x", "3", "sp") +#else +#define RTLD_START RTLD_START_1("w", "2", "wsp") +#endif + -#define RTLD_START asm ("\ -.text \n\ -.globl _start \n\ -.type _start, %function \n\ -.globl _dl_start_user \n\ -.type _dl_start_user, %function \n\ -_start: \n\ - mov x0, sp \n\ - bl _dl_start \n\ - // returns user entry point in x0 \n\ - mov x21, x0 \n\ -_dl_start_user: \n\ - // get the original arg count \n\ - ldr x1, [sp] \n\ - // get the argv address \n\ - add x2, sp, #8 \n\ - // get _dl_skip_args to see if we were \n\ - // invoked as an executable \n\ - adrp x4, _dl_skip_args \n\ - ldr w4, [x4, #:lo12:_dl_skip_args] \n\ - // do we need to adjust argc/argv \n\ - cmp w4, 0 \n\ - beq .L_done_stack_adjust \n\ - // subtract _dl_skip_args from original arg count \n\ - sub x1, x1, x4 \n\ - // store adjusted argc back to stack \n\ - str x1, [sp] \n\ - // find the first unskipped argument \n\ - mov x3, x2 \n\ - add x4, x2, x4, lsl #3 \n\ - // shuffle argv down \n\ -1: ldr x5, [x4], #8 \n\ - str x5, [x3], #8 \n\ - cmp x5, #0 \n\ - bne 1b \n\ - // shuffle envp down \n\ -1: ldr x5, [x4], #8 \n\ - str x5, [x3], #8 \n\ - cmp x5, #0 \n\ - bne 1b \n\ - // shuffle auxv down \n\ -1: ldp x0, x5, [x4, #16]! \n\ - stp x0, x5, [x3], #16 \n\ - cmp x0, #0 \n\ - bne 1b \n\ - // Update _dl_argv \n\ - adrp x3, _dl_argv \n\ - str x2, [x3, #:lo12:_dl_argv] \n\ -.L_done_stack_adjust: \n\ - // compute envp \n\ - add x3, x2, x1, lsl #3 \n\ - add x3, x3, #8 \n\ - adrp x16, _rtld_local \n\ - add x16, x16, #:lo12:_rtld_local \n\ - ldr x0, [x16] \n\ - bl _dl_init \n\ - // load the finalizer function \n\ - adrp x0, _dl_fini \n\ - add x0, x0, #:lo12:_dl_fini \n\ - // jump to the user_s entry point \n\ - br x21 \n\ +#define RTLD_START_1(PTR, PTR_SIZE_LOG, PTR_SP) asm ("\ +.text \n\ +.globl _start \n\ +.type _start, %function \n\ +.globl _dl_start_user \n\ +.type _dl_start_user, %function \n\ +_start: \n\ + mov " PTR "0, " PTR_SP " \n\ + bl _dl_start \n\ + // returns user entry point in x0 \n\ + mov x21, x0 \n\ +_dl_start_user: \n\ + // get the original arg count \n\ + ldr " PTR "1, [sp] \n\ + // get the argv address \n\ + add " PTR "2, " PTR_SP ", #(1<<" PTR_SIZE_LOG ") \n\ + // get _dl_skip_args to see if we were \n\ + // invoked as an executable \n\ + adrp x4, _dl_skip_args \n\ + ldr w4, [x4, #:lo12:_dl_skip_args] \n\ + // do we need to adjust argc/argv \n\ + cmp w4, 0 \n\ + beq .L_done_stack_adjust \n\ + // subtract _dl_skip_args from original arg count \n\ + sub " PTR "1, " PTR "1, " PTR "4 \n\ + // store adjusted argc back to stack \n\ + str " PTR "1, [sp] \n\ + // find the first unskipped argument \n\ + mov " PTR "3, " PTR "2 \n\ + add " PTR "4, " PTR "2, " PTR "4, lsl #" PTR_SIZE_LOG " \n\ + // shuffle argv down \n\ +1: ldr " PTR "5, [x4], #(1<<" PTR_SIZE_LOG ") \n\ + str " PTR "5, [x3], #(1<<" PTR_SIZE_LOG ") \n\ + cmp " PTR "5, #0 \n\ + bne 1b \n\ + // shuffle envp down \n\ +1: ldr " PTR "5, [x4], #(1<<" PTR_SIZE_LOG ") \n\ + str " PTR "5, [x3], #(1<<" PTR_SIZE_LOG ") \n\ + cmp " PTR "5, #0 \n\ + bne 1b \n\ + // shuffle auxv down \n\ +1: ldp " PTR "0, " PTR "5, [x4, #(2<<" PTR_SIZE_LOG ")]! \n\ + stp " PTR "0, " PTR "5, [x3], #(2<<" PTR_SIZE_LOG ") \n\ + cmp " PTR "0, #0 \n\ + bne 1b \n\ + // Update _dl_argv \n\ + adrp x3, _dl_argv \n\ + str " PTR "2, [x3, #:lo12:_dl_argv] \n\ +.L_done_stack_adjust: \n\ + // compute envp \n\ + add " PTR "3, " PTR "2, " PTR "1, lsl #" PTR_SIZE_LOG " \n\ + add " PTR "3, " PTR "3, #(1<<" PTR_SIZE_LOG ") \n\ + adrp x16, _rtld_local \n\ + add " PTR "16, " PTR "16, #:lo12:_rtld_local \n\ + ldr " PTR "0, [x16] \n\ + bl _dl_init \n\ + // load the finalizer function \n\ + adrp x0, _dl_fini \n\ + add " PTR "0, " PTR "0, #:lo12:_dl_fini \n\ + // jump to the user_s entry point \n\ + br x21 \n\ "); #define elf_machine_type_class(type) \