From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00053.outbound.protection.outlook.com [40.107.0.53]) by sourceware.org (Postfix) with ESMTPS id DA9583858D28 for ; Fri, 12 Aug 2022 15:29:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DA9583858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=CgcuLugntCmz9Oh63T8hDPOYhjfXVHJoFAdKrYxjAwHnd0Y3QWdUIEFwNvbQFiTH12Wg6EAhdeh+L4XNDWtkKQxyzpzALvMPKU10S6s50Ct/j9hl24nL2G/IrPQjeiyA8aNASVhVVQZ6AdDTva3ZGPbYnlhmu6iiasI1fXIofTG2m5vHSB3Bgp6iPaYyRsUp+5+MXATKraBn4Gj9tlvkoITE29vQZoA6edFjbr2SQGtNnQTf9QWifycwyLLqm5mt3xKGGkn+uVLDM8Lv1ASAyRPTRIWrCROWE1jGR39svWqTzHtyHeQYhzmPfCcSVA4b7f2jQW//Y86pKsBwAjuheA== 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=Szqw6UnlTqZEJ2ub4pJR60dIwhCtge0uvV/pPH0NWLU=; b=eMfqR2QwN4toPR9Fp8vIZIh94e2iiS/i5FHWIQu5yMdafbNgfB8jTBJqvk+OUIMNi9SLRg7qoxZQAJ5Add4wehqPb4MUjLHVgyTvTMK7y9PyN739q1aPt85MY24Lxf3/lwAin2wAOf8xJBn1pNqK1Vhk61nQ+G/ju3jDj4ZKkWpOcOl8EE8lE+OyHp/68AmR4km3Y90v2i5R/InyeGNtMU+QVC7ln8V1Z4/kKHuirjFA7KxalIIrcPxFEg26m2PP3PjevsJisu60wn035NXV7qmawGQv7j2KLZrtc/faiczach3gkz74oZIhrQ2VU+u1y7t+hLC4WiR/WIo5kydiDQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.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 AS9PR06CA0295.eurprd06.prod.outlook.com (2603:10a6:20b:45a::12) by DB6PR0801MB1942.eurprd08.prod.outlook.com (2603:10a6:4:75::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.17; Fri, 12 Aug 2022 15:29:21 +0000 Received: from AM7EUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45a:cafe::20) by AS9PR06CA0295.outlook.office365.com (2603:10a6:20b:45a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.12 via Frontend Transport; Fri, 12 Aug 2022 15:29:21 +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 AM7EUR03FT043.mail.protection.outlook.com (100.127.140.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11 via Frontend Transport; Fri, 12 Aug 2022 15:29:21 +0000 Received: ("Tessian outbound fa99bf31ee7d:v123"); Fri, 12 Aug 2022 15:29:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d2d80713bfe437ce X-CR-MTA-TID: 64aa7808 Received: from 9adf1ac45115.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9143BA28-3483-41BA-A114-D10570D5AB08.1; Fri, 12 Aug 2022 15:29:14 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9adf1ac45115.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:29:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WA4/8XNBblyMBeH00c0nN+XeKIBWjgoGFOXLonNWDWwWK/TFaFaU/oMajORFyfvtSqqg0JxvPMPwd5wOKsLcUh9jcDKyHUjOO0aI4dCE6HkwHnIPCRPcVqcCm+nrK4NPMf5Zo0FRBSjd6v2GyPWUNedlqJ5k9Fvixfo9m+qV9VE/XrUqw5Medo1l7LxyTuklKIbEmWdDXTt/AkbLmZ3obb2YP7HEIUBdWJswkhm55yMeKz1cRAxHUVqVOKbo4HdTez99AYc2bAKQlnpDl6nq8vwkwlqz8CkG12pb/WP0tRkajXIZy2VZMCsX3jIL3hMM2m6PlEbljLwGGCTXCQ908g== 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=Szqw6UnlTqZEJ2ub4pJR60dIwhCtge0uvV/pPH0NWLU=; b=WfKJVw+bU5dHsXoM8at8vQs6Vc423JkylkOeCinrhQNIctIZF3M8QB0KMvyumASq9WnIpuFfGTFNdPB0IMRoMmlejzk2PMrvftCSNu5C/J3gNnuhjl8ucbPreezpF2a9rpc+Qvdfj/XEWpULZy8Lh5cqQT65HlECN2bhxYVwuQahsHiAjMbMJc88x80Tb0J9syILvgTvll4AxgkeVZJ+KI0GFaKxV/+Mbh35/Bsjvu8pe1CzuRPsn5GHwbK+U29scLcXbjH9Mk6tFs2I10SBOf+vl3EqHSiatQVf5q1VQQ5tJPzJhLUGPpaAeXwYWn1Vh+iAALTU59hyxCza+zUwAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=gcc.gnu.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 AS9PR04CA0116.eurprd04.prod.outlook.com (2603:10a6:20b:531::17) by DB7PR08MB3676.eurprd08.prod.outlook.com (2603:10a6:10:4d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Fri, 12 Aug 2022 15:27:01 +0000 Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:531:cafe::7f) by AS9PR04CA0116.outlook.office365.com (2603:10a6:20b:531::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.14 via Frontend Transport; Fri, 12 Aug 2022 15:27:01 +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 VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5525.11 via Frontend Transport; Fri, 12 Aug 2022 15:27:00 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2507.9; Fri, 12 Aug 2022 15:26:37 +0000 Received: from e124257 (10.34.105.24) 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; Fri, 12 Aug 2022 15:26:37 +0000 From: Andrea Corallo To: Andrea Corallo via Gcc-patches CC: Richard Earnshaw , nd Subject: [PATCH 5/15] arm: Implement target feature macros for PACBTI References: Date: Fri, 12 Aug 2022 17:26:37 +0200 In-Reply-To: (Andrea Corallo via Gcc-patches's message of "Fri, 12 Aug 2022 16:26:49 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 2ca6f592-d93e-46da-fe2a-08da7c776dec X-MS-TrafficTypeDiagnostic: DB7PR08MB3676:EE_|AM7EUR03FT043:EE_|DB6PR0801MB1942: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: +n4CNADLjZnJmsEOrlVS4qtZjFvimojPzmlUF9d1tCfWo+9Jplx+KuHd8k4ZXVAi2cQJxMqUozHG7Hrh6xATPe/5b4Iq+gURb8FaSKWOONBpeof6f1BVzlTwY6fl28WJJ6KFP/BHNe1lUnXzJA/2x+ztaJQgZ/A0qngjsYh810e9UEF1uD6a1Ea0PRdiuufxfKlDvZNngLrSHpsixxXyYnmrh4TM7ZGcQyOkdOTMeVtHvvdXw/gT+eRrPeHAeSNGrP7xpXppxQNWyXRy3iozNY5eMOpJirig69EFNIN0+MXGx+NVsaq2GiUZt0zTPqnnlEJXF21QwRQzTknb26DD2Ox9GGkTo3xoe5+5gvuVoXElZrMAkuDVT2TDIrtuHRN08hDZa9taHyoC+Y9hLSCyuKh4VLKRmrSEFmYIB6el6qjNFNyDXEHR6LbcPCFXIulgr+jGz7aq5MlDPLcBmSm5jlthfcBxPl7O/0ASrZpaDJI2fcJ5CWddL57ch7ERrmZzlqlg2+/4gHhufVkW2cSlqudou8kYG0xtXY+5e0kXZ+Uov9y0c8MXeAJcu/p0Mz53uGqkS7+BgGI4uLEHpuecR/AoBBtcedUE3yjg1m6zhVGSNtZS5IZaNUr3FS9hyEOvA97dRvwzxk3TjOYH6rFolDYxmXcRZmNcPaFuFYstPYjB9qJ7SnY8yQJH/ZkfkayeTinR8Om7EBE+nBjqBA+vbCXIwsYkrVL2odp4DTcndOI/PB0Vr4FpbMvDxi5SelnQDxb29Ikqet4fW/ewEev8mBjviX1T8HYsCOZETCdElz86F1lp0+bBoUuezyqUWbogmP3Dk3FI+uv8Iq0Xji8eiJweNBzEHx04UE9XyXhoykxaOCCTItyxohi6osELviVE 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)(46966006)(40470700004)(36840700001)(26005)(186003)(4326008)(8676002)(33964004)(2906002)(70586007)(70206006)(83380400001)(36756003)(47076005)(336012)(426003)(2616005)(5660300002)(235185007)(36860700001)(498600001)(8936002)(44832011)(84970400001)(40460700003)(82310400005)(86362001)(6916009)(54906003)(356005)(81166007)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: k+WiYrHobZ2dsOWPQypfDIQcWdum0GBMaf2qZeuZlp60H4tiveHrzujbV8iqPeal5Qhig9BfQJDvCIGeNdiEcu2zZnUP3S4J9LwQ7xwOkAuDqJRWzUhbK7z5Yk+9lKgd/wY6TdN6E2n0bnyuE0CYNteEfbjRuakSHfgfgNSEChYY/RLhSDtGFKNL9Z2Rfnj6s8bX+D8Aow7GkUtzlv7Ag7w1nb3K03qsEgQydxROGi7y1VW5GM1lcdwAl0EG6+Uac2hhKf3JWyhwvW7JR252Onc+rQsOXuWtYrkIEv+SwY+qtwpjZjv/rdHU2EhRuFiPOd7UTnKw11AA0X1OOhubNe8DTcNv89ny3qnrfIFNQkuRPs9U6r/6H++nfB+ODey8paBvn5JO5QU4WGgVqyi9RxNbI0/dAxRa5nMcOZpflnuU17N3l+uNgUTe0eBojKcRttpz04yrjeFbzByePnLdYKNIq5PZN3PcU3bFee/ixaS1eOs+DLLEl7K9jlEKaobFqAY8mxQnPWy9pc3Q4qml9k+AbVOnwH4hJ6vjG8dyRkzWjTG6oAPdROHzx211J7BOO1PVjdNzp/9W/FYdjm5VRUQp6ysipIiMEdiU6DCUzflc5DUhNbkViNc5yLw8ea/FwJQZIO8wEUESxxLKNQKeW7zXrjgYg7OYiJw70abyOkOSltLyS3tYsVZFUvX3SiPTeBkXoc0bgJwoMifDotESEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3676 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7fece05f-ba47-4072-7d0f-08da7c771a4e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gAfgIUWaf4LZz11w51qRvGBKW07QH+zMAPZpeQ9Hh4GL4Oqm1StHY4uMOr5cUh1fqowxv1YXUk3mPZG/jpqeBVUT2bBvCgO8oG/OhoGa7rtsxQE70ZwouAR+nkbDWOa/1u7l8mG763G5qgMkLbaPuTZ5Notem4XVObZLRaSaE1CPUAJ0eBc8wBNjJPI6doOxVm9FwzlFS+/CHCFibn6rhtI8B1b97+VGTeqoVWCLRGb5kKibfW9LCKA1mPr3HJouUBV1eC9vsu8b7asvET1zbNhNdLIaS6+TnWLed1bFBX+MLn+j63Pmy851SzgZcgNyK1IwOPwnpCOYwSO3lbVI7ZI9SQVYlFG62KMkSNxNhekMWZ6Md4mpGjD+dk9jKBa3ZAwRxzIjIVspy3/Bdz8T1liojafar7VZUrag/QjXB/WxwjfG3T6XfYbgUYU3g9eXHs2j49R5P3y4rVvqzM68Sv1G3Ib+Yq3nUS9T2drqTpxdUXSMpvt1IlJMIgnZt93SribRktN7bwx0MzbXDvmBnhI8+WmkIDS2nTS3LRKjRVKdi4ifXFT0yO+nzGCPMLP02hVqCZLFiHRuiImQN6EubPaglTioUMBizkH548OuLjntkmKHk1zclH8x6PuCC9bBNul+1ddQkwU4603S3KDVWl3ka94CJJ+7/tO+tahusoxIMBRZpMSPKbkofdk+WhHr+tICc4fskrcfY8Qr6tZ3jDxYtIY6P8XGhczAkG//PWVVtpXctRucbDHQsFiLgd0EWBYCQ01pZHnZZw5RMw0K1g0VgeUf22lCXCMpFUtDDpx7ljVUsTXVouLK2Ct+pRhVjlNXPcXU1k041sbt9OVIdL8kH+t4M4aD65jg5tjZBx2YP4l3HAq4v9qB664yVWOx 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)(136003)(346002)(39860400002)(396003)(36840700001)(46966006)(40470700004)(81166007)(47076005)(26005)(82740400003)(426003)(336012)(2616005)(41300700001)(33964004)(235185007)(82310400005)(40480700001)(186003)(40460700003)(86362001)(478600001)(84970400001)(4326008)(6916009)(8676002)(5660300002)(316002)(70206006)(54906003)(70586007)(36860700001)(36756003)(83380400001)(2906002)(8936002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:29:21.2609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ca6f592-d93e-46da-fe2a-08da7c776dec 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: AM7EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1942 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2022 15:29:26 -0000 --=-=-= Content-Type: text/plain This patch implements target feature macros when PACBTI is enabled through the -march option or -mbranch-protection. The target feature macros __ARM_FEATURE_PAC_DEFAULT and __ARM_FEATURE_BTI_DEFAULT are specified in ARM ACLE __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI are specified in the pull-request . Approved here . gcc/ * config/arm/arm-c.c (arm_cpu_builtins): Define __ARM_FEATURE_BTI_DEFAULT, __ARM_FEATURE_PAC_DEFAULT, __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_mbranch_protection_ok): New function. * gcc.target/arm/acle/pacbti-m-predef-2.c: New test. * gcc.target/arm/acle/pacbti-m-predef-4.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-5.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-8.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-9.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-10.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-11.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-12.c: Likewise. Co-Authored-By: Tejas Belagod --=-=-= Content-Type: text/plain; charset="utf-8" Content-Disposition: attachment; filename="5-15.patch" diff --git a/gcc/config/arm/arm-c.cc b/gcc/config/arm/arm-c.cc index a8697b8c62f..190099b2c37 100644 --- a/gcc/config/arm/arm-c.cc +++ b/gcc/config/arm/arm-c.cc @@ -212,6 +212,24 @@ arm_cpu_builtins (struct cpp_reader* pfile) def_or_undef_macro (pfile, "__ARM_FEATURE_COMPLEX", TARGET_COMPLEX); def_or_undef_macro (pfile, "__ARM_32BIT_STATE", TARGET_32BIT); + def_or_undef_macro (pfile, "__ARM_FEATURE_PAUTH", TARGET_HAVE_PACBTI); + def_or_undef_macro (pfile, "__ARM_FEATURE_BTI", TARGET_HAVE_PACBTI); + def_or_undef_macro (pfile, "__ARM_FEATURE_BTI_DEFAULT", + aarch_enable_bti == 1); + + cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT"); + if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE) + { + unsigned int pac = 1; + + gcc_assert (aarch_ra_sign_key == AARCH_KEY_A); + + if (aarch_ra_sign_scope == AARCH_FUNCTION_ALL) + pac |= 0x4; + + builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", pac); + } + cpp_undef (pfile, "__ARM_FEATURE_MVE"); if (TARGET_HAVE_MVE && TARGET_HAVE_MVE_FLOAT) { diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c new file mode 100644 index 00000000000..52d18238109 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options "-march=armv8.1-m.main+fp -mbranch-protection=bti+pac-ret -mfloat-abi=hard" } */ + +#if (__ARM_FEATURE_BTI_DEFAULT != 1) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c new file mode 100644 index 00000000000..9f2711097ac --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" "-mfloat-abi=*" } } */ +/* { dg-options "-march=armv8.1-m.main+pacbti" } */ + +#if (__ARM_FEATURE_BTI != 1) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." +#endif + +#if (__ARM_FEATURE_PAUTH != 1) +#error "Feature test macro __ARM_FEATURE__PAUTH should be defined to 1." +#endif diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c new file mode 100644 index 00000000000..db40b17c3b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-options "-march=armv8-m.main+fp -mfloat-abi=softfp" } */ + +#if defined (__ARM_FEATURE_BTI) +#error "Feature test macro __ARM_FEATURE_BTI should not be defined." +#endif + +#if defined (__ARM_FEATURE_PAUTH) +#error "Feature test macro __ARM_FEATURE_PAUTH should not be defined." +#endif diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c new file mode 100644 index 00000000000..cd418ce0c7f --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=bti+pac-ret+leaf -mthumb -mfloat-abi=hard" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 1) + __builtin_abort (); + + if (__ARM_FEATURE_PAC_DEFAULT != 5) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c new file mode 100644 index 00000000000..ce4b45ab464 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard" } */ + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif + +int +main() +{ + if (__ARM_FEATURE_PAC_DEFAULT != 1) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c new file mode 100644 index 00000000000..6d48b7c31a5 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-skip-if "do not override march" { *-*-* } { "-march=*" } { "-march=armv8.1-m.main" } } */ +/* { dg-additional-options "-march=armv8.1-m.main -mbranch-protection=bti+pac-ret" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 1) + __builtin_abort (); + + if (__ARM_FEATURE_PAC_DEFAULT != 1) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c new file mode 100644 index 00000000000..3538c186397 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options "-march=armv8.1-m.main+fp -mbranch-protection=bti+pac-ret+leaf -mfloat-abi=hard" } */ + +#if (__ARM_FEATURE_BTI_DEFAULT != 1) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." +#endif + +#if (__ARM_FEATURE_PAC_DEFAULT != 5) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined to 5." +#endif + diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c new file mode 100644 index 00000000000..27c1c8f521c --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options "-march=armv8.1-m.main+fp -mbranch-protection=pac-ret -mfloat-abi=hard" } */ + +#if (__ARM_FEATURE_PAC_DEFAULT != 1) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined to 1." +#endif + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index aa828bd3a07..c98cb1c8303 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -5090,6 +5090,16 @@ proc check_effective_target_arm_cmse_clear_ok {} { } "-mcmse"]; } +# Return 1 if this is an ARM target supporting +# -mbranch-protection=standard, 0 otherwise. + +proc check_effective_target_mbranch_protection_ok {} { + + return [check_no_compiler_messages mbranch_protection_ok object { + int main (void) { return 0; } + } "-mbranch-protection=standard"] +} + # Return 1 if the target supports executing PACBTI instructions, 0 # otherwise. --=-=-=--