From patchwork Thu Oct 28 11:43:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46743 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 57A993857C47 for ; Thu, 28 Oct 2021 11:46:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57A993857C47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635421603; bh=8SNuJv21i5wQKDw9w2oGee3gGA4hvTU3o0BHbjRSjV0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OZSeNvgrPcbxJ2wTf5hDeY21MEiqBVW0GWp0IGteWViu5cBYKAagWyrPz3ZKt8fEg QMKyy9t8KZqLbQgGnNUycoaoWeDDdW6mxViSZm+ynIQdccJ/CCb+W4Dq63xeQ6aRJ0 SUxHR20DjDLf1aYjlgZU36UtCq2RmILx+k2/FFEA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140082.outbound.protection.outlook.com [40.107.14.82]) by sourceware.org (Postfix) with ESMTPS id 4822C3857C4C for ; Thu, 28 Oct 2021 11:43:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4822C3857C4C Received: from AM6P195CA0101.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::42) by AM0PR08MB3953.eurprd08.prod.outlook.com (2603:10a6:208:125::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13; Thu, 28 Oct 2021 11:43:10 +0000 Received: from AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:86:cafe::da) by AM6P195CA0101.outlook.office365.com (2603:10a6:209:86::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Thu, 28 Oct 2021 11:43:10 +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 AM5EUR03FT032.mail.protection.outlook.com (10.152.16.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Thu, 28 Oct 2021 11:43:09 +0000 Received: ("Tessian outbound 2bb1f94ba47e:v108"); Thu, 28 Oct 2021 11:43:08 +0000 X-CR-MTA-TID: 64aa7808 Received: from 6c292bccfe16.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 77C3E1F9-8D3A-4D32-8A21-F69A1F0FBF93.1; Thu, 28 Oct 2021 11:43:02 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6c292bccfe16.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Oct 2021 11:43:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HAf2oipFMjm5pC5hsgtUTuIuvUqIFbj66LcSq9KiW8TDpvkLkeKkVXYhRCGW4NlkcAg1wiZ35uH2T2AvxXRTW9Zb2eUGztESv3c1zCMhkedR2c1aJAJTDf97MQI2fjWgdWm3lakpkVEIii+QbhUdMCfxPwHn81u+AQ7/OjjhDmJ6tPcEY+Xjx7scqZZ9//e9lIMVgZM1oIH1oYC86T4bszFwN0EvDfrbU16kIK0YZjJ0dc74V8n3nBH83DFo0MqSrz3piCcorzBG+q+zgfkZVSntTuITfd3hCRLOoi1UklbILSA/AeS0shMCqQtJQqDzAOyccEozQVrh43tgU/BK+g== 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=8SNuJv21i5wQKDw9w2oGee3gGA4hvTU3o0BHbjRSjV0=; b=aPgkcIGSeXC0cxvuzHEeFvSTEpF1mVdrPOMXmZsTOcGBBVTNNRuzGlxvqwN60HQ3TVTQS1xF9Uv8QSY0AoxKOlUSPRsfy5FmTiSATsRDU3SVhzcbX9vc6qZl6r7Rs+fCLIkTTDmyX+RKw5sj6F3mYegYVgTbaY/cPqV0zCleA46WzxtXi5pp3rZbndy3ykHMEOIeJYqiNC1hc5TrXycsF6lEpp4MzpWFlBVxGBTaPExwwLaJxut/IKtVu+S2f8/jeAMVCZgjVap/MckoQHtWA9C6BATFgjRvYhTBccIom7qt27ffHfPUOrIjcxmYceKB0LYqLAMVRAmqyNu184GagQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from PAXPR08MB7075.eurprd08.prod.outlook.com (2603:10a6:102:201::15) by PAXPR08MB7336.eurprd08.prod.outlook.com (2603:10a6:102:223::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16; Thu, 28 Oct 2021 11:43:01 +0000 Received: from PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2]) by PAXPR08MB7075.eurprd08.prod.outlook.com ([fe80::9c7f:ad76:ac66:26f2%9]) with mapi id 15.20.4628.020; Thu, 28 Oct 2021 11:43:01 +0000 To: Richard Earnshaw , "gcc-patches@gcc.gnu.org" Subject: [Patch 5/8, Arm, GCC] Implement target feature macros for PACBTI. [Was RE: [Patch 4/7, Arm. GCC] Implement target feature macros for PACBTI.] Thread-Topic: [Patch 5/8, Arm, GCC] Implement target feature macros for PACBTI. [Was RE: [Patch 4/7, Arm. GCC] Implement target feature macros for PACBTI.] Thread-Index: AdfL7sWjcuVwp8nCRWGxzbTXLqW2Fg== Date: Thu, 28 Oct 2021 11:43:01 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ts-tracking-id: 18AA94D8668CFF40A9A59CCA6B2638BF.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 7e21a914-897a-4a56-562c-08d99a081d48 x-ms-traffictypediagnostic: PAXPR08MB7336:|AM0PR08MB3953: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 4GSnludICW0p9Ix79Vp4SdTHYoaqIIibzBDUult9kX9kl912Fl/sSb0c07LB9qBqb6JQBKcpTE1Jbmw1brVfFj2oouIU0SZ0Qe804iBm/y6Fj4eWOmo0uXBAkeqpOQAxcZNygS3oFYsvoeZ4xzGiTFiPHHqcUGN0xfU+0+G/rdKhS8EJi4nZZA/ldIVX7h+p2tsTKmhnWelowJyjRVWvQWjMwYIo1RWMNyZZ+UO3iB+Mta+gMYSwHzcc65y5IqqtGAi/C2cvBx52LuCCScf1LJqNBFqCbFdROtYa+YmOzh14n6p9jUYP0ls6Zq1S6EnkIbjSpu8xE8gKauxVARXUe86AdMxYuIauUmgDOCQczY9DmYVREwNxj+YtOerqTao42A9vjgZdLgXzqvzoQIqFpVFz4hEfUdlWjhFWRHMpoFktnn+ijFFnuKR/6oW1jr6AbkLOTGt0relguiNubef1F4BvHvDn9CN5bzkqPd+k7GbXwsT+c2LCWQ05e57WQLBiM5XAaot00gh2BB9wHfHzpUEetOK8GtNF5FiaHqZqtdooBQIjA1+ocvO3vP8hRclwPACmjcRKZRcsCYvTrmZ3D3KZqqcYYe50Bibu+bD1EmxHIYqzyQnRRppuVbRR5AvAKOCWR2zb/04f/VXdm//4PESUc6iJ8FFiYn0HIVLajboCh0lPS8nEwjmIqe7U2LcHEhxpD88aJ3YR9SCVWZij1Keh6FmbpdJ3KXHnB2pa0ipnAvJVpREwpYf6XH6Oy9auWN6MvpHRSOP9eVGWZxmkSDNCnITSFkfD8eSA2ipC9XEH7WVkiszqWuQOA0EOTCETFSLebX+CkxtI6zkSbYMtBA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB7075.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(122000001)(508600001)(26005)(38100700002)(8936002)(5660300002)(53546011)(55016002)(71200400001)(4001150100001)(110136005)(52536014)(186003)(38070700005)(316002)(8676002)(9686003)(66946007)(66476007)(66446008)(76116006)(86362001)(33656002)(2906002)(66556008)(99936003)(6506007)(7696005)(83380400001)(64756008); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7336 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 373034f1-b617-41d0-fdca-08d99a08189a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A7EgDvFhEegkBUVEe3b2+r1H9Z0FOLObHaApW8OV0SiHn9PbzF6yg6tGFHdhaQurCWq4LvNDEOK5BMfEeNtAmlVrV9m3FOyBx3FvgXSwVtPFb4AZJYU591+N1uLAx5F2Cf1d2nvmIvd5Cqoa01Osp6NBsIyuFXjTHCEhyQlfwtw7AfQb7LrFxRuVdE/ughHSwr0pzV/G33zncnsh3Q6VK8EETzhqYDInkKhoPW+ex+xuivRtD0JkWFNg7/XwIIWXuLgNgcjxQFJgrr17jUzFFpvDcRHXBXPm/tCy5U+EqZTMHsw4k8e/ZvuyzlZskPRlXDvrqohHfUQ/GbS5ZrzUI2MQ3eNu0ik0gxcXLQun9NMRjHzEYNt9x66bG4AUeLHg7nJY9Ja6LX8iRaWiP4pY3WjEaOtX/Ow7cnCec+l5DsiXKPkglqJG/TA+SXYG9Xa8kQh0vhk2+jBCpbwSpKHj5N/xgt8EcRbfNjGaOzWFI5yIhxzJNEVoUx4RznChNTDlTnQc3A+H1cr+J5mO0ulbRIgHuYeLxr6QoJMjFbABMY4oY8xdpcBHiVBsxZZTnNaRICZV/X7MiHHINJJCbNOF7BoBvo9VYwupbBDIXH8RrBQWgiPF7haIbnzA/79yo7qG9VsFGxa4JTPnsh3IDCMF0jzCVP2FeyIOMjiB+qlSkhC9IeDztLdKBkryqdUBKOih9TV6jKtubDg+twDevxWw0X3MnuhhcHlEC2vTwfKUp+JYcvkDoG8iG1E+kWxgQE/gfde4Q9n0FrfmezYL5QpY06oKwSB1fxvezKC2VSdgpjVfh7+eU9cMOM8+ofW0QGwx3Ch9u+v5CWcEFYdb/fgWmg== 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:(4636009)(46966006)(36840700001)(36860700001)(9686003)(316002)(52536014)(8676002)(82310400003)(7696005)(508600001)(21480400003)(33656002)(8936002)(26005)(83380400001)(70586007)(86362001)(70206006)(235185007)(336012)(356005)(53546011)(33964004)(4001150100001)(81166007)(2906002)(47076005)(6506007)(5660300002)(186003)(55016002)(99936003)(110136005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2021 11:43:09.0597 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e21a914-897a-4a56-562c-08d99a081d48 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: AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3953 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, 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: 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-Patchwork-Original-From: Tejas Belagod via Gcc-patches From: Tejas Belagod Reply-To: Tejas Belagod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" > -----Original Message----- > From: Richard Earnshaw > Sent: Monday, October 11, 2021 2:58 PM > To: Tejas Belagod ; gcc-patches@gcc.gnu.org > Subject: Re: [Patch 4/7, Arm. GCC] Implement target feature macros for > PACBTI. > > On 08/10/2021 13:18, Tejas Belagod via Gcc-patches wrote: > > Hi, > > > > This patch implements target feature macros when PACBTI is enabled > > through the -march option or -mbranch-protection. > > > > Tested on arm-none-eabi. OK for trunk? > > > > 2021-10-04 Tejas Belagod > > > > gcc/ChangeLog: > > > > * config/arm/arm-c.c (arm_cpu_builtins): Define > > __ARM_FEATURE_BTI_DEFAULT and > __ARM_FEATURE_PAC_DEFAULT. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/arm/acle/pacbti-m-predef-2.c: New test. > > * gcc.target/arm/acle/pacbti-m-predef-4.c: New test. > > * gcc.target/arm/acle/pacbti-m-predef-5.c: New test. > > > > I presume the specification for this is ACLE - please say so rather than making > me guess. > Yes, sorry, very poor description on my part. Now fixed - please see patch description below for links to specific ACLE sections. > > + cpp_undef (pfile, "__ARM_FEATURE_BTI_DEFAULT"); > + cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT"); > + if (TARGET_HAVE_PACBTI) > + { > + builtin_define_with_int_value ("__ARM_FEATURE_BTI_DEFAULT", > + arm_enable_pacbti & 0x1); > > My reading of the ACLE specification would suggest this shouldn't be > defined if it would have a value of 0, but that's not what this code > does. I think it would be better to move this outside the > TARGET_HAVE_PACBTI and use the def_or_undef approach. > > + builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", > + arm_enable_pacbti >> 1); > > This one is less clear, could the value ever be zero? I guess exactly > one of a-key and b-key must be defined and each has a separate bit. > Now fixed according to what the arch specifies. For the M-profile, there's only one key which means when -mbranch-protection is invoked, bit 0 is always 1. > + } > + > + > > Not more than one blank line at the end of a block. > > > 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 > > > Given what I've said above, I think you need to also test that > __ARM_FEATURE_BTI_DEFAULT is defined before testing the value (and > emitting #error if it isn't). > Fixed. 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 (https://developer.arm.com/documentation/101028/0012/5--Feature-test-macros?lang=en) __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI are specified in the pull-request (https://github.com/ARM-software/acle/pull/55). 2021-10-25 Tejas Belagod gcc/ChangeLog: * 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/ChangeLog: * gcc.target/arm/acle/pacbti-m-predef-2.c: New test. * gcc.target/arm/acle/pacbti-m-predef-4.c: New test. * gcc.target/arm/acle/pacbti-m-predef-5.c: New test. Tested the following configurations, OK for trunk? -mthumb/-march=armv8.1-m.main+pacbti/-mfloat-abi=soft -marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp mcmodel=small and tiny aarch64-none-linux-gnu native test and bootstrap Thanks, Tejas. diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c index cc7901bca8dc9c5c27ed6afc5bc26afd42689e6d..98d47ad4cc6e88aa7401429a809c555c5aadc15f 100644 --- a/gcc/config/arm/arm-c.c +++ b/gcc/config/arm/arm-c.c @@ -193,6 +193,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-2.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c new file mode 100644 index 0000000000000000000000000000000000000000..4394fd147d7bf468238bd66a24b79bd1338d33aa --- /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 arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=bti+pac-ret+leaf" } */ + +#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 0000000000000000000000000000000000000000..90f0c724b9efe38d3c3a1345d49a9615b853207e --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c @@ -0,0 +1,21 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=pac-ret" } */ + +#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 0000000000000000000000000000000000000000..c865809b8b01db8f8c021501e7d3317b0b8bb0ed --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c @@ -0,0 +1,24 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -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; +}