From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70042.outbound.protection.outlook.com [40.107.7.42]) by sourceware.org (Postfix) with ESMTPS id 9210838582B4 for ; Tue, 5 Jul 2022 16:30:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9210838582B4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ZKyAVh1U5rKMIQPuD6scBwri31sXkl3Rx48w3LLHsopsPoyBrNqI379JX09+u/vlmBAz+vxhyF4UdovOXiQBze8Ypi09l0nUV5ePKd0uoaDMKEUb8r8OVy6xIsDkwmMo++PBcL5EXZmCxBnPj9k/iw7jxZTjzl3/9SfSdeatdFnJdQHB0K6IWYw69KMCpF0doL0DffXTxwhbDHvV+QHlctd3q5OdD/OvjITcUUsbY99R+W4PSHIkjdfJGt9R4YcAax4p6HdX8TFYD5wsJ8j9ZV8UFzpX72ltUOGsRrLnMUh18IoTIa3wn54k27icm2LqixDO5WMTuuWNE8E7LlR/FQ== 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=Npy27GUe80KkI5xWL4wMSyjsbfocM0ij2cf9BYushpo=; b=QnO/gaklyb+yWWTm6SlGIeL+kRsS4CpPwJJOJHZ0CdYsYIJ3MO70V4kInR0Ntjnw+NW18gRBHXzlYVded7htfu+gtbn2oU8hhIxL2P0ycCQk+i7RFwXHhzKikkIKTELMs/IwqbthIUwxppWerrMiVvf+v0IhJkjK5kovHQXGHQyT6gBY2cDkeExnSgG0o6RmjOc7UnKa6vt8eB3ZDyeMAaRO6iAUJ0Cyp/NMFcQQeXKoeIMqHrE/XZU8Hd0YgL5Slq3dCcn7mB9yJu3D4NsgfY0PgTgh1+E9coNQvL/gEd8kBNnPEZAe7VpottT01/p49OGc2uxV0p8jFvZIDReOxg== 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]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Npy27GUe80KkI5xWL4wMSyjsbfocM0ij2cf9BYushpo=; b=o6ckLRt2OzrbNxpk5OPf73amRy3FWij2A6ZEwM0h1oy3BXjtyIWGMcyzxSdNzLMkZPHZVCsbNE9JmQuyabLQ8RyLH3JhcY/kZU25cfhv1/zVn9uV5W3ypjg2AgifueKZ4vgdSwqwNlaumiFPZHzvCcfQ9F8LQ2xrtKohrVH8IBY= Received: from AS9PR06CA0141.eurprd06.prod.outlook.com (2603:10a6:20b:467::13) by AM0PR08MB5284.eurprd08.prod.outlook.com (2603:10a6:208:12a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.17; Tue, 5 Jul 2022 16:30:53 +0000 Received: from VE1EUR03FT003.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:467:cafe::d4) by AS9PR06CA0141.outlook.office365.com (2603:10a6:20b:467::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15 via Frontend Transport; Tue, 5 Jul 2022 16:30:53 +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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT003.mail.protection.outlook.com (10.152.18.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14 via Frontend Transport; Tue, 5 Jul 2022 16:30:52 +0000 Received: ("Tessian outbound 190453a6d737:v122"); Tue, 05 Jul 2022 16:30:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f697752b5efe63f3 X-CR-MTA-TID: 64aa7808 Received: from d479ef706473.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7F671E89-EDA5-4939-8019-6C2DCBE17611.1; Tue, 05 Jul 2022 16:30:45 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d479ef706473.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 05 Jul 2022 16:30:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KFkAGx740gtanJDATLMXAs25c6q8Jnl1Pyx+OyEztqaHBzQ9MJbU5k0ThKm3KIVGeaZagZWXRmTfYMhSEhCyl2Pweb8fMrmqrs0wmGkjVDvX4QEQWeoMsr9uYSZ7S7x4CGGHMaq4cj8b1gW2ArjB2q+/SscJfVzeUi5YPWHTCZT6XUKEJOE2pJohCQWni7cUlL3BroCSVeFcmyqlzItnqgdd5nBWvlK1ykAzOk+B2EvRJzAQ2m1LPZAN4ws8trc32SSRDK4Jh9rpwWsg9V5Fgn4ImTz4RB4rcKCrIlhWndGIz6WpChY4JNTIj6nYn9Fs4rN9ymN3ujRF8F2UgKtG9w== 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=Npy27GUe80KkI5xWL4wMSyjsbfocM0ij2cf9BYushpo=; b=R7lA/2vw9oNFMKFOxE+83bZ6T2hOF4U+BXIkT7BTrjakq2WpEXF/57Xj2V8zBA5C/TnrrICrlNWIga4jsLJtU4O0rJHTeTIUg7aSy4vUbRAhu1NiD4WtmZxeHewZCci9RsNtp/PxCzOH2955nAousU5+5LYKGkY7+Vqzn3c/GG7m21jRpuHb/OyBYnejUKX65GQX6bjtALO0PltYIJpiQyPGgH+qqL+HfO2w9LQNgwoiemQ5yF0ASpPYyYkFaRAR6e6k1/BvQHF4mQoV1gbP4gvlEcQgqy+Iq88jY8RhWPAOnhtiCuLC2c4X8ovrpnev15DGUWikqBu8SHFTkaApOg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Npy27GUe80KkI5xWL4wMSyjsbfocM0ij2cf9BYushpo=; b=o6ckLRt2OzrbNxpk5OPf73amRy3FWij2A6ZEwM0h1oy3BXjtyIWGMcyzxSdNzLMkZPHZVCsbNE9JmQuyabLQ8RyLH3JhcY/kZU25cfhv1/zVn9uV5W3ypjg2AgifueKZ4vgdSwqwNlaumiFPZHzvCcfQ9F8LQ2xrtKohrVH8IBY= Received: from FR3P281CA0089.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::18) by HE1PR0801MB1673.eurprd08.prod.outlook.com (2603:10a6:3:86::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15; Tue, 5 Jul 2022 16:30:40 +0000 Received: from VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:1f:cafe::21) by FR3P281CA0089.outlook.office365.com (2603:10a6:d10:1f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.6 via Frontend Transport; Tue, 5 Jul 2022 16:30:39 +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; pr=C Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT032.mail.protection.outlook.com (10.152.18.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5395.14 via Frontend Transport; Tue, 5 Jul 2022 16:30:37 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.9; Tue, 5 Jul 2022 16:30:37 +0000 Received: from e125768 (10.2.78.50) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.9 via Frontend Transport; Tue, 5 Jul 2022 16:30:37 +0000 From: "Victor L. Do Nascimento" To: Richard Earnshaw CC: Subject: Re: [PATCH 3/8] newlib: libc: strlen M-profile PACBTI-enablement In-Reply-To: (Richard Earnshaw's message of "Tue, 5 Jul 2022 16:39:41 +0100") References: <20220705135818.50088-1-victor.donascimento@arm.com> <20220705135818.50088-4-victor.donascimento@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) Date: Tue, 5 Jul 2022 17:30:36 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 5ec493cd-7928-4c9a-5bf6-08da5ea3ba1d X-MS-TrafficTypeDiagnostic: HE1PR0801MB1673:EE_|VE1EUR03FT003:EE_|AM0PR08MB5284:EE_ 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: 6OTUFCVlsyvmSButAzkgCPVIcCp5+Q7ayJyczcuy3aoOF23k33DuoMEM5wrU6nh/HNwtk1/zO99hPMeeW6D6CzF4JFgnTmGkPxEOzFIP+clOLgM60qdppkfsKo24ZDioG2OJ9SI62fJk+P9BhIbaaGUrErTP3av3vKz1+NWobnzVXDXpYlTUqHvZdne2q0L09LtK8wm99H77aEE0Pz+Go1pvWQN1D8caLAs29H6Fg+eTvNTUtTeew6bS+/3fXLC7lydXcMXgQmbbLb5bFYaU0KqR25P0+jH8WxZBDdmUSgpDjEd/sv1cPf+Ugvv8y37kp+gM98j+niFabvV0Hhy8QceZRz+n35+621fSKwgijHI7j7dNevx6QtCgejoplNBJCHKxjXBy7n7C26iS7a+hbtKkacZD5wC8Gv/gMkpCdxzyMDXNAhVjo6EWSIh1u7ty6aY8Z1DtY44pRDouHtzeAiczx6t6XgIjhslLMGM5EwDXCP6TfaSw4WlMagynMhjg96DgcJC6vU0NvkcaWiPK5nHFVpskOg1ydJ62FFgn6b4jdjqsz6tV9q7HpVw5c7YAn921LMFb0JJWJbEuqBO++hcgT8Ja8O6nhlXaMxg5jVfjfV/bHh87vf/VU4CVL/xyOs3a3BNoiWOjNwrbA3FGxX5YcIOADS62H7qNrxv31K7Szmk/6Jhie6ZBn69sXR0GovnYLx7P2QoM58AKl2R/HXLFQF+L0jEJXXAtsSkM3Hrc+wghg2Mc/5zftwLF8Mhx62MZcTrunGAWjNG/LSXRsBXZKiCpp9conc61IrZSUZKxTiDBNHgbTU3QJEuhwmLJfapWfnUd48TebJ8Z91gptZTdiuKNHqz77kEA9awjLFnw+rd8dKsrrHJ9jed6xdly 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:(13230016)(4636009)(376002)(396003)(136003)(39860400002)(346002)(36840700001)(46966006)(40470700004)(36860700001)(41300700001)(2616005)(40480700001)(82310400005)(36756003)(316002)(19627235002)(53546011)(2906002)(8936002)(70586007)(70206006)(8676002)(86362001)(478600001)(4326008)(426003)(186003)(83380400001)(336012)(47076005)(356005)(82740400003)(26005)(81166007)(40460700003)(6862004)(5660300002)(36900700001)(357404004); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1673 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT003.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8c0b5dde-2ea9-4e03-a3d7-08da5ea3b195 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y3MayzUeAf95Rp8sZs8G805bpFERVgYkEDE+6Tesx4BuT33iR4A5JbRT1JjFmhxB3v3htNc5zB6ofiYeu0bOEihgrqhEveZnzkRf1Jlp5m9E4ej4W2yZwVt7qh4xdxtPRPHTVYW/GEOr1DBFv9VioBKqsiftLGWaxJYjwnyRkPbRKJGlXyPKthxlHaM1JKohWTf7rZWdIdJLsCztoMfx3VwMFqjyUWfC39PZmnEQHce2Ovtpy3PhUP/M/1dEK2I14i+1MZPPkF6xIriNExLoJbuAtxTtNRU0up+lwz3uFMYcASyPpwB0dxFcVEowBSQH6hz9biW4iJvrioK0PbQPHkNpP83LnkkOcR7e5W4uOt/WOQOt3us0fNnXzbqwluvkHfQhxDtQ/+K/UuyHImA58UxvTvYH4t9OVS7tLBHgeS6Gel2qiuY8ChNi6prrWHkoGBifX8XLFo2P3xN7XCvNaeSnWWPjN+pLNQydZxGq15OlK0jAslkDHZ4NJg1TiZf8+XFApJVidiN9asdAQx65vtsUgyH9SUbRyq60rE8u65LXHUXazeSgRpYjJffKvjXYZhSs5lMvoeeXfL+HR+xFnuqiMEBDJJ5hhpue8MrGM5/awKLBYbUs+0HC4s4M5erNh0SLvXUYwv2i+p2yY6VpO/GrhYYpkdfWS6GzrjDiLo6cD46If5Qw/15/L0wE8K4FJKXtdvcxL1Ck/2YoIyKNYN4cXz1njXFodw+vgGo2A4cYG5pnQ+1j9JvQDThuGV4IilaXG3Z/I6sB30T/K4haVQ9hr3V27d8kixXoHT/WDD0pReIqGge8Jao2AFyQulhhFSmy7lhBS4SD6W8Rn8InMG1R7YaXV9IXRDUFsJWvyZQ= 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:(13230016)(4636009)(376002)(396003)(346002)(136003)(39860400002)(40470700004)(46966006)(36840700001)(40460700003)(426003)(186003)(82740400003)(82310400005)(81166007)(83380400001)(336012)(40480700001)(47076005)(41300700001)(36860700001)(26005)(53546011)(316002)(478600001)(19627235002)(4326008)(8936002)(70586007)(36756003)(8676002)(2616005)(6862004)(86362001)(2906002)(5660300002)(70206006)(357404004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2022 16:30:52.0060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5ec493cd-7928-4c9a-5bf6-08da5ea3ba1d 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: VE1EUR03FT003.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5284 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2022 16:31:01 -0000 Richard Earnshaw writes: > On 05/07/2022 14:58, Victor Do Nascimento wrote: >> Add function prologue/epilogue to conditionally add BTI landing pads >> and/or PAC code generation & authentication instructions depending on >> compilation flags. >> This patch enables PACBTI for all relevant variants of strlen: >> * Newlib for armv8.1-m.main+pacbti >> * Newlib for armv8.1-m.main+pacbti+mve >> * Newlib-nano >> --- >> newlib/libc/machine/arm/strlen-armv7.S | 52 ++++++++++++++++++++-- >> newlib/libc/machine/arm/strlen-stub.c | 9 ++++ >> newlib/libc/machine/arm/strlen-thumb2-Os.S | 13 ++++-- >> 3 files changed, 67 insertions(+), 7 deletions(-) >> diff --git a/newlib/libc/machine/arm/strlen-armv7.S >> b/newlib/libc/machine/arm/strlen-armv7.S >> index f3dda0d60..18c8226d0 100644 >> --- a/newlib/libc/machine/arm/strlen-armv7.S >> +++ b/newlib/libc/machine/arm/strlen-armv7.S >> @@ -59,6 +59,7 @@ >> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ >> #include "acle-compat.h" >> +#include "pacbti.h" >> .macro def_fn f p2align=0 >> .text >> @@ -77,7 +78,9 @@ >> #endif >> /* This code requires Thumb. */ >> -#if __ARM_ARCH_PROFILE == 'M' >> +#if __ARM_ARCH_8M_MAIN__ > > These GCC architecture macros (those that end with '__') aren't portable and are > essentially deprecated. What exactly are you trying to achieve here? It was my attempt at circumventing the .arch directives below. As these older architecture lack the support for PACBTI instructions, if we don't prevent the selection of the wrong target architecture, when said instructions are encountered they cause Newlib compilation to fail. In particular, I needed to distinguish between armv7e-m and armv8.1-m.main and chose the __ARM_ARCH_8M_MAIN__ macro out of the output from using the -dM GCC preprocessor flag. Will fix. >> + /* keep config inherited from -march= */ >> +#elif __ARM_ARCH_PROFILE == 'M' >> .arch armv7e-m >> #else >> .arch armv6t2 >> @@ -100,8 +103,34 @@ >> #define tmp2 r5 >> def_fn strlen p2align=6 >> + .fnstart >> + .cfi_startproc >> + /* common pacbti_prologue macro from pacbti.h not used. >> + handwritten prologue saves one push instruction. */ >> +#if __ARM_FEATURE_PAC_DEFAULT >> +#if __ARM_FEATURE_BTI_DEFAULT >> + pacbti ip, lr, sp >> +#else >> + pac ip, lr, sp >> +#endif /* __ARM_FEATURE_BTI_DEFAULT */ >> + push {r4, r5, ip} >> + .save {r4, r5, ra_auth_code} >> + .cfi_def_cfa_offset 12 >> + .cfi_offset 143, -4 >> + .cfi_offset 5, -8 >> + .cfi_offset 4, -12 >> + >> +#else >> +#if __ARM_FEATURE_BTI_DEFAULT >> + bti >> +#endif /* __ARM_FEATURE_BTI_DEFAULT */ >> + push {r4, r5} >> + .save {r4, r5} >> + .cfi_def_cfa_offset 8 >> + .cfi_offset 5, -4 >> + .cfi_offset 4, -8 >> +#endif /* __ARM_FEATURE_PAC_DEFAULT */ >> pld [srcin, #0] >> - strd r4, r5, [sp, #-8]! >> bic src, srcin, #7 >> mvn const_m1, #0 >> ands tmp1, srcin, #7 /* (8 - bytes) to alignment. */ >> @@ -159,9 +188,22 @@ def_fn strlen p2align=6 >> rev data1a, data1a >> #endif >> clz data1a, data1a >> - ldrd r4, r5, [sp], #8 >> add result, result, data1a, lsr #3 /* Bits -> Bytes. */ >> - bx lr >> +#if __ARM_FEATURE_PAC_DEFAULT >> + pop {r4, r5, ip} >> + .cfi_restore 4 >> + .cfi_restore 5 >> + .cfi_restore 143 >> + .cfi_def_cfa_offset 0 >> + aut ip, lr, sp >> +#else >> + ldrd r4, r5, [sp], #8 >> + .cfi_restore 4 >> + .cfi_restore 5 >> + .cfi_def_cfa_offset 0 >> +#endif /* __ARM_FEATURE_PAC_DEFAULT */ >> + bx lr >> + >> .Lmisaligned8: >> ldrd data1a, data1b, [src] >> @@ -177,4 +219,6 @@ def_fn strlen p2align=6 >> movne data1a, const_m1 >> mov const_0, #0 >> b .Lstart_realigned >> + .cfi_endproc >> + .fnend >> .size strlen, . - strlen >> diff --git a/newlib/libc/machine/arm/strlen-stub.c b/newlib/libc/machine/arm/strlen-stub.c >> index fc2daf16f..4a0bb8cbb 100644 >> --- a/newlib/libc/machine/arm/strlen-stub.c >> +++ b/newlib/libc/machine/arm/strlen-stub.c >> @@ -58,6 +58,11 @@ strlen (const char* str) >> "data .req r3\n\t" >> "addr .req r1\n\t" >> +#ifdef __ARM_FEATURE_PAC_DEFAULT >> + "pac ip, lr, sp\n\t" >> + "str ip, [sp, #-4]!\n\t" >> +#endif >> + >> #ifdef _ISA_ARM_7 >> "pld [r0]\n\t" >> #endif >> @@ -167,6 +172,10 @@ strlen (const char* str) >> "it ne\n\t" >> "addne len, len, #1\n\t" >> # endif >> +#endif >> +#ifdef __ARM_FEATURE_PAC_DEFAULT >> + "ldr ip, [sp], #4\n\t" >> + "aut ip, lr, sp\n\t" >> #endif >> "bx lr\n\t"); >> } >> diff --git a/newlib/libc/machine/arm/strlen-thumb2-Os.S b/newlib/libc/machine/arm/strlen-thumb2-Os.S >> index 961f41a0a..823b0310e 100644 >> --- a/newlib/libc/machine/arm/strlen-thumb2-Os.S >> +++ b/newlib/libc/machine/arm/strlen-thumb2-Os.S >> @@ -25,6 +25,7 @@ >> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ >> #include "acle-compat.h" >> +#include "pacbti.h" >> .macro def_fn f p2align=0 >> .text >> @@ -33,8 +34,9 @@ >> .type \f, %function >> \f: >> .endm >> - >> -#if __ARM_ARCH_ISA_THUMB >= 2 && __ARM_ARCH >= 7 >> +#if __ARM_ARCH_8M_MAIN__ >> + /* keep config inherited from -march= */ >> +#elif __ARM_ARCH_ISA_THUMB >= 2 && __ARM_ARCH >= 7 >> .arch armv7 >> #else >> .arch armv6t2 >> @@ -44,11 +46,16 @@ >> .syntax unified >> def_fn strlen p2align=1 >> + .fnstart >> + .cfi_startproc >> + pacbti_prologue >> mov r3, r0 >> 1: ldrb.w r2, [r3], #1 >> cmp r2, #0 >> bne 1b >> subs r0, r3, r0 >> subs r0, #1 >> - bx lr >> + pacbti_epilogue >> + .cfi_endproc >> + .fnend >> .size strlen, . - strlen