From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140088.outbound.protection.outlook.com [40.107.14.88]) by sourceware.org (Postfix) with ESMTPS id EC5D7385829C for ; Tue, 5 Jul 2022 13:58:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EC5D7385829C 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=aBLoP/wd6IoTWRvRL1fUQdxd4HAdvKCTdmVBMBjPtx0K5aGsfEK06AOUasB91IfpzmiXFM4MJF72Y+OPY+dyIa34EjWdqJO+1l4ztNhRKD3ScOJMzTIqcH+dPc+oAZuFluylQitaTXS8vmvSZR+cdWfv7la12vHbjU+6am0k/se9g1Ue0keH8YCMlgkKnHIqofQkJJVADEYeRhyUFFz5Noqu0e3uJVADAJTqHVVpz9rAeAFh+rW1oKoFcRqXVhTHARDtx7CahrHCDGHMWtq+mgEf/ty9F3vn43qMD8AnIS8Dh+g3gVc2d15prCxHG7VFlA9t09IIvPnkjhvsxBjNYg== 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=iNCMz39JPXvBJ/NJu0uOiSOvpcSbYiYx8z3zhKYBZdc=; b=n3qVdqw8jmM0d/U3WWKAYNE2hWJ19ZHMWhzgZNYaSifrV1CNLPScAC0jQx5Bsg+3kZFDhrgON5heoJoCM4I9O2sSfgvG2i8bVkUL3FXoCZ0sqtLW8CT0q9zr4ZavUwGqwrJMa/9tuoGiZ60CwLrEYKE6w3P0F8uki6jzKY+UUDMvtgb386BOPxRUfGyPmOOjCPDdajSlPMOi8pJnD9jeouJZODTFMo0WOcvnTYR4cwfvPtYwKAyRdNhqV1dD5SsPmtXORzEAiO+k1MOM9sTGB00d81qTVBEiy0VHcsNyIfUBiVInEWxz6AER8ySLEyvkkoU/HTbW5CaCl06GjXanWA== 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=iNCMz39JPXvBJ/NJu0uOiSOvpcSbYiYx8z3zhKYBZdc=; b=Pg39oQSHo7kO5m5YdKY+WS+XeOqULWZPIsTn1Ekv13i86dpiI73ViUiS9xgK4ANwpWcK9HO1WAKDgT/afzEHsh1q0FktpcN1U75C59YqqwufRtll+rlrbqYzgDMwHuzNmdEouAGOb2lBw7Dfl1Bn/pTcwxmfpEhtUa+euLGbYG8= Received: from DB6PR07CA0006.eurprd07.prod.outlook.com (2603:10a6:6:2d::16) by AS4PR08MB8069.eurprd08.prod.outlook.com (2603:10a6:20b:588::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.21; Tue, 5 Jul 2022 13:58:39 +0000 Received: from DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2d:cafe::7d) by DB6PR07CA0006.outlook.office365.com (2603:10a6:6:2d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.14 via Frontend Transport; Tue, 5 Jul 2022 13:58:39 +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 DBAEUR03FT012.mail.protection.outlook.com (100.127.142.126) 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:39 +0000 Received: ("Tessian outbound d5fa056a5959:v121"); Tue, 05 Jul 2022 13:58:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3ad9fee251935313 X-CR-MTA-TID: 64aa7808 Received: from 1715b88bdb1d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9537489C-BDF0-4A82-A7F5-9E4637210332.1; Tue, 05 Jul 2022 13:58:32 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1715b88bdb1d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 05 Jul 2022 13:58:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4PYQNQs1n5A88YfWk+B4Mwg9oL7teptOd2VV0MllXUYMD4Ej9r7WnAZN8uP+3jwMTiEd71gvVI3oqOyxSKbtSf6NdCEANV+zn8UOzEqW5i75pvIvA6VhMgOAm4hy9WzoAOVOH5RTl1quT2enmlk0tBWOrI6QNnbR6CLVWTJ/Gr5yUZ3gG0CqQGGZkdQNGOMX/CZ7gE3VyVm+T2o47edn3wo/fH2kiSqVCocIJj3FV1eJKtqK1awWqk8vXgM115pZLwEdLA+fDF9dazsknJ3dlhtjrTD0BpblO1XOZSTbhXrPsXsVqJLNTgDN/h1Ps70mFsNd7WKHaoHgbDK4FI4Ng== 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=iNCMz39JPXvBJ/NJu0uOiSOvpcSbYiYx8z3zhKYBZdc=; b=GCFxtIfOfWCP7Bag9FtReH88Bw7eTiPFXCeQBij12Iiic+grq0sR7Kff7cYS/E0GvzjGi7yQNBKokuGuGPXdm8R4LsCXGtGdJLE9Yje1vDtSgCHWvQ/avtUw80TaAZ6oNjohOwFYEAKBFjMBfEcqHujmfkteT1k2d2TjI/t9YbcsqF8SA9erf70P1vMk5fSx7/JHFRHYlKVaoddfpv3F9NhIKBZK7hpIrk8jrtyOyR6dXPog+wuzh5TDESe+Z/4z3iC2IGSviusMw41gKtqFPnWbUHevKbwhdvGw/PCNDC24FOswgRLPJuIyTkJNv/W4yfTX5HjZtQPxFrjrAqlx1Q== 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=iNCMz39JPXvBJ/NJu0uOiSOvpcSbYiYx8z3zhKYBZdc=; b=Pg39oQSHo7kO5m5YdKY+WS+XeOqULWZPIsTn1Ekv13i86dpiI73ViUiS9xgK4ANwpWcK9HO1WAKDgT/afzEHsh1q0FktpcN1U75C59YqqwufRtll+rlrbqYzgDMwHuzNmdEouAGOb2lBw7Dfl1Bn/pTcwxmfpEhtUa+euLGbYG8= Received: from AS9PR06CA0526.eurprd06.prod.outlook.com (2603:10a6:20b:49d::29) by AM6PR08MB5191.eurprd08.prod.outlook.com (2603:10a6:20b:e6::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.18; Tue, 5 Jul 2022 13:58:30 +0000 Received: from VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:49d:cafe::2d) by AS9PR06CA0526.outlook.office365.com (2603:10a6:20b:49d::29) 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:30 +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:30 +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 2/8] newlib: libc: strcmp M-profile PACBTI-enablement Date: Tue, 5 Jul 2022 14:58:12 +0100 Message-ID: <20220705135818.50088-3-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: 07bcd4f0-3cf1-4616-d577-08da5e8e769c X-MS-TrafficTypeDiagnostic: AM6PR08MB5191:EE_|DBAEUR03FT012:EE_|AS4PR08MB8069: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: bmaMYPwPG80XZJ/gnFVSRQj84qV1ccWlF0ehYXCMoSZrm/30pecxQH2OjWj2IGWEXR1wlmQ2lztkiOvi9IGvTUmVOyaKn4rduj0JGSArvbxwaenP2FbCkZ2Zk7jAyfQ1AVvtgCEtj7fRTV1VCMseQ0ENRY+3z/dsqEJa5V88IqG68e31aFjZ9EHo0mTAeORFFnW5UqE0FxzsA+6604CbmSblYWdht5ufcdgEK+7A261EcBWqugWoY2+YPyVcJCVZzg4AcPpV2cxA9IXoWWqnxfJ/1uTHGip1QWbbtCtfLn2iVrQpu2ul+scQNPw8BXfo+BVIe9I2mE48KFB/jazPpocLa+uotvMS7J3acfXpC58YFJ0Ueoj6iZDGmQVdWusKnHy9bd8v5apKB9Dk72W273K1u0Symrhy30maELuplCW+1hlLLbOwYWGL00jsWJxwdf0D/E32d/f7QMP+evIw6SNDZEj/gboeRTktKwEY3zrzyNi8EG52T5y59PeUOeA3WEfNmvMhcHb4sTQrrRe8mBzVGMA883ogyTVHKzT5g/lJTHj7JFfhqIX00tNM5RgFTE2E7XeNGEwc6eU5KPRqmuMYsok1DDP2CXg/JkKL70cxCAZxjFLgqmNIxRB7sFrWiuRQm/TKp3QfeecAtJiMRqWHr3gWqAM5Nfo6X+V+U8NaDI7FuWkECEkD5s3tBtRWCXI3oRG4jwI6KF1tNUq4E9l3gONSPqXwEOG4Da+71UK4cl+xz1jzawGT1Z3c6/OPJa2gqQOFMSGuah3axINQTUdjLipkv7q7mGmiBMSJBiYgEy5Gp/2momWamBsuEz9/RyPUfyaUXz/ir8IOKSDhWVDnymkvlltylRzMpolIYSbE7VJydHJJGBzIinsc+m1i 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)(396003)(376002)(39860400002)(346002)(136003)(46966006)(40470700004)(36840700001)(36860700001)(40480700001)(7696005)(8936002)(478600001)(5660300002)(81166007)(2906002)(70586007)(41300700001)(356005)(82740400003)(70206006)(6666004)(8676002)(4326008)(82310400005)(36756003)(186003)(6916009)(47076005)(426003)(336012)(26005)(40460700003)(1076003)(86362001)(2616005)(83380400001)(316002)(40753002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5191 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 68ea485b-7354-4039-354f-08da5e8e7124 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F6W+UlJldgtHB+4shP8Y/oVQR0hTOZZFaejs+5eJKxtolBMNB50J3pqtSslYgrB2Ujp+OIr01P8R5ZFm184txwNp5gjUH2eyXklUS9OWrqkXOP/TyB1DYLpqS1+APoIXJyfW5dQb6cN0ppxGHxbsfXpyx2NPxKZ4ey4sd9z2HHP06HJnwsgykIJdfl67rKGTA9IeKo+9gQaMGDI/BG9iY1W2U0Jix6XcP92eJkTIu8oDtuqEK0yOmYF7llXlj3KJ1nXVK+R2DBmZNjUVQfk/Hoy9pfrTfzsZTnY7fd/muAb9+lGDUiVzGrKnMkj9afU5gHfU6QlnoSrrDRnlBQ8olJhzpv/a8/Dka2vN2FTjDGsR5MkOwth+K9b4qe25UwarrH0MBvlXFOmyduKrxqTLYAWPqqjSut9idtd5LAjR5um4PkwijTox9oEVmGNbipmCVDi6f4plKjLb/Yeugq57dVM9hlO44VSbkg1c5Tf2Os8d0VVCS8LwGMcAnecYechxNn+VSmLQzlHd+Dw5NoDoCxtPw+Q82hbJHwUx653MsEmiZ7UYennwRIZgaEJeCO30zfnXDsTqd+4pHmQ+wtF2NTa+ueR2FoNPvfuZjArWyoMZXi3Ir4kU3lvdbWVHDp1C8u6YWWTa9RTkiLIjiApYvXUzz2KCHh6g4T08N1lVKXOM1CkU7ZLLVRzNZXSIpLtGZdTpjr4PCa9m28gmIa0LKb/DSWneALO1Rs3aeB/uSfcp0yoKEdl8S2XTWKqprYgkxv3xqJfgHFylAaOL6v/ExQGcifdFblu141InLNx15bwONK79WugfnjXa8gOH6YoMQ9smjhCaZTTOLD0QYu1pHgRpEmUqHYMNGeVLduQCD80= 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)(36840700001)(40470700004)(46966006)(186003)(2616005)(40480700001)(1076003)(336012)(426003)(47076005)(36756003)(82310400005)(6916009)(316002)(83380400001)(8676002)(4326008)(70206006)(70586007)(7696005)(8936002)(40460700003)(478600001)(5660300002)(82740400003)(86362001)(81166007)(26005)(41300700001)(2906002)(6666004)(36860700001)(40753002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2022 13:58:39.4703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07bcd4f0-3cf1-4616-d577-08da5e8e769c 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: DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB8069 X-Spam-Status: No, score=-2.6 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, UNWANTED_LANGUAGE_BODY 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:44 -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 strcmp: * Newlib for armv8.1-m.main+pacbti * Newlib for armv8.1-m.main+pacbti+mve * Newlib-nano --- newlib/libc/machine/arm/strcmp-arm-tiny.S | 7 +++- newlib/libc/machine/arm/strcmp-armv7.S | 45 +++++++++++++++++------ newlib/libc/machine/arm/strcmp-armv7m.S | 36 +++++++++++++++--- 3 files changed, 71 insertions(+), 17 deletions(-) diff --git a/newlib/libc/machine/arm/strcmp-arm-tiny.S b/newlib/libc/machine/arm/strcmp-arm-tiny.S index 607a41daf..8085eb4df 100644 --- a/newlib/libc/machine/arm/strcmp-arm-tiny.S +++ b/newlib/libc/machine/arm/strcmp-arm-tiny.S @@ -29,10 +29,14 @@ /* Tiny version of strcmp in ARM state. Used only when optimizing for size. Also supports Thumb-2. */ +#include "pacbti.h" + .syntax unified def_fn strcmp + .fnstart .cfi_sections .debug_frame .cfi_startproc + pacbti_prologue 1: ldrb r2, [r0], #1 ldrb r3, [r1], #1 @@ -42,6 +46,7 @@ def_fn strcmp beq 1b 2: subs r0, r2, r3 - bx lr + pacbti_epilogue .cfi_endproc + .fnend .size strcmp, . - strcmp diff --git a/newlib/libc/machine/arm/strcmp-armv7.S b/newlib/libc/machine/arm/strcmp-armv7.S index 2f93bfb73..466db3fc8 100644 --- a/newlib/libc/machine/arm/strcmp-armv7.S +++ b/newlib/libc/machine/arm/strcmp-armv7.S @@ -45,6 +45,8 @@ .thumb .syntax unified +#include "pacbti.h" + /* Parameters and result. */ #define src1 r0 #define src2 r1 @@ -91,8 +93,9 @@ ldrd r4, r5, [sp], #16 .cfi_restore 4 .cfi_restore 5 + .cfi_adjust_cfa_offset -16 sub result, result, r1, lsr #24 - bx lr + pacbti_epilogue #else /* To use the big-endian trick we'd have to reverse all three words. that's slower than this approach. */ @@ -112,22 +115,28 @@ ldrd r4, r5, [sp], #16 .cfi_restore 4 .cfi_restore 5 + .cfi_adjust_cfa_offset -16 sub result, result, r1 - bx lr + pacbti_epilogue #endif .endm + .text .p2align 5 + .fnstart + .cfi_sections .debug_frame + .cfi_startproc .Lstrcmp_start_addr: #ifndef STRCMP_NO_PRECHECK .Lfastpath_exit: sub r0, r2, r3 - bx lr + pacbti_epilogue nop #endif def_fn strcmp + pacbti_prologue #ifndef STRCMP_NO_PRECHECK ldrb r2, [src1] ldrb r3, [src2] @@ -136,16 +145,26 @@ def_fn strcmp cmpcs r2, r3 bne .Lfastpath_exit #endif - .cfi_sections .debug_frame - .cfi_startproc strd r4, r5, [sp, #-16]! - .cfi_def_cfa_offset 16 + .save {r4, r5} + .cfi_adjust_cfa_offset 16 +#ifdef __ARM_FEATURE_PAC_DEFAULT + .cfi_offset 4, -20 + .cfi_offset 5, -16 +#else .cfi_offset 4, -16 .cfi_offset 5, -12 +#endif /* __ARM_FEATURE_PAC_DEFAULT */ orr tmp1, src1, src2 strd r6, r7, [sp, #8] + .save {r6, r7} +#ifdef __ARM_FEATURE_PAC_DEFAULT + .cfi_offset 6, -12 + .cfi_offset 7, -8 +#else .cfi_offset 6, -8 .cfi_offset 7, -4 +#endif /* __ARM_FEATURE_PAC_DEFAULT */ mvn const_m1, #0 lsl r2, tmp1, #29 cbz r2, .Lloop_aligned8 @@ -270,7 +289,6 @@ def_fn strcmp ldr data1, [src1], #4 beq .Laligned_m2 bcs .Laligned_m1 - #ifdef STRCMP_NO_PRECHECK ldrb data2, [src2, #1] uxtb tmp1, data1, ror #BYTE1_OFFSET @@ -314,7 +332,8 @@ def_fn strcmp mov result, tmp1 ldr r4, [sp], #16 .cfi_restore 4 - bx lr + .cfi_adjust_cfa_offset -16 + pacbti_epilogue #ifndef STRCMP_NO_PRECHECK .Laligned_m1: @@ -364,8 +383,9 @@ def_fn strcmp /* R6/7 Not used in this sequence. */ .cfi_restore 6 .cfi_restore 7 + .cfi_adjust_cfa_offset -16 neg result, result - bx lr + pacbti_epilogue 6: .cfi_restore_state @@ -441,7 +461,8 @@ def_fn strcmp /* R6/7 not used in this sequence. */ .cfi_restore 6 .cfi_restore 7 - bx lr + .cfi_adjust_cfa_offset -16 + pacbti_epilogue .Lstrcmp_tail: .cfi_restore_state @@ -463,7 +484,9 @@ def_fn strcmp /* R6/7 not used in this sequence. */ .cfi_restore 6 .cfi_restore 7 + .cfi_adjust_cfa_offset -16 sub result, result, data2, lsr #24 - bx lr + pacbti_epilogue .cfi_endproc + .fnend .size strcmp, . - .Lstrcmp_start_addr diff --git a/newlib/libc/machine/arm/strcmp-armv7m.S b/newlib/libc/machine/arm/strcmp-armv7m.S index cdb4912df..4bbc63ba8 100644 --- a/newlib/libc/machine/arm/strcmp-armv7m.S +++ b/newlib/libc/machine/arm/strcmp-armv7m.S @@ -29,6 +29,8 @@ /* Very similar to the generic code, but uses Thumb2 as implemented in ARMv7-M. */ +#include "pacbti.h" + /* Parameters and result. */ #define src1 r0 #define src2 r1 @@ -44,8 +46,10 @@ .thumb .syntax unified def_fn strcmp + .fnstart .cfi_sections .debug_frame .cfi_startproc + pacbti_prologue eor tmp1, src1, src2 tst tmp1, #3 /* Strings not at same byte offset from a word boundary. */ @@ -106,7 +110,7 @@ def_fn strcmp lsrs result, result, #24 subs result, result, data2 #endif - bx lr + pacbti_epilogue #if 0 @@ -214,12 +218,18 @@ def_fn strcmp cmpcs data1, data2 beq .Lstrcmp_unaligned sub result, data1, data2 - bx lr + pacbti_epilogue 2: stmfd sp!, {r5} - .cfi_def_cfa_offset 4 + .save {r5} + .cfi_adjust_cfa_offset 4 +#ifdef __ARM_FEATURE_PAC_DEFAULT + .cfi_offset 5, -8 /* Account for ip register already on stack */ +#else .cfi_offset 5, -4 +#endif /* __ARM_FEATURE_PAC_DEFAULT */ + ldr data1, [src1], #4 and tmp2, src2, #3 @@ -353,10 +363,17 @@ def_fn strcmp .Lstrcmp_done_equal: mov result, #0 .cfi_remember_state +#ifdef __ARM_FEATURE_PAC_DEFAULT + pop {r5, ip} + .cfi_restore 5 + .cfi_restore 142 + aut ip, lr, sp +#else ldmfd sp!, {r5} .cfi_restore 5 +#endif /* __ARM_FEATURE_PAC_DEFAULT */ .cfi_def_cfa_offset 0 - bx lr + bx lr .Lstrcmp_tail: .cfi_restore_state @@ -370,9 +387,18 @@ def_fn strcmp S2LOEQ data2, data2, #8 beq .Lstrcmp_tail sub result, r2, result +#ifdef __ARM_FEATURE_PAC_DEFAULT + pop {r5, ip} + .cfi_restore 5 + .cfi_restore 142 + .cfi_def_cfa_offset 0 + aut ip, lr, sp +#else ldmfd sp!, {r5} .cfi_restore 5 .cfi_def_cfa_offset 0 - bx lr +#endif /* __ARM_FEATURE_PAC_DEFAULT */ + bx lr .cfi_endproc + .fnend .size strcmp, . - strcmp -- 2.36.1