From patchwork Fri Oct 8 12:18:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 46006 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 ADE543857C63 for ; Fri, 8 Oct 2021 12:24:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADE543857C63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633695849; bh=UvKqwQJdVYFZlNxIg0BmMjrqX0+VemoYKHtZvtalbu0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QbchhLfiXX/bAdx46fkVujpPL/lwA+DJBQGFmq0/VdM/WMRBkN08ok4KGME7/PXx2 4M/WYzp2T8sps9N63nSscWDZCGzdDqFWUkiEubIwSaoJGuhR89KE8anGDMFq9fsokT IUDL0WwIGdFjzBssjd8QmJRy0lk0vWKjuZLW02xI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80043.outbound.protection.outlook.com [40.107.8.43]) by sourceware.org (Postfix) with ESMTPS id 4069F3857C7A for ; Fri, 8 Oct 2021 12:18:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4069F3857C7A Received: from AM6PR04CA0072.eurprd04.prod.outlook.com (2603:10a6:20b:f0::49) by AM8PR08MB6516.eurprd08.prod.outlook.com (2603:10a6:20b:363::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.19; Fri, 8 Oct 2021 12:18:48 +0000 Received: from AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:f0:cafe::a0) by AM6PR04CA0072.outlook.office365.com (2603:10a6:20b:f0::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19 via Frontend Transport; Fri, 8 Oct 2021 12:18:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; 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 AM5EUR03FT015.mail.protection.outlook.com (10.152.16.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Fri, 8 Oct 2021 12:18:48 +0000 Received: ("Tessian outbound 16951d3c485e:v103"); Fri, 08 Oct 2021 12:18:48 +0000 X-CR-MTA-TID: 64aa7808 Received: from 85e5c0e60edd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 381A4FB8-33FE-4720-8134-A93E77AC888A.1; Fri, 08 Oct 2021 12:18:42 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 85e5c0e60edd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 08 Oct 2021 12:18:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mTznaDh2nHqLGSjzJ/lzGKJHISnpilgM8FYGuL6HvFl8lNeOdZrE+cMhvhme6AbKagd6b/bvLwQPqWl9Z2xUdjQyQ+G8XagXX6oX0EZa47I7+e+WgHgXxDV2iu5eVuXVQalO8ztoAroJ2ilkyMmE3askDm5mbbPcaMz3yA/SsQcGDRApnq2Qw1HKeSU6QPkFyfWGz46gLkHNG/hdyqG30mIK8Pd9q274J+QGGoLnprL8B2eH9Qvv8GyLtOO2vNunbGGAVSbA9nxAzPJx1hjQTN1/9ulbAvblf2NkqtCOXk7gccuNzs97cQokaZEIl01r+cChNa6pTJA3sj4VD0eTfg== 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=UvKqwQJdVYFZlNxIg0BmMjrqX0+VemoYKHtZvtalbu0=; b=hzP11EEOs0FU8o03nh6jwtfW6r4FIaRYk/inXuFEN3YBhL2Se+EwTQdYWmZHykneZSMO45rPcyuGgPNVjCPYkUQVvEQnNd3aw1/ptmqJs0Ri41752ADZBa24YRz+VyO/A9Z4RhGyApknCVvW8EpBM0ZdrFxXDCvshx1kq1cSTDmeoL0gb6Te0BV9F+sez8EdakhCGIXKoEAJgQdNkjMLVDZeVwZCZx24QqSjpHujN9ORIdt/bPJuCc2faCpqgHQ7F9ECNt3saUns2aUyYMwbb+udALydlAQThxTi5Iz5v3giwHoYpJUczWWJtaxnqxvB+7/aK/vY9qnnYIPksC8Yyg== 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 AM5PR0801MB1844.eurprd08.prod.outlook.com (2603:10a6:203:39::22) by AM6PR08MB3864.eurprd08.prod.outlook.com (2603:10a6:20b:8e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Fri, 8 Oct 2021 12:18:40 +0000 Received: from AM5PR0801MB1844.eurprd08.prod.outlook.com ([fe80::4cab:e095:5105:b6ec]) by AM5PR0801MB1844.eurprd08.prod.outlook.com ([fe80::4cab:e095:5105:b6ec%9]) with mapi id 15.20.4566.022; Fri, 8 Oct 2021 12:18:40 +0000 To: "gcc-patches@gcc.gnu.org" Subject: [Patch 6/7, Arm, GCC] Emit build attributes for PACBTI target feature. Thread-Topic: [Patch 6/7, Arm, GCC] Emit build attributes for PACBTI target feature. Thread-Index: Ade8PEiv0rcXGdRcTAaXoDGfc7ZSpg== Date: Fri, 8 Oct 2021 12:18:39 +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: B5BE6CF68F90BC4D8CE84B1C14934148.0 x-checkrecipientchecked: true Authentication-Results-Original: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: db1f04da-fcbc-415c-40bd-08d98a55c82f x-ms-traffictypediagnostic: AM6PR08MB3864:|AM8PR08MB6516: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:4941;OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 1PNgfScL2vU3pa327nSO1+kaSuVEV7v3g/2iEW+0kevpAK2DF2p3Y9o/ENxpSt0/kFflqLZ5I2ZAfX7d0kLYW/Ltf1RPk+Ik01cU0FXp7zp1fagbJOPjJz/TN+5pQ7LYuXXUFnwRoHOsn2h6emv6rsaQiW5WJexOMOmB/uDpNrjbAjp71sP+2jYlgxpKSIfWTnV/txLBaSfFrn4HjVZxA5Fjm40cjb64aoK2wzY/9XfT8yViNVF2q3lY7+ZAkiRkcGRBkBHnklEcs62GNtzqx8QohvfqKriVyJkUjKHN13ChWiXyP4nmZPA2r0fHLR9dkOvCLNJdVkBuElEOVGMTWsQDIJj11IUDXVlo0vl6UGY9r1C4nFz5OHwBzfanzKEhabgwIUu9eLrMAl1Bk+rJIt2jvSc2RQhYCOoOEEaaKkMQ3p71Gre5Vpd470CXTv5z+5qkpRFx8MjG7BQxKvrui2GJwADVe9Q5Z3P2/mZ8HmLSSEi3x2leHAJtDkAhdbA+zDXdeZwIzJObTyfSMHa5dU4POn/2J9gkX7wdCWbRgEf1aIcFdgn598W1ZnVA4nx1OfNiS6eM7xd+WdUIgO1wixRiRC+mbPpUh+jwnwowF/RHdrVvNkar+Fr8K3/fAtAwuXSMdF6J58gnQVxjKh8jKFusNUE1Qq8Z4ZNPhh4r6jJSSI8Wm5hDRIjXSVMknyPqYq64qOgbiJont4wc3shfbnXxquaOEb73A9dvCSuv7AjVFHZcZ/PgCxeMhO4JGoVS5JioL4H+CZMUwIoE4CzKnztwKGR+MfDHPhXvFU+osIDDxtJE0w/740V1twjmZxBqhVeuo7bNisij7yYoZTKS4A== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0801MB1844.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(76116006)(86362001)(8936002)(6506007)(38100700002)(122000001)(71200400001)(38070700005)(66476007)(5660300002)(33656002)(26005)(9686003)(508600001)(316002)(8676002)(4744005)(66556008)(2906002)(55016002)(52536014)(7696005)(66946007)(6916009)(83380400001)(186003)(99936003)(64756008)(66446008); DIR:OUT; SFP:1101; x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3864 Original-Authentication-Results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 097c7a2c-7c05-42f7-8490-08d98a55c321 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qpLEtnqNTbnjvZCFTJjcMUaZiIxW11cwUj4BGJAyTWvjcM/SsZd0JS0zCYdk2XgpuAX6jJCopRGMfB6gxdnz83CzJ3u8n2Wku8/MlBNrIVr6rW1rVOyt5gtGUffCC56+3Rn3430z3ACdGKLQuhrDkLnaRSWpYJQHp0Mq+pzdK7xmSj65jbxg3peXoUf/JCb/OLstZd+ZBvr1rxu0dcoGToe8kZ0GXBnUIVaj0wIMfuyg16+6AlcVUox6fOCfgIBmJ1TTjiZDy73GE0tlkgj4b/m+WUoTwQpsL0u/EWTKB7KFOfGp8FnDRClYqFOSbKpvLbn+1H+tw8mxJy0Yv45zn+h4udyooYDjEvrALPCLJF82i6+jZ2QXBZDmPtkNlSZB/6TQs0lBNPr75LuG7hzjKHIyfuSy0QDI/218T57HpZ5UZLkb+2IUE3u310E4zS3pJzPhOcLOcwFIvhMgwa+K2Yi8YqUTIbAmDsPqY6AWXd1mXyfxGcF4hNJF/JwDpVAY6Q3hMv0AGVG63Tqawr+W2nlDFU3FiUne08wusBNhurVncXBwI3EXN/r8mBdLq5HrJYT23ztHBQXPCo5R5E9TYkdTFjgN4xPCfdpHcKfLPi0ml5xzh3TXhcKoMcOOu3WYOp5kotwaVkcAMorOUCSEdOsc9X8AaK5xjKZlklwMIXmffTa/PxTQUDruTGV62Qb3CsppPfnLOiT2jIJQCOQy4c8qyNSSY54vnT/nCbggAN/p7wzwxcJsAFC823fg9TSZLf/s7qSi6pgm39fWjAexqmAaJ886mFsVqI7svP0zL1yu8I4gcm3dBPSMBKlktjUSRHTS7++LzXnNcxOXIyKdAg== 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)(36840700001)(46966006)(6916009)(55016002)(83380400001)(235185007)(5660300002)(70586007)(86362001)(316002)(36860700001)(8936002)(82310400003)(70206006)(8676002)(52536014)(6506007)(508600001)(7696005)(336012)(33656002)(47076005)(356005)(186003)(21480400003)(81166007)(26005)(99936003)(9686003)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2021 12:18:48.4499 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db1f04da-fcbc-415c-40bd-08d98a55c82f 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: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6516 X-Spam-Status: No, score=-13.7 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" Hi, This patch emits assembler directives for PACBTI build attributes as defined by the ABI. (https://github.com/ARM-software/abi-aa/releases/download/2021Q1/addenda32.pdf) Tested on arm-none-eabi. 2021-10-04 Tejas Belagod gcc/ChangeLog: * config/arm/arm.c (arm_file_start): Emit EABI attributes for Tag_PAC_extension, Tag_BTI_extension, TAG_BTI_use, TAG_PACRET_use. gcc/testsuite/ChangeLog: * gcc.target/arm/acle/pacbti-m-predef-1.c: New test. * gcc.target/arm/acle/pacbti-m-predef-3: New test. * gcc.target/arm/acle/pacbti-m-predef-6.c: New test. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 1f939a6b79a90430abf120e0aa075dfc1fab29a8..557aae371e2707cb8db569ce033242a139b64e86 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -28305,6 +28305,27 @@ arm_file_start (void) arm_emit_eabi_attribute ("Tag_ABI_FP_16bit_format", 38, (int) arm_fp16_format); + if (TARGET_HAVE_PACBTI) + { + arm_emit_eabi_attribute ("Tag_PAC_extension", 50, 2); + arm_emit_eabi_attribute ("Tag_BTI_extension", 52, 2); + arm_emit_eabi_attribute ("TAG_BTI_use", 74, arm_enable_pacbti & 0x1); + arm_emit_eabi_attribute ("TAG_PACRET_use", 76, + (arm_enable_pacbti >> 1 != 0)); + } + else + { + if (arm_enable_pacbti != 0) + { + arm_emit_eabi_attribute ("Tag_PAC_extension", 50, 1); + arm_emit_eabi_attribute ("Tag_BTI_extension", 52, 1); + arm_emit_eabi_attribute ("TAG_BTI_use", 74, + arm_enable_pacbti & 0x1); + arm_emit_eabi_attribute ("TAG_PACRET_use", 76, + (arm_enable_pacbti >> 1 != 0)); + } + } + if (arm_lang_output_object_attributes_hook) arm_lang_output_object_attributes_hook(); } diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c new file mode 100644 index 0000000000000000000000000000000000000000..de9102be3f293605d0891c45cd247be9cf8bd00b --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c @@ -0,0 +1,22 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=pac-ret+bti --save-temps" } */ + +/* { dg-final { scan-assembler "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */ + +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-3.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c new file mode 100644 index 0000000000000000000000000000000000000000..6ecdf2f7411e5d44a5304681032d0841d965b49c --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c @@ -0,0 +1,21 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=pac-ret+b-key+leaf --save-temps" } */ + +/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 0" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */ + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 0) + __builtin_abort (); + + if (__ARM_FEATURE_PAC_DEFAULT != 6) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c new file mode 100644 index 0000000000000000000000000000000000000000..2340bf0f937b7ea68a02500b66f151f0ce3f39b6 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c @@ -0,0 +1,21 @@ + +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-additional-options " -mbranch-protection=bti --save-temps" } */ + +/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 0" } } */ + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 1) + __builtin_abort (); + + if (__ARM_FEATURE_PAC_DEFAULT != 0) + __builtin_abort (); + + return 0; +}