From patchwork Thu May 5 13:59:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 53522 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 962EA3856257 for ; Thu, 5 May 2022 14:03:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 962EA3856257 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651759386; 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=WlOu56Vf7AVvulibqOJS+vcERwqzXPJw+sMGEEPY5UzvglNqyT1kbs8/JwAHKfra4 Urv9bgu+wmil/OoHdvt5pcSOw605girfGhzc1U7W7ViUy2Azqbq96FBkz61B8MdVyN Cb6FXC9Pxfpy7OMG4eP4mtAoGsdSwwDPUUdHES2I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70088.outbound.protection.outlook.com [40.107.7.88]) by sourceware.org (Postfix) with ESMTPS id 9A8D83856243 for ; Thu, 5 May 2022 13:59:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A8D83856243 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=gbiPd1h5JAhascCHTO2DEtWdHAb+k96vG98hDNmWHY0ImQNvW5Gj0+2b/ycTSZtPdaRrA+18RAZMlc0/2yw1p1wx914g1hqELMpS1Pzj2ZEemE4ty23rSw0Ejovh7dmp/GITpttlWF2wCMrWQfTIW7hZxywa5tHUwF5LBSu/tro7lFVfN1dGVxMDjO57wk8zV9IXPpO2vb8SS2anqWEh8PNX5kUV4u10ZPSnk8eRF+O9URiVaE5meKLN2zrha21vQBt+hYzhpT14chHAGE9tpu1fZRlWmVNAHdfQz2M5Tw9AcrDF71dVkYBTddLva62ecTKe0wwHc7oW7wyXYFOJgg== 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=TyWZtIS61RO8jk/8uhxGvFrOORGeqzos3e0CrZ9N1PPjXusvyHjEC/FGnFkCOs0PcsQSqAk2a7n2aqgZLEruFyu5QEyRILN4mkNl3Xwg9e2EmkCUcDdW6RJALXTdpoGqx5k272AIVTwS9sqlBS9Y3SLQeRmk7FHgyOwgvcx3r0rrPVUiU62mpwuxHhS0lR6D5/2oZWeN2LmTykiASJ/vKa+6FIxiewcQ6f69EGmO8ny6we4Gd0KnRLIihFOgWeZNuKZz6oB0TnjfNZnOmGluU++AbZ3zy7LeEWtQMfiOZggCqT2rQODtIuZTb8t0LQ1Di83BEjc8ITdUujquFpj4jQ== 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 DB6PR0202CA0043.eurprd02.prod.outlook.com (2603:10a6:4:a5::29) by VI1PR08MB4046.eurprd08.prod.outlook.com (2603:10a6:803:e4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.13; Thu, 5 May 2022 13:59:40 +0000 Received: from DBAEUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a5:cafe::1c) by DB6PR0202CA0043.outlook.office365.com (2603:10a6:4:a5::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.27 via Frontend Transport; Thu, 5 May 2022 13:59:40 +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 DBAEUR03FT048.mail.protection.outlook.com (100.127.142.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Thu, 5 May 2022 13:59:40 +0000 Received: ("Tessian outbound 62985e3c34b6:v118"); Thu, 05 May 2022 13:59:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 49d4c9054822e286 X-CR-MTA-TID: 64aa7808 Received: from 113264d9b725.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8A581E08-9F6F-45D7-93E0-A7537E1CC7EE.1; Thu, 05 May 2022 13:59:34 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 113264d9b725.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 05 May 2022 13:59:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b9HoDVei2PvG6FSA4ZW9X9OSV+qHYJy/Yqi+XjOznYmmcjAnCWfFzfD2uT2RCJX1KdhWCa09VNyga2LF1Qt/PctbIG/B6282bO9ZuczVba5h2aFIZubjOm91ZVOwWTXpVyfYyRlI+q0mBgWrqCgrNDzHHENGjsvh2HIIsEWWrccXlL9DTk3GiKihD/IXnfZt6z9vvva99901Fi9jCpEUoocsUwtR3sy/v2cW+g6DZ8iSqu680yrkhC7a1bZw6cbbno5ItPUQccQg3rTniP/2dlfZDS/OeC3TIgsX+4kFPWqhOPdWX3lC9Jf+UTeqXIQ8MLejeshxNxSmX1aKlDzPlw== 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=CVwr86A74D22qnqF0gmxQi7rHPriwLwjZre8LXt3tD+AP+4PIHrTKavK2WlEavYR5bgpKcEWpXnAtrWnruRq79/zagY55xqQGugXtNDVPAcZ2pBGkpv8h6wntjo7IsOTJ225VFL0akFDGVx8HUe8leL3q+ONK3mPE5GoOETtJg5dPcDSFZnwmLria/MnLTd9doHuhSvRw6yEuXOHm2Ba6zAZ0IFiJismBgprYD5iYcPqftTXkfPx4MFBIT9uNd+hyQoVvsDiOnO+SqPdjUd8oSAwt1boSJGg2CTVMAOiubaZ+t3Uhp2llvOPKPBxsR8/AsB8OEIujxCeZ2asZThUvA== 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 AM0PR04CA0068.eurprd04.prod.outlook.com (2603:10a6:208:1::45) by VI1PR0801MB1741.eurprd08.prod.outlook.com (2603:10a6:800:5a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 13:59:22 +0000 Received: from VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:1:cafe::e1) by AM0PR04CA0068.outlook.office365.com (2603:10a6:208:1::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.27 via Frontend Transport; Thu, 5 May 2022 13:59:22 +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 VE1EUR03FT034.mail.protection.outlook.com (10.152.18.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Thu, 5 May 2022 13:59:22 +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; Thu, 5 May 2022 13:59:25 +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; Thu, 5 May 2022 13:59:25 +0000 To: Subject: [PATCH v6 4/4] aarch64: Move ld.so _start to separate file and drop _dl_skip_args Date: Thu, 5 May 2022 14:59:21 +0100 Message-ID: <30ecd158a7425badc5996450816a3ca3dd86e9c9.1651757640.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: b642dbe0-55a7-4b34-88c1-08da2e9f7faf X-MS-TrafficTypeDiagnostic: VI1PR0801MB1741:EE_|DBAEUR03FT048:EE_|VI1PR08MB4046: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: eAamhI8BI3cY3hDqXCo7Ns6By9ue8UYqMFtRn6ZEzfFiRizn/zLshX/QRr2ITpHJny4irdj8kDFC1DDy3Vz55vdeot4trYWCivFBejfkYDRBGPkbEHpkBaZENjwXx1aksoXsemctD1l6YtYd14NSXqSGiHV4gM1So3wuMuT51EyTzaXWIZ7i1Xhx5I1bSBm0BnTXEDm56YuXmjtWH5rh1rWA5Z9P8agNjt7QfOWr4xG2w3NiskfqoiEvOZzOH38hXgKaxHXJqqxUe9xnb6uvU/4v5gECi0mSYQzZA6QeXREA4kkOfO4hqhwSwDJP5yhvT5NOuHi6ce3a6G3LXgtyB7nQfsBWEK/vIXXOR0Z9KgN2Uhv/0JnJMIZESz7sOPys/+OGupJeEHmtjjYrulGr+yPFjPF5/3F5ra03QHG3/ffD/y912v39jZrbtax12DwfBRF69sVCBhJE8oT3NfCRxpEjY4qTUeU0cykyf9u/qhPd2RV5WTWhKI1JKgKrloxJtlLUCOth1pUTNkO89P9D8AzFlmftwR7qyD1QVA3Cn6psu53xdWpP4hjmEzfD5YBVbciXEPA1MHESX21i8qy+Z2VHTksW2YVbKR5qkRm8/1GCcQyNA2IyLvkc0oe0j7Gkwf9YMKy2FdcWFSnMlizI6+ffTwysegdOODHuxI4j2bZh+Uv8573Q6uVxJBgjMqJjYNMZ5DF/xYfl40mvw/xJXej/sbt/f74EmyoaTGNFGJ/WzV091+zpKDTsH28TI3cRr0rBnEpAlqclSKgHszZlfCnVwcsUENYQ6zGrlq5li120S7Vus4+0LlazqBC4NHst 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)(36840700001)(40470700004)(46966006)(316002)(6916009)(36860700001)(36756003)(83380400001)(8936002)(82310400005)(86362001)(26005)(44832011)(6666004)(7696005)(5660300002)(70586007)(70206006)(508600001)(8676002)(2616005)(336012)(426003)(186003)(40460700003)(47076005)(356005)(2906002)(81166007)(2004002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1741 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 74071e79-8d1d-4883-8d7b-08da2e9f7503 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eGAlEOTBlavq2gyrn8lMU1M6abrMnekY46esqtIldOZrj8ZGLV4DnnhYvtPceVD/uUC8HuE6B42lvwc7twef5Hj+qSZp4jOJdeByw+PUjznt+4nfXXlMDr+efzZmokOMaX9qUf3zBH9TyU9GiXP3G28VS11DAuyQIjniYWtV28CiR4MGeMIm+yXUbNeOSO3l+xKSty2qWxo4Tma2rfLRJyWiR99jfXZhWCPEsyQplLtssBPt/3iqfxQRv/kFyL2w+PySSSfJFFMUcXTYMPQVgObZ4cmITVxTu/tRWQ1hQKe8JCT8PR7UkWfePzbgavGZbHqlmZXOg29KQ+K/dmnRwCqUtR1tJ2etXNGLKYzcgAeMjUqca+H3OG58LNOt/ylIYySRcYxj+7QTjROXl1XS9/RqBZ7WbiJ/yQMRzWzVd2sBykLHzrJkjgP2dIYdHZxb/vkwpeQ6lqA6x0Xv1KK7l/Ea4ZfheYq/DbsmZQaJ8jUCFvyx9UkNCuTEjZvs2NrCfulHJM2FZZFAxy94ig1uzlofOc+MMnNA3bCbpLJVKkf44FHD3pQy8L/8kNP1z2D9mBlo5u8H2lLGEeq6U/icJnOLBgGT4wxizF3ZbANV2JxWwN4jCUTRrr88NPkRQyCZQEjbQfezoZN4dgxFZo087jsvwj1Bms/d+woAIL92jC0iCVuevWqAbq2yS/xrBynTAgefaZEq8fE3TqGiylBeMgHVXcZAYuvxrGt9Bh65rQhMykfGKg52QNTB1O0x3yHhg5kaOkUlzgYbdKe89yWZJ0gYOUCyMw49nXeDDfQMpCE= 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)(36840700001)(40470700004)(46966006)(8676002)(26005)(186003)(81166007)(316002)(70206006)(86362001)(70586007)(2616005)(6666004)(7696005)(508600001)(82310400005)(426003)(336012)(6916009)(36860700001)(44832011)(47076005)(83380400001)(2906002)(40460700003)(5660300002)(8936002)(36756003)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 13:59:40.3078 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b642dbe0-55a7-4b34-88c1-08da2e9f7faf 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: DBAEUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4046 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+patchwork=sourceware.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. Reviewed-by: Adhemerval Zanella --- 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)