From patchwork Wed May 4 06:27:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 1626081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=MVIMKGve; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KtRlT0GYrz9sG6 for ; Wed, 4 May 2022 16:30:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5FD0385742F for ; Wed, 4 May 2022 06:30:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5FD0385742F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651645810; bh=xeTJYuqv4J+kyT3Q0Oe9cxcZrXQZUbCCEsUGeftT09Q=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=MVIMKGveJxVCzrS+a0HM3Yaama1nOh4tdLZgaoSrx9hb6E3fRnSUcfdVZH4En+BzU Obd2Jgzsy6tjsg68yWlix/RPGwwBCBQo136HfZ3d6wjDwPSMzBOd5rOReOqUCCvfWW NunI9r6vvOvklLe/CYZ0KDiRqJmY1oGXuJVsuVaU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50047.outbound.protection.outlook.com [40.107.5.47]) by sourceware.org (Postfix) with ESMTPS id 7CD0F3858418 for ; Wed, 4 May 2022 06:27:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7CD0F3858418 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=GzxdGmWAUqCbecG6ItsmCVrThxY1oB4ZcWJ97YGcXrIU+sAbMu0ViJa26BAKnV5Y5uZTZOOTPqbP1/Qa4mmWxa+L2vakk9UDbptpzkigmW9HVqyhvmM4oUIHsrhDwzc6iCje3ynnj7ci+wgB6VnS+ew9l6gLpdTR9l+YK4CeV6PmXxhsHUj3uUGmU53YhX9xkRlmdW4QOYBvZt6gmUSz1k8CRX8Gjjku2dMN6ECtUDouxeOpLAlyF3SorUJ5Bs7hQsVvv9AWXxKyNFHW6pDZEz3KYbvOKO2petQY2Ob0d1FuW1XGAzV3wXMdYja45FErvhnF5g4RnFQHQ632U1HKFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xeTJYuqv4J+kyT3Q0Oe9cxcZrXQZUbCCEsUGeftT09Q=; b=A/EErJ/gsmSYTULgBieP++2xYmcCB8cVGoo3R+Ezqf9xU5PHp2JFMyV70Rz/51bC1qEsDsJJE1h1cAAI22sxpDVQ6eOj3A1zfoUX+DHyZuhiDinqopM54MPxs5fGjTy1N0XWZ7KNOr0Numzt7uxqeBYt+c82VEs5fSsXWDpN7W20f7HjRbG9TYtFotWuXujb76chOXnHEbNHWW2txuZMAF96IK6IH3RcH8CsKGkJT1PAzsYWManRQWyCRyTQguHuPD0zVuYv3LaYkY02nDMDgvcqzC/hFoC1O2JA2mn/Af7OpxNBnBoJqYnbhxuXQ8L6Kzc32fyLeF0LSuKWj1uzPA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1, 1, smtp.mailfrom=arm.com] dmarc=[1, 1, header.from=arm.com]) Received: from DB9PR05CA0017.eurprd05.prod.outlook.com (2603:10a6:10:1da::22) by VI1PR08MB5439.eurprd08.prod.outlook.com (2603:10a6:803:13b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.14; Wed, 4 May 2022 06:27:26 +0000 Received: from DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1da:cafe::ca) by DB9PR05CA0017.outlook.office365.com (2603:10a6:10:1da::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25 via Frontend Transport; Wed, 4 May 2022 06:27:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT016.mail.protection.outlook.com (100.127.142.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Wed, 4 May 2022 06:27:26 +0000 Received: ("Tessian outbound 9511859e950a:v118"); Wed, 04 May 2022 06:27:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b9ada3eb648d6c70 X-CR-MTA-TID: 64aa7808 Received: from b52703bd12f7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EF557554-BFF5-41F4-AAFA-CB91814CC6A7.1; Wed, 04 May 2022 06:27:19 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b52703bd12f7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 04 May 2022 06:27:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fl1yBvw7m9H6X3ssofprix16LfoJUMq0WhiV7Z3QNEx5r6K+3EJOM+KocBaQ7PwGD5iFobNfldt8/7NV0Rv6RMNixheahlcVxc6S81gxH6dTSnJaDWjTZ5ysDLkGQWehFDh0RYe9iKLw6urb9cw5vW81GncPwnF35mY4XT30Pl8jygyRX0zUMIpuwMjjBElUDK6v5CsqLwuQUyIxkgwIwGGFe40eXK4jzUTmwoF87Wvl0XbOOEjtgOTueA2ku4YupQaswqzTgVMhQjjkBrcoQvFOlNWpeO3k1kCRdHHi+S6jurIU7k6JG80cvxA+swgPsaym2js+Jel8XF7Bfrb3+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xeTJYuqv4J+kyT3Q0Oe9cxcZrXQZUbCCEsUGeftT09Q=; b=LYSytsCtNDNJV1ElmGjZVTWWguydcljWJbpSArz6K4XgJyRleDVSC13DUcbpiw3ZLqAXPRV5KOxs5OPDVZi90habt9bVYT/lWJJXhGVIRaTweEAIO0jj+h/qQUO3wg6Azj1undnNLBEeoCCkayLtn831JQ80lkPCoh0FWA3vNoICsOteNzG2wvKrETMv+ksRr5KZn2EvpJ1PHLfgLTt8DbFYTUPQIlPj94EaWDpzxuPOvT89DPoE7uT11p9Nnt67wk9+x0uSR/obSDRs0wuBz8HeoPFxknK9dhZxP0EWciTCxb1Q0UCWKBX4aABI4AAR7mgI7USrB4CNL75NC+uydg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from DBBPR09CA0006.eurprd09.prod.outlook.com (2603:10a6:10:c0::18) by AM0PR08MB4561.eurprd08.prod.outlook.com (2603:10a6:208:12d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.13; Wed, 4 May 2022 06:27:18 +0000 Received: from DBAEUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::d) by DBBPR09CA0006.outlook.office365.com (2603:10a6:10:c0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24 via Frontend Transport; Wed, 4 May 2022 06:27:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT062.mail.protection.outlook.com (100.127.142.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Wed, 4 May 2022 06:27:17 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 4 May 2022 06:27:20 +0000 Received: from armchair.cambridge.arm.com (10.2.80.71) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.27 via Frontend Transport; Wed, 4 May 2022 06:27:20 +0000 To: Subject: [PATCH v4 4/4] aarch64: Move ld.so _start to separate file and drop _dl_skip_args Date: Wed, 4 May 2022 07:27:16 +0100 Message-ID: <04cfa0c448fe88a5fd9895b65c4b8f15de63cda3.1651643916.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: c14419b5-cd08-459c-45a7-08da2d97285d X-MS-TrafficTypeDiagnostic: AM0PR08MB4561:EE_|DBAEUR03FT016:EE_|VI1PR08MB5439:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: wuusA/sLP8eYXXJBEMfmzuyvUBwtPPwo/bGZ+lfAwfaU3xaHR/CjpJZqS34PBpGEF6QVok+Uh+PZgGvzzD01zOWo9hugQ1hqBOHUmOZ7QXz9FMu9yFhSGM8ePlW3DdTbVsgAR2C2+6fkyFWw1MpbRug+4dmtfDvR94QGHnyVX5OscFh8Ap7h4FCAcL0ySEKQI8Lglg0bEmvElsZ1K4fh2sziN2Fp3WGqft/SdlJIhriaLPhkRlJS+nznd+943+SY07NBw2R4MHs5V1A0pl2PzglcncsnDKOHITF9X8kk69UAVKw1FZiruZI2ORo4sebMHiE4PAP47xlHdrIdN/x+sg3Wp5yv8DwkwUlyp5A+MVR9iD6QwUZ776hw8Vk7iipJYuEjkD8ooiCos0wq2B40Xd/NMBgW1pyGgdD4nKw6kaUegJEtQ832qHoSoWL0ILv7IxxVbUReH2P3awy80Ov8MsYTvmjMLZJ2eAkE1H+L4B0PFgLFbL/vsE4dSFx7NQ4JTmALz3ZnIKIF/Bv1+ht+0SeIqvtCxeAJgplhXhSyCmHV4XBhr+zAJXaUie1Wi2Xb0D6UKfAvoznm4GxlvtQ+WMGtex0y5qWaKEGh1I5qJwhHWf7r430KVFPmswPSiMjufQlfT+JY4kUf2Bidi91B8g/QC4k2BW9lnInzveat0qMNaEVs2q0tz1+oIBzI1lhvLEwsJ9POo8TLnqoE5IeSSixmU/3Fx2IG9He5lkVttCNrP/f5cPM8mZSy3MC/g9CjoeMaoBrrIY2fOXDv8whuRRjuXI3uUUbWe9KRAdHVzZ3phGWemNG6Tu8PzLKa5uoW X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(40460700003)(2616005)(83380400001)(81166007)(356005)(36860700001)(7696005)(2906002)(26005)(5660300002)(70206006)(70586007)(8676002)(82310400005)(186003)(47076005)(44832011)(316002)(426003)(86362001)(36756003)(8936002)(336012)(6916009)(508600001)(6666004)(2004002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4561 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a8b6daa3-dc82-4418-ddf2-08da2d9722ec X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RzMy2mI4zqnOTdiW3gb08AFQSO5rbVQF6dBMBNwUDA9gZPqJ9LR88lbqSpAv3oGVzyNy3ofzcxBtAkNcALs/CB2Kwo+8yUh7lZSwVkWkVZQ5FwgClsLxfbll9S00NX7VLUaPKG5tgJR2/sdrYxG6g+aGr4b+6qXn/skYhgq9jHKPKXiop0iD0H8bV1y9dYeXv9+FPXPg9zH7D7Gosr7n4eDRFDCDIEJIGOqxAi4tv7w/GGS280FTQKSEC0xepx2WaJAFSeLOxmxrk+5hoPOHHD+SuvijuKo5rLxZU2FI8/ioZixfR8k6OY3jkBTpN/9TSPD3UuiO88ey+1mjK9FRbFh36x7rHPps5n19ZsawxQcB7yIPZTkvLzVcmFYEr03soFFTTHG1ssQXJtRhiEDlA6jxLNi4OiRwZxic1dsJyPxxSx2szkWQP14ovDeP/+ERyhsZB51D5n4Kd8shsiwKewpXr2wk3XQ7taZ4Z5FRbxlX7ytYaYMCkS6idAqhKepr/Flw1uiZAx/XIJw+lywDQp9AhRutgxrRhNQs4Ej0hMk1VRkArdtkKO2ztDZBz1IS6I07YG/jx4LYmHZtcVyxKtd/2RU730j5at/c4xW2e/wK4+RnsZ1mITc9Mhq6Hw+Ihwu+Eck/DLmgPF5weAYWiB9jGjjXh+XtDRj6S9fWlEWgNviV+k/tWsYsqnfHhCJ8oRYFGA13sPYTnE5XGfVvoLt9F6hEimoyo0pcOscA9rQioGGbM/T2jRDRGNYtpyZAz/me5RQTrolX2zlE7zyT8/FcTZh85iq1SCChS9MWtRE= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(8936002)(5660300002)(81166007)(316002)(26005)(6916009)(8676002)(70206006)(6666004)(70586007)(508600001)(36756003)(86362001)(336012)(7696005)(186003)(40460700003)(426003)(47076005)(83380400001)(36860700001)(44832011)(2906002)(82310400005)(2616005)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2022 06:27:26.6859 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c14419b5-cd08-459c-45a7-08da2d97285d X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5439 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" A separate asm file is easier to maintain than a macro that expands to inline asm. The RTLD_START macro is only needed now because _dl_start is local in rtld.c, but _start has to call it, if _dl_start was made hidden then it could be empty. _dl_skip_args is no longer needed. --- v4: - adjust commit message about _dl_skip_args. v3: - mention _dl_skip_args v2: - fix typo in commit message. --- sysdeps/aarch64/Makefile | 1 + sysdeps/aarch64/dl-machine.h | 77 +----------------------------------- sysdeps/aarch64/dl-start.S | 53 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 75 deletions(-) create mode 100644 sysdeps/aarch64/dl-start.S diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 7183895d04..17fb1c5b72 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -33,6 +33,7 @@ tst-audit27-ENV = LD_AUDIT=$(objpfx)tst-auditmod27.so endif ifeq ($(subdir),elf) +sysdep-rtld-routines += dl-start sysdep-dl-routines += tlsdesc dl-tlsdesc gen-as-const-headers += dl-link.sym diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h index b40050a981..fe120bb507 100644 --- a/sysdeps/aarch64/dl-machine.h +++ b/sysdeps/aarch64/dl-machine.h @@ -105,81 +105,8 @@ elf_machine_runtime_setup (struct link_map *l, struct r_scope_elem *scope[], return lazy; } -/* 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_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\ - // bti c \n\ - hint 34 \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, __GI__dl_argv \n\ - str " PTR "2, [x3, #:lo12:__GI__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\ - mov x16, x21 \n\ - br x16 \n\ -"); +/* In elf/rtld.c _dl_start should be global so dl-start.S can reference it. */ +#define RTLD_START asm (".globl _dl_start"); #define elf_machine_type_class(type) \ ((((type) == AARCH64_R(JUMP_SLOT) \ diff --git a/sysdeps/aarch64/dl-start.S b/sysdeps/aarch64/dl-start.S new file mode 100644 index 0000000000..a3a57bd5a1 --- /dev/null +++ b/sysdeps/aarch64/dl-start.S @@ -0,0 +1,53 @@ +/* ld.so _start code. + Copyright (C) 2022 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +ENTRY (_start) + /* Create an initial frame with 0 LR and FP */ + cfi_undefined (x30) + mov x29, #0 + mov x30, #0 + + mov x0, sp + PTR_ARG (0) + bl _dl_start + /* Returns user entry point in x0. */ + mov PTR_REG (21), PTR_REG (0) +.globl _dl_start_user +.type _dl_start_user, %function +_dl_start_user: + /* Get argc. */ + ldr PTR_REG (1), [sp] + /* Get argv. */ + add x2, sp, PTR_SIZE + /* Compute envp. */ + add PTR_REG (3), PTR_REG (2), PTR_REG (1), lsl PTR_LOG_SIZE + add PTR_REG (3), PTR_REG (3), PTR_SIZE + adrp x16, _rtld_local + add PTR_REG (16), PTR_REG (16), :lo12:_rtld_local + ldr PTR_REG (0), [x16] + bl _dl_init + /* Load the finalizer function. */ + adrp x0, _dl_fini + add PTR_REG (0), PTR_REG (0), :lo12:_dl_fini + /* Jump to the user's entry point. */ + mov x16, x21 + br x16 +END (_start)