From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2073.outbound.protection.outlook.com [40.107.20.73]) by sourceware.org (Postfix) with ESMTPS id 12A703858280 for ; Tue, 5 Jul 2022 13:58:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 12A703858280 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=GB/zA7X7I4bUE65Amdnf5+pSmS+6eCE+X+yB+qVG1LlyjdzVjuVZv22cIccBSWeag7UPN9abxLUOpMN/x2c+e2fEQJRDAsSNy77BBzk+BM5vcekUJfi8qE010PWhTIst94/2qC0xNFWFiYnPn8Vq/lP9dPR38ocJAyznN7l2BLTwUaOcWRt9nhE54lskwMhX1pbqRVqQLgjVVuStd9h3xDb0+XELO6dRbk2H2dq/X6XgvefE1IbQNX6+UAmlPJ0knTEvpIX+FWloJrEEGXu1W6ZFnQtvPezp+Y48jAEFxgR6XA3TEL9mOWjptPPokSqT1yCE8gSxeeotXLM83I3xOQ== 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=cigBE/ZZoUjdeEpaXjAfPx6urV8Fqq0GoqB0xCzwWiM=; b=jKdBv5C0p2JBIX0efzcFOEI27paOcxL8G5IA0SOcY4WTAEeNBI0P4hwey00Z5w6tcu+gQlShFkuRWyeEe8kWH/gzLAix8wFGriAQFhQzQSOEG9e3dAsW+0wg2R7VSvj6cVhjKlQAhfjOoHht7tD+ctrv2Ne2FkbTn2t38I4DXsl0ofoaZt5k8N9qPFnVdyqoOQKLipdLT4TZje2tl1462GFsdHJN3eWJp7wwBEzbgyFDt0xwxSYDshmK/NHBXyoxmUpHU8Vctj65vtcxzUOTAYkS/fVquGIfdxwU9q+BXrjaUsvzK9KDRCxUCCJPFzN+daMcevjxFHdQWMlbKcX4hQ== 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=cigBE/ZZoUjdeEpaXjAfPx6urV8Fqq0GoqB0xCzwWiM=; b=UqwCFQT6F9YHBo88HSw7WFtczHz1TpJRCP51nCJu/vjVmTVPOXKJ6+5d1IlbR8PQNQP9vY7pV/Pfz8OroO0PYOWnz9Jd5OuLjNwo0piE4O3VbtFuxhSPpQPds5k6dyzB45G26nnwd9A49LkpD0vzH2uVlwgT7HJqbNMcB8Ul3co= Received: from FR0P281CA0110.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::6) by AS8PR08MB7910.eurprd08.prod.outlook.com (2603:10a6:20b:50b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14; Tue, 5 Jul 2022 13:58:41 +0000 Received: from VE1EUR03FT017.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:a8:cafe::97) by FR0P281CA0110.outlook.office365.com (2603:10a6:d10:a8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.8 via Frontend Transport; Tue, 5 Jul 2022 13:58:41 +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 VE1EUR03FT017.mail.protection.outlook.com (10.152.18.90) 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 13:58:41 +0000 Received: ("Tessian outbound ef501234d194:v121"); Tue, 05 Jul 2022 13:58:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 70278ade7596c25c X-CR-MTA-TID: 64aa7808 Received: from 7b919fab6d4e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A5389FEA-2A13-4427-AD95-16243FDDB274.1; Tue, 05 Jul 2022 13:58:34 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7b919fab6d4e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 05 Jul 2022 13:58:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AaMZ6NLEoXRjwOnL+ya9qB21ItsumL6NmnewTM1GVci8yFFiehytF8H+QawFnwQqkcCQinhf3OAj5aZWslt/R6fRWwpH9WSTeTAQgbYDUP756nQykfXsz7pYjxXrWqV7CJRRvGtHk3IqdkTzTeML8DDvbxkSwSpwqG8G1TaKZLNwjddy+E/YtthKLf6EqWtU4ivT+iUgBrrCVaCfPb2cT1A2YmqibjWL4PC6SNdgEu3kMr/UJq4tzxZC8VI7cCA9rGSiGC9Kzy4lH+f5rLofq5a3JzxhbSgo+CL7IyZzo8heEqxiLWfgGNIzAdJP46NgeKzlgIqqXE7YCzGS35OLYQ== 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=cigBE/ZZoUjdeEpaXjAfPx6urV8Fqq0GoqB0xCzwWiM=; b=QY9XMqb0lBupUqfws4kvyLsoxjJ3VL0QFwObmaGkIQLEmhUSnYGu11otprL50raQzaCsSMt8rDJlDeePNYHaK146zYBh3BuNAq73dyugiltI2VCWDuYm955tUF0MrcpvEDf94187UgI29xfDa4KpYlAfyEiiIcGjb2FaBdeoYPE89dmXWEgcAyhFx8HSnWoEjekAqtW7ZVppCQLXhXS1AY+UMs9kQopTs0LKDZ7+yiVBFCwxuaJLcaPwpV6jg5t/KBdC4EhInwFXFRKdYHjxtcP0+uzIPs5SOw6r8bnpDcVs5nEGOxETXklpbsuCNDIV9oNDBfipTXJEF1U/SRrsog== 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=cigBE/ZZoUjdeEpaXjAfPx6urV8Fqq0GoqB0xCzwWiM=; b=UqwCFQT6F9YHBo88HSw7WFtczHz1TpJRCP51nCJu/vjVmTVPOXKJ6+5d1IlbR8PQNQP9vY7pV/Pfz8OroO0PYOWnz9Jd5OuLjNwo0piE4O3VbtFuxhSPpQPds5k6dyzB45G26nnwd9A49LkpD0vzH2uVlwgT7HJqbNMcB8Ul3co= Received: from AS9PR06CA0523.eurprd06.prod.outlook.com (2603:10a6:20b:49d::24) by AM0PR08MB5234.eurprd08.prod.outlook.com (2603:10a6:208:15c::20) 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 13:58:31 +0000 Received: from VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:49d:cafe::62) by AS9PR06CA0523.outlook.office365.com (2603:10a6:20b:49d::24) 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 13:58:31 +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 VE1EUR03FT009.mail.protection.outlook.com (10.152.18.92) 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 13:58:31 +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 13:58:24 +0000 Received: from e125768.cambridge.arm.com (10.2.78.50) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.9 via Frontend Transport; Tue, 5 Jul 2022 13:58:24 +0000 From: Victor Do Nascimento To: Subject: [PATCH 3/8] newlib: libc: strlen M-profile PACBTI-enablement Date: Tue, 5 Jul 2022 14:58:13 +0100 Message-ID: <20220705135818.50088-4-victor.donascimento@arm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220705135818.50088-1-victor.donascimento@arm.com> References: <20220705135818.50088-1-victor.donascimento@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 55309a4f-5695-49ae-c095-08da5e8e77a1 X-MS-TrafficTypeDiagnostic: AM0PR08MB5234:EE_|VE1EUR03FT017:EE_|AS8PR08MB7910: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: LFprzm2wgLD6pVbmQy33g17r6RqfTuo4ZxwWMJreUCOfz7zoviGG9g6JNJU2Ki3qFTkbD1YGF+7rVV62ZK6Z1l5vw2OHkhbOOVCl17+eLRvbyimbuQKaVMJ8CslRwQSffq5zWFZcxELEfAWsT3wSC5Lxfbtq4qQtmLWNTdw+h+QyJLrE9P5kktdS7YyI4f1gA/S/pxFlhx23/MaxLLtRMZKwSe956NZv4F+w/3+JVEMBDCPVllvcBjISvoqYuW9BT8AFpal2/coAmxbEbZsZa7p7ywRjQF6HEdTmwvygct9y9KEvee8lvIhokhfArFOAHsXXmyOrmvIxM6bVU1yd0jki0xUifGcqkLUnufLMAn+JtGYVnw+zdx8UNy7TwS+t2pk56hyw5yePrzHioZkl3lsW6OrKomYjfK0qQQxkwwesQZGHlteUd3goiuHqwo6xC36DJST/2CLpsh3kE+d8iGdxeDiqlb/1C/yQNLdD9nc8041j++QQKsU7D4KDIuvq8xJvWPKM2YFISiRtrvDDYpMJShd3JrSxh0cBppZNwQrW3cMzT8GkMqsx2otoxSktu8Wl79+eCUWDLxQS1+Qss2xUWhRRu8sbm0h5edmU1oCGakiReAaOQkAKL0QDijivtebbCJZbMaGhWA5znu1oROs/P5JsTCVwEFROx7VWu5DrxCNzx3RBA/YqqsviJiTxSgENN5sqyZLHP3sHllEGZZ0nNY+iekFp9fafxO/t+xfIUiyhuo4A5HSp/2q5YC+WYNK9SNKf2C/gA3jaLjOapW9B60FfZUpdOI8SZbzAstxItOCeZKvVs41Z9tv3NfW3GvuWd25tWfqQL2zWKJgt9jO7zCwr+3KpO58ZOSdyc8x5wlV9fvaImWn6fWdpYOwU 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)(346002)(136003)(396003)(39860400002)(376002)(40470700004)(36840700001)(46966006)(478600001)(7696005)(26005)(6666004)(41300700001)(36860700001)(186003)(2616005)(1076003)(356005)(83380400001)(6916009)(47076005)(336012)(82740400003)(4326008)(426003)(81166007)(70206006)(8676002)(70586007)(82310400005)(2906002)(8936002)(19627235002)(5660300002)(40480700001)(40460700003)(316002)(36756003)(86362001)(36900700001)(357404004); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5234 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 9e986caa-7352-41d7-b6e4-08da5e8e71a9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4Dcw+bZ5b4Z0TV8pcMIYAH+pgSiyG98j+Uth+G1GX3azLsY43VLSnam7uUWRkloQHJMsIiLBiO9rEcZd7THJamJSqxx9scviO1VLlo95Od00dU8jXtHkG6Pxkqxk6MGvPTlmDCmXaWLOtgV5cvX+MYPbMn+0uzeTU5ZXp8mHn7+G9Z18qqlcck/Gwxc+EegO5Y4dJ+y3unk7w7ch5XkfuS4f41MfkVPKREETWNK3Cll0psMwV7hRjwfP+VcslUkyYWcc8WjbVsLz0G/CS8qvn1Kf9kjc0r3d1S/6TaQHA6Z2p5ObYMV0rmnk5tfphuaEcuDMCQPK9Acjk08SMIBsKAMrn1feguCBgaA/pkUqacKRitmKadUVP0SXcImcjP6Gly+5l0V+Ny0iWJ6JR8oDkOKzNvskZfpWCRc9qUqlt11r/mqczXdkl3bMdy7oEi2Pprb8cCHucJ1iWIbQFKuHB2331tGaVQxzbtJezWUHs1B4cnwJUZ3ZmDdmzjNkzqfEOgJoQWu13ZZ0kUN8tEtAlbf/ZTTqC84DLrdP3XPW7AD3RpojoWVqvDP21luoNz3/MPMNctJKbEYvVaJm8B77XQCoYbxQyxunpfKCrqdap0v88Ix8ZL516wQWivat1S1WjAaDH0Jb9zzolxPdXLZdfdJBHYpOgRkr6NNVKFgK3AHeneh6bTl2RDg1Sx8yBmqP0W+xfsDIVbchre2So7gsKCUTF/cFELrggHz82juA7ppuq4mGyzIZFUClqhRf8Y567S1WcgWDAIEMDc8nin0Pn7dZzW+xde/P/5OIFFlKJo+htwiWl/F6dxoeasifTIBVFwIoTnCnKJcGk2E/45iLkkoPf/ZXwjsSJ7k/kp+mt3E= 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)(396003)(346002)(376002)(136003)(39860400002)(46966006)(40470700004)(36840700001)(40480700001)(36756003)(186003)(41300700001)(19627235002)(6916009)(6666004)(2906002)(8936002)(47076005)(7696005)(1076003)(336012)(426003)(82310400005)(2616005)(316002)(83380400001)(70586007)(86362001)(5660300002)(82740400003)(40460700003)(8676002)(26005)(4326008)(70206006)(478600001)(36860700001)(81166007)(357404004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2022 13:58:41.0654 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55309a4f-5695-49ae-c095-08da5e8e77a1 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: VE1EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7910 X-Spam-Status: No, score=-12.8 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 13:58:45 -0000 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__ + /* 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 -- 2.36.1