From patchwork Fri Aug 12 15:21:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 56712 X-Patchwork-Delegate: rearnsha@gcc.gnu.org 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 83AF13858436 for ; Fri, 12 Aug 2022 15:21:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83AF13858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660317714; bh=ZtfaIXC8wiiHN9Pexf+DVnZyyPQQD0tfStd/RNOckCk=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=mfBIIVjJT5MMN/sOIsEbo78axii06yfkd7z1xVHP59iOE4ty7J72RuK5F2woVMW71 MWQfk7DvLBMRvZ42WHcuzf4zRVwnw8NNlA2QnoVyxV3Gv6QgnFQLnBL6CKN4YL3utB d4AUUcG2IsiJS0gdd1xwMX86YIwb+C0c9bnt24pI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130071.outbound.protection.outlook.com [40.107.13.71]) by sourceware.org (Postfix) with ESMTPS id 969423858C56 for ; Fri, 12 Aug 2022 15:21:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 969423858C56 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=gEeb+y5TywjpSPxaLF1wr4o+lmnuniH3FwlUammDL649KNA0jR42lLVigsLOhfYGJGahv1gr8cWx4eV+IR/MsYHZfJl8REVWdFL+1uk+JnY6TEVLItLeGuL177KypJXId06oVRq5EDH2qAB9Q0kiLOhP8Y2Ns3nQvqW4bvWtCQsPzlzH5wc7y4xvFmG57fGXSvZ5+xG4gTrLG9LPJSEGSLJ8xz6UbuEFR5gLvZ290V1g2/6yAuvA1Oxs6CdB8SEz7HbM0wlshkNvh0DtoUveq2DGv/zW5q65qHmw3tlH1e9pFwG4IfvBvKM6F+kuIHqKmpVabWTxaSP8Sr1h74jdQw== 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=ZtfaIXC8wiiHN9Pexf+DVnZyyPQQD0tfStd/RNOckCk=; b=YfyNWpJiMEbolQqLiqvZPpI17tZZeD+cFQuLztjU2DegybTtvih87qBUfOFb7PPlMBgVC8730YGS+gC/o8uyGjqa06VsrY/tibzhaFT0INiTYfxTA+OoI9KThNL2w+v7p/HX79OwrGaqULK39222YsXIeiJnIwPtSe+PWWwtP0bwncUrpuNAT7Anv8Gb2682NBGQ4H6nh+4HQyOD1doBeknVwkH6fsSvUblfi3GL0Gae/0EXm/dNTomjtZr42uIkxvK0IGpZZdUgeaTfhEZaHfiu4fEoXiKoW3VLRISwtlaFkf/zv96YcL8yVRTRzjMHaCq9rs4EHD7kiVHnYwZWrg== 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 DBBPR09CA0021.eurprd09.prod.outlook.com (2603:10a6:10:c0::33) by DU0PR08MB7567.eurprd08.prod.outlook.com (2603:10a6:10:317::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Fri, 12 Aug 2022 15:21:19 +0000 Received: from DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::a7) by DBBPR09CA0021.outlook.office365.com (2603:10a6:10:c0::33) 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:21:19 +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 DBAEUR03FT022.mail.protection.outlook.com (100.127.142.217) 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:21:18 +0000 Received: ("Tessian outbound fccf984e7173:v123"); Fri, 12 Aug 2022 15:21:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7358ca300bb4dc34 X-CR-MTA-TID: 64aa7808 Received: from 760f068cb02d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2D3D10DF-7B24-4051-A514-B8136D9CBCA4.1; Fri, 12 Aug 2022 15:21:12 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 760f068cb02d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:21:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfjDu/0U9cnkjaV1D+UI71OGOt9xPTEfU0knrn/HJ5H05zRgS4Hc2yGTPpT0Zoxn7odPvrMuvZbcYyEYDRZ3ecvsloJb3X58Nom1V/5RLJgJXtaRgKf1NeCgon6OeCryhJdGRGhzUloMH3WWbyXc1FOczs2HYdx4YspQ8R90OlR9NpbtnoF+/PFHj+egurFMk10CotyWuHMH2vbG/JqdTDXkIX4h0V3XuJloe50mENSsbk7XqlviNuZiX/3fpyTU4hI4FByXeVQBSBbNn9SECK0CBoPABqxdDACASBTWzoezYWjhEMxUzeNwjbColyAIRSbhHKENRyCCmwSQwzcUWA== 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=ZtfaIXC8wiiHN9Pexf+DVnZyyPQQD0tfStd/RNOckCk=; b=PCF3qJkUTF5WBv+Lu1ROMhC9iZBwC5XB02i12j7nbFk8EX3Bc6t/eGeinKJ37t5dvUYzdSpdffIYxsOks4ubFNOKtb7gGZW4o7bxwbDJQ2Bsgqm2Tg5aZkH7NpTitgQrozK4Cjjl3RWD3xQst3aFCX9vpLuZFcyHTLj+/2bZS/jo9aoFeYryhzPfmJfKFInxeqeXXWNSuLdjV2GGGwygWyVic4Y8icD/0QuzODg7SQ1fwhOif8baNIlDhnzfwWMFPl6H3T84U2SdHFF1b0qOqoxel0m5DxwD+XXkUsfTfBOQ333t6YTW5FBnWWPrBdLFh3o+qbJJ9hw6sqfKammFiA== 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 AM6P192CA0036.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:83::49) by GV2PR08MB8171.eurprd08.prod.outlook.com (2603:10a6:150:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.19; Fri, 12 Aug 2022 15:21:05 +0000 Received: from AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:83:cafe::d0) by AM6P192CA0036.outlook.office365.com (2603:10a6:209:83::49) 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:21:05 +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 AM7EUR03FT063.mail.protection.outlook.com (100.127.140.221) 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:21:05 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2507.9; Fri, 12 Aug 2022 15:21:01 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.9; Fri, 12 Aug 2022 15:21:00 +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:21:00 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 3/15] arm: Add option -mbranch-protection References: Date: Fri, 12 Aug 2022 17:21:00 +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 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 4ebd2c79-6683-455f-768d-08da7c764e50 X-MS-TrafficTypeDiagnostic: GV2PR08MB8171:EE_|DBAEUR03FT022:EE_|DU0PR08MB7567: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: N8fDXcpbFNiQWPlMe1yjvFUfmSV8jv/wfTyg9MlijzNuAN8C/F0pYo8pEqVWQovHAr1MKFJJTm5vOZyox1U9Ve2af9HHGzkE/qzuLCT+qFOj/sPXeuhXK08sMk5XYy89F5lIDMR5mFfJxY4IXLmFf0n3huXcrRNy4XFc9pZ3cykcW07Hd9oVMVGCiS+bVVdSJeC7S8aSI/u2nMHn9yZ3Z1qfp4D7WSL+boXnIMkhXqcKRQrMB0Pl5HWaZL2kWVeUc+UgTY5xyk6fLYUO3lVI7R9a4eP1sYIMVQASXbh0642Joy7N6QOfvJRn8fTowj56SO1r6i7GvLdIFHcNSXwm3F37PP+H/0rfU9CGAVbWtvv1lTv6PUc9gn2pQvx/lqg7B22+oujcR7nDd27oBiS1YoOjJl48OZyU8AZWwcs0+p2gHK88imMmr9wZjCT5xrttamycJD3FIW/4WLlVcttNDYrNMKe19r6U/oOqDiJ1I5IqDRbkZ6FacZcSnohTPdVg4lvaElWSg/TvdHx0cXIkNvl7Tb8P7FCz4z7DxBPeKXlkzFoRg/wQmq8FRifOAU2RrpSak4Y0N8ZMiXEXWCLc/u3XbDogYBnV1H47J6ooNWvNdF0aB268/muOrwJlldBFG1a/x2DYt1YSs+0vLfWidTE1JVZrIEPckZv8gtMFC4TLCEL4fImhgHtjhOqRZL2EIUbzW9VppurfMuju7e+wDkvq2e26/23fq5RnY1hN4OsVTbcZJ2Ah0uEiD4p+pQEzqhn0vskVk+B9VsyYuqxeg6Z+4cgM3x3KwWVpI4cWz5HBRZRm2TAT3Lc3H+Qklxrqbvn8dGGc8EyuCHru7Nx8TXyLIsM/8hhHeHEqMFCi3ApzTK4ROaXveUwHK6YKVtig 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)(39860400002)(376002)(346002)(136003)(396003)(46966006)(40470700004)(36840700001)(336012)(40460700003)(316002)(47076005)(426003)(83380400001)(356005)(40480700001)(81166007)(44832011)(82740400003)(36860700001)(82310400005)(86362001)(70586007)(8676002)(70206006)(6916009)(26005)(186003)(36756003)(41300700001)(2616005)(478600001)(2906002)(33964004)(4326008)(5660300002)(235185007)(54906003)(8936002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8171 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 830a69a5-0c14-4372-ccbd-08da7c764660 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x/R5GEyks1DKfdt307KfqekU9UF5dqJpA23pmf6TBCTI4FS2K7oxI3Awur/y6IFa5TwPY6EidHAKpGgwDtKgWFjKdFMJG2FO6SMn18HSU+Lm5TxzfZ2uyUaIVD5csRDUgRK4g+x0kyksycgXAkJWgziuU/A5uLiy3PbEOj754Qc4iNIjtT0S9WaGCJNLRa+rPp4RUSPiyEioTGoju7lGBCDVzgHImTdy4+fl/63ez/jO4BqNZ4FOcyd5b6U7/54RTY5mUhr/SyHXSBDcgG3RozV4GHWxkW649IGRU9qQcHh9Z1t+R59rOyboC8b7gC6mu43kCVGw0XAQnP3eUIhtsIhXq3LCvnbbrc94qJM0XViBOq0q+HKKEKin/x3ALJsbOQ7iNGZcPDNwWf2ZIMuwNDTj+o8oPOu2pFx2f66MYnTSqCYfSfFix6tntMxaoz/seawXrDJjwBrmjI6I9eoi2acQOuvTyfI/ab1gyczU0VzIvdElFNWsz0HafmOotFzhspmshpm158Do75nThaMKZL7zGbHeXQEa4JUk2SWIC5ov11Drjg7mVHBmqpY7zIZsq8rWI4rmgCKrCjeBRvfj7C5eXgq+HlJdKA5Woc9rvjR3rdlUeJLzbNtw0cs2CW6/qnQ0qhjmjhAZclkqaJs2pzYP+ISAvl50GcAsZOncAJ5UJvVSz8XCsSF+NWYAiN+GD59lf+Ej7YhtFJKpw/hyrXItYgZSgKV/MD0EI+okMKZ1e8VDtMJsBzBpsSSDBLUhQYXs1BFAjwTLIGhOFPZJhgUQMtJ+4BLGSQwzYSXWasdqxJ0CGeIPejD9/PfQdlKRZJ1cvfeySNFsfc20yIpdyg== 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)(136003)(376002)(346002)(39860400002)(396003)(40470700004)(46966006)(36840700001)(316002)(6916009)(478600001)(54906003)(41300700001)(2906002)(4326008)(40480700001)(40460700003)(82310400005)(70206006)(8676002)(44832011)(70586007)(235185007)(5660300002)(8936002)(82740400003)(36756003)(36860700001)(86362001)(426003)(2616005)(81166007)(186003)(47076005)(336012)(26005)(83380400001)(33964004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:21:18.8227 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ebd2c79-6683-455f-768d-08da7c764e50 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: DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7567 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-Patchwork-Original-From: Andrea Corallo via Gcc-patches From: Andrea Corallo Reply-To: Andrea Corallo Cc: Richard Earnshaw , nd Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi all, this adds -mbranch-protection option. This option enables the code-generation of pointer signing and authentication instructions in function prologues and epilogues. gcc/ChangeLog: * config/arm/arm.c (arm_configure_build_target): Parse and validate -mbranch-protection option and initialize appropriate data structures. * config/arm/arm.opt (-mbranch-protection): New option. * doc/invoke.texi (Arm Options): Document it. Co-Authored-By: Tejas Belagod Co-Authored-By: Richard Earnshaw Approved here diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 60f3eae82a4..0068817b0f2 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -3263,6 +3263,17 @@ arm_configure_build_target (struct arm_build_target *target, tune_opts = strchr (opts->x_arm_tune_string, '+'); } + if (opts->x_arm_branch_protection_string) + { + aarch_validate_mbranch_protection (opts->x_arm_branch_protection_string); + + if (aarch_ra_sign_key != AARCH_KEY_A) + { + warning (0, "invalid key type for %<-mbranch-protection=%>"); + aarch_ra_sign_key = AARCH_KEY_A; + } + } + if (arm_selected_arch) { arm_initialize_isa (target->isa, arm_selected_arch->common.isa_bits); diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt index f54ec8356c3..d292e23ea11 100644 --- a/gcc/config/arm/arm.opt +++ b/gcc/config/arm/arm.opt @@ -323,6 +323,10 @@ mbranch-cost= Target RejectNegative Joined UInteger Var(arm_branch_cost) Init(-1) Cost to assume for a branch insn. +mbranch-protection= +Target RejectNegative Joined Var(arm_branch_protection_string) Save +Use branch-protection features. + mgeneral-regs-only Target RejectNegative Mask(GENERAL_REGS_ONLY) Save Generate code which uses the core registers only (r0-r14). diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 079e34ed98c..a2be3446594 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -825,7 +825,9 @@ Objective-C and Objective-C++ Dialects}. -mcmse @gol -mfix-cmse-cve-2021-35465 @gol -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} @gol --mfdpic} +-mfdpic @gol +-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}] +[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]} @emph{AVR Options} @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args @gol @@ -21521,6 +21523,40 @@ The opposite @option{-mno-fdpic} option is useful (and required) to build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi}) toolchain as the one used to build the userland programs. +@item +-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] +@opindex mbranch-protection +Enable branch protection features (armv8.1-m.main only). +@samp{none} generate code without branch protection or return address +signing. +@samp{standard[+@var{leaf}]} generate code with all branch protection +features enabled at their standard level. +@samp{pac-ret[+@var{leaf}]} generate code with return address signing +set to its standard level, which is to sign all functions that save +the return address to memory. +@samp{leaf} When return address signing is enabled, also sign leaf +functions even if they do not write the return address to memory. ++@samp{bti} Add landing-pad instructions at the permitted targets of +indirect branch instructions. + +If the @samp{+pacbti} architecture extension is not enabled, then all +branch protection and return address signing operations are +constrained to use only the instructions defined in the +architectural-NOP space. The generated code will remain +backwards-compatible with earlier versions of the architecture, but +the additional security can be enabled at run time on processors that +support the @samp{PACBTI} extension. + +Branch target enforcement using BTI can only be enabled at runtime if +all code in the application has been compiled with at least +@samp{-mbranch-protection=bti}. + +Any setting other than @samp{none} is supported only on armv8-m.main +or later. + +The default is to generate code without branch protection or return +address signing. + @end table @node AVR Options