From patchwork Tue Jan 21 15:03:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 1226620 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517892-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=ct/5EwMk; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=9LR3l77l; dkim=fail reason="signature verification failed" (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=9LR3l77l; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 482BdX2sCKz9sRk for ; Wed, 22 Jan 2020 02:04:15 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:references:in-reply-to :content-type:mime-version; q=dns; s=default; b=UanUppln62tCGMpz IUe+ZyK11fET8K+QPQtUu5t0Z9p/blk87ZTJoJDEQ2b8XZkWS6C9UvtotktrYq2o bdRkecSosmjbqDCKfMBcsQmuUIEY7yaiAXK2EFN+QEGTI/P7m8iRcYQ3HRqMoOaE Om+hAOgU9/UI57qp7Ybsk326/7Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:references:in-reply-to :content-type:mime-version; s=default; bh=r9BLr6DkhjZ2uhnbXAM5Sr GkfR4=; b=ct/5EwMkWT49hGAVzfQZqHjvUiwcRfDqm98+KJE0An+E62+XClRkLb 6HLilQ/uRztY4HRo06OWNqhCYuVHBXidtwAy0U68TLfSU/CWDgNdhmEjfPRt9nwD ZxsNSlhkUPWLBoyuJ0XQqblEdSYvKW+vWM1+UVDWyLCObmxdAZ7PA= Received: (qmail 125010 invoked by alias); 21 Jan 2020 15:04:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 125000 invoked by uid 89); 21 Jan 2020 15:04:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy= X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr130088.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (40.107.13.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Jan 2020 15:03:55 +0000 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=5z8hy4GK8o1b7Ki6+Qb9PJxYCDU7GonbKE2MULVH1Zc=; b=9LR3l77lLAPMaTuaM3/KfYJsbIG1/vTaZUV7tEmGSq21DKXDMR/6cIw9M81hmkLcH3EXdHIv1XFtK62hNXZYduadjouEF8+A559ndzm4VIyK6WoOEUJmGJdgrYqkUamIFrXH/sejynBxRBccmWsMVh6DdXTv5RGMD3XAwlVFuKw= Received: from VI1PR08CA0181.eurprd08.prod.outlook.com (2603:10a6:800:d2::11) by VI1PR08MB4047.eurprd08.prod.outlook.com (2603:10a6:803:df::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19; Tue, 21 Jan 2020 15:03:51 +0000 Received: from DB5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::206) by VI1PR08CA0181.outlook.office365.com (2603:10a6:800:d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.18 via Frontend Transport; Tue, 21 Jan 2020 15:03:51 +0000 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=bestguesspass 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 DB5EUR03FT032.mail.protection.outlook.com (10.152.20.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.23 via Frontend Transport; Tue, 21 Jan 2020 15:03:51 +0000 Received: ("Tessian outbound 4f3bc9719026:v40"); Tue, 21 Jan 2020 15:03:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1d9f3546856da8a4 X-CR-MTA-TID: 64aa7808 Received: from ce7eccc8ce7e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9C2BBC85-C998-41C6-9C2E-B800F5FCF1BC.1; Tue, 21 Jan 2020 15:03:45 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ce7eccc8ce7e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 21 Jan 2020 15:03:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MXYFpPIaTMiydXHy2df+mr5losfitr/GoawCrjCUzt4oj8UIw8SoZgTI2tGymU/sQLiOvLyPQeD6cv6gBzELMjlNDg/fGoerdQetKrqYJjEpHZbFxD65E2DVxRjxDFtRf2ClD6yR0CjIA/0Hwfdut4y1wK2oQAZnAVgyTUzc92WlamGFuRSZDELfP6d2h7Yk7qs1vAfIemf9n9L/LW3u0JrbAxwmGqI6NdAXYPvcxzLk8LIXzx3bo1KreCzvlY3O6HKDBhZluzR2ENzhfpOjGmnc8y06ttGCJ21Wr0k0CIUuNYsSpofD6cIHOd/MKTx6QY1gkOfQ10LpwLhtZNj2Ww== 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-SenderADCheck; bh=5z8hy4GK8o1b7Ki6+Qb9PJxYCDU7GonbKE2MULVH1Zc=; b=nlsYaUL1A3GRbyMoPCzsc6bj+WxU3H8mWfPQGiPZLiyzqLuJMlHOQpjYYOJsENMPO05P629HFLZvJaYnBf/T+9jVBD1Y4UTW4jeA3rgFkDXXhRjieLbU4xc55RVgsLAIsyteq7EUztAYxYxA4j6WTGQiIn+dD0hXk775G6IPi3c3SFt1HwFeEhzpVAVUSUG6rSrOJ7QFjSZBR1MZg53F9DCu15RaPODEuBrLYHO/p6RfNEZgx1oOmfQUiQLj9+TQQaAf2dv33vp1AOXpN+kfrwoqTvrgNvkgU+5JDNlSVWEO9bBB1AFo1NvT0fB1lTr74KvKo6kmB7XpIH4MxKUIYg== 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 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=5z8hy4GK8o1b7Ki6+Qb9PJxYCDU7GonbKE2MULVH1Zc=; b=9LR3l77lLAPMaTuaM3/KfYJsbIG1/vTaZUV7tEmGSq21DKXDMR/6cIw9M81hmkLcH3EXdHIv1XFtK62hNXZYduadjouEF8+A559ndzm4VIyK6WoOEUJmGJdgrYqkUamIFrXH/sejynBxRBccmWsMVh6DdXTv5RGMD3XAwlVFuKw= Received: from DB7PR08MB3292.eurprd08.prod.outlook.com (52.134.111.30) by DB7PR08MB3036.eurprd08.prod.outlook.com (52.134.107.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20; Tue, 21 Jan 2020 15:03:40 +0000 Received: from DB7PR08MB3292.eurprd08.prod.outlook.com ([fe80::5d10:e4ac:4968:cab7]) by DB7PR08MB3292.eurprd08.prod.outlook.com ([fe80::5d10:e4ac:4968:cab7%4]) with mapi id 15.20.2644.024; Tue, 21 Jan 2020 15:03:40 +0000 Received: from [10.2.80.79] (217.140.106.55) by LO2P265CA0011.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19 via Frontend Transport; Tue, 21 Jan 2020 15:03:40 +0000 From: Szabolcs Nagy To: Mark Rutland CC: nd , =?utf-8?b?RsSBbmctcnXDrCBTw7JuZw==?= , GCC Patches , Sudakshina Das , Richard Earnshaw , Kyrylo Tkachov , Torsten Duwe , Richard Sandiford , Dave P Martin , Will Deacon , Mark Brown Subject: [PATCH v2][AArch64] PR92424: Fix -fpatchable-function-entry=N, M with BTI Date: Tue, 21 Jan 2020 15:03:40 +0000 Message-ID: <1f29f9cf-5072-8718-9bdf-2a07d6019442@arm.com> References: <00194eb0-f727-4d59-9bcd-60b05248d031@arm.com> <20200119085329.lj4ha7in5qmw5pgb@google.com> <20200121113434.GA2045@lakrids.cambridge.arm.com> <5509bc66-37bb-0cc2-14d2-0d67dc96961b@arm.com> In-Reply-To: <5509bc66-37bb-0cc2-14d2-0d67dc96961b@arm.com> user-agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Szabolcs.Nagy@arm.com; x-ms-exchange-transport-forked: True x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:7691;OLM:7691; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(39860400002)(346002)(366004)(376002)(199004)(189003)(2906002)(81156014)(478600001)(81166006)(5660300002)(37006003)(2616005)(54906003)(71200400001)(8676002)(86362001)(6486002)(66476007)(6862004)(66556008)(31696002)(8936002)(66446008)(66616009)(6636002)(64756008)(4744005)(4326008)(36756003)(52116002)(31686004)(44832011)(26005)(66946007)(16526019)(186003)(956004)(16576012)(316002)(142933001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB3036; H:DB7PR08MB3292.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Q9ubWCE8SKAMCDojQpox02HI2Fx39Gv8Yqi+RJ42+sdNhdHmi55/JRqgH8STOQD3rtDA38W0e08ZJoAGge/jtTCQTGGds4QH/KfgK7R501qPF5yuLbEWLL8EJKOKlpVCph9OE8HS4eTgi8WTtgcCIYElOa2GM3FXQhcuAqwKHgaQyXgfYMBbRcIi6K6nKg3rij5/1BBlMgd4ESmBhAxeqC2RTPWpA992lE4mfuVxM4Usws7dcrr6NfRMQoGXg1aQgbOqabO7NcmZOVGDJIBQyb213kGgHc5efT8JtVmWU252WxENjvNVIajzasq+W/TsBhz/1xjyeALexRqwLNhAAvPeQ0ycn4aSV/ERJKCcIFgfLFWHrN3Z3tmlRgyjy854e0XtwbxY17U4JQMtBfu2egCZ/PFtQwXQhmkSpqNmsVpFXTI1t8/eGWotV5KoFRGD9N6LbwPzPDdyRnoK+FjRkYg/F9XdfCAyHtkDiMuRufZ3McYpKvo3LUCns8hae/lD MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs.Nagy@arm.com; X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 082edcf7-9297-4332-2016-08d79e8319d2 X-IsSubscribed: yes v2: - emit bti based on feedback from Richard Sandiford (dont copy varasm logic). - add testcases. - kept bti outside the patch area if possible, i.e. option (b) in earlier discussion. This fix does not update the documentation of the generic option, I think some text would be useful there about patch area layout with indirect branch hardening (but i wanted to keep this fix target specific). gcc/ChangeLog: 2020-01-21 Szabolcs Nagy * config/aarch64/aarch64.c (aarch64_declare_function_name): Set cfun->machine->label_is_assembled. (aarch64_print_patchable_function_entry): New. (TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY): Define. * config/aarch64/aarch64.h (struct machine_function): New field, label_is_assembled. gcc/testsuite/ChangeLog: 2020-01-21 Szabolcs Nagy * gcc.target/aarch64/pr92424-1.c: New test. * gcc.target/aarch64/pr92424-2.c: New test. * gcc.target/aarch64/pr92424-3.c: New test. From 65a60c0dc4318a33e0a0e0a6573084d84bd18a88 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Wed, 15 Jan 2020 12:23:40 +0000 Subject: [PATCH] [AArch64] PR92424: Fix -fpatchable-function-entry=N,M with BTI This is a workaround that emits a BTI after the function label if that is followed by a patch area. We try to remove the BTI that follows the patch area (this may fail e.g. if the first instruction is a PACIASP). So before this commit -fpatchable-function-entry=3,1 with bti generates .section __patchable_function_entries .8byte .LPFE .text .LPFE: nop foo: nop nop bti c // or paciasp ... and after this commit .section __patchable_function_entries .8byte .LPFE .text .LPFE: nop foo: bti c nop nop // may be paciasp ... and with -fpatchable-function-entry=1 (M=0) the code now is foo: bti c .section __patchable_function_entries .8byte .LPFE .text .LPFE: nop // may be paciasp ... There is a new bti insn in the middle of the patchable area users need to be aware of unless M=0 (patch area is after the new bti) or M=N (patch area is before the label, no new bti). Note: bti is not added to all functions consistently (it can be turned off per function using a target attribute or the compiler may detect that the function is never called indirectly), so if bti is inserted in the middle of a patch area then user code needs to deal with detecting it. Tested on aarch64-none-linux-gnu. gcc/ChangeLog: * config/aarch64/aarch64.c (aarch64_declare_function_name): Set cfun->machine->label_is_assembled. (aarch64_print_patchable_function_entry): New. (TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY): Define. * config/aarch64/aarch64.h (struct machine_function): New field, label_is_assembled. gcc/testsuite/ChangeLog: * gcc.target/aarch64/pr92424-1.c: New test. * gcc.target/aarch64/pr92424-2.c: New test. * gcc.target/aarch64/pr92424-3.c: New test. --- gcc/config/aarch64/aarch64.c | 31 +++++ gcc/config/aarch64/aarch64.h | 1 + gcc/testsuite/gcc.target/aarch64/pr92424-1.c | 122 +++++++++++++++++++ gcc/testsuite/gcc.target/aarch64/pr92424-2.c | 12 ++ gcc/testsuite/gcc.target/aarch64/pr92424-3.c | 12 ++ 5 files changed, 178 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/pr92424-1.c create mode 100644 gcc/testsuite/gcc.target/aarch64/pr92424-2.c create mode 100644 gcc/testsuite/gcc.target/aarch64/pr92424-3.c diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index e40750380cc..ef037e226a7 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -18123,6 +18123,34 @@ aarch64_declare_function_name (FILE *stream, const char* name, /* Don't forget the type directive for ELF. */ ASM_OUTPUT_TYPE_DIRECTIVE (stream, name, "function"); ASM_OUTPUT_LABEL (stream, name); + + cfun->machine->label_is_assembled = true; +} + +/* Implement PRINT_PATCHABLE_FUNCTION_ENTRY. Check if the patch area is after + the function label and emit a BTI if necessary. */ + +void +aarch64_print_patchable_function_entry (FILE *file, + unsigned HOST_WIDE_INT patch_area_size, + bool record_p) +{ + if (cfun->machine->label_is_assembled + && aarch64_bti_enabled () + && !cgraph_node::get (cfun->decl)->only_called_directly_p ()) + { + /* Remove the BTI that follows the patch area and insert a new BTI + before the patch area right after the function label. */ + rtx_insn *insn = next_real_nondebug_insn (get_insns ()); + if (insn + && INSN_P (insn) + && GET_CODE (PATTERN (insn)) == UNSPEC_VOLATILE + && XINT (PATTERN (insn), 1) == UNSPECV_BTI_C) + delete_insn (insn); + asm_fprintf (file, "\thint\t34 // bti c\n"); + } + + default_print_patchable_function_entry (file, patch_area_size, record_p); } /* Implement ASM_OUTPUT_DEF_FROM_DECLS. Output .variant_pcs for aliases. */ @@ -21970,6 +21998,9 @@ aarch64_run_selftests (void) #undef TARGET_ASM_TRAMPOLINE_TEMPLATE #define TARGET_ASM_TRAMPOLINE_TEMPLATE aarch64_asm_trampoline_template +#undef TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY +#define TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY aarch64_print_patchable_function_entry + #undef TARGET_BUILD_BUILTIN_VA_LIST #define TARGET_BUILD_BUILTIN_VA_LIST aarch64_build_builtin_va_list diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 342fe29bd91..297d197297e 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -842,6 +842,7 @@ typedef struct GTY (()) machine_function struct aarch64_frame frame; /* One entry for each hard register. */ bool reg_is_wrapped_separately[LAST_SAVED_REGNUM]; + bool label_is_assembled; } machine_function; #endif diff --git a/gcc/testsuite/gcc.target/aarch64/pr92424-1.c b/gcc/testsuite/gcc.target/aarch64/pr92424-1.c new file mode 100644 index 00000000000..c413a2c306e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr92424-1.c @@ -0,0 +1,122 @@ +/* { dg-do "compile" } */ +/* { dg-options "-O1" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* Note: this test only checks the instructions in the function bodies, + not the placement of the patch label or nops before the futncion. */ + +/* +**f10_none: +** nop +** ret +*/ +void +__attribute__ ((target("branch-protection=none"), + patchable_function_entry (1, 0))) +f10_none () +{ +} + +/* +**f10_pac: +** hint 34 // bti c +** nop +** hint 25 // paciasp +** hint 29 // autiasp +** ret +*/ +void +__attribute__ ((target("branch-protection=bti+pac-ret+leaf"), + patchable_function_entry (1, 0))) +f10_pac () +{ +} + +/* +**f10_bti: +** hint 34 // bti c +** nop +** ret +*/ +void +__attribute__ ((target("branch-protection=bti"), + patchable_function_entry (1, 0))) +f10_bti () +{ +} + +/* +**f11_none: +** ret +*/ +void +__attribute__ ((target("branch-protection=none"), + patchable_function_entry (1, 1))) +f11_none () +{ +} + +/* +**f11_pac: +** hint 25 // paciasp +** hint 29 // autiasp +** ret +*/ +void +__attribute__ ((target("branch-protection=bti+pac-ret+leaf"), + patchable_function_entry (1, 1))) +f11_pac () +{ +} + +/* +**f11_bti: +** hint 34 // bti c +** ret +*/ +void +__attribute__ ((target("branch-protection=bti"), + patchable_function_entry (1, 1))) +f11_bti () +{ +} + +/* +**f21_none: +** nop +** ret +*/ +void +__attribute__ ((target("branch-protection=none"), + patchable_function_entry (2, 1))) +f21_none () +{ +} + +/* +**f21_pac: +** hint 34 // bti c +** nop +** hint 25 // paciasp +** hint 29 // autiasp +** ret +*/ +void +__attribute__ ((target("branch-protection=bti+pac-ret+leaf"), + patchable_function_entry (2, 1))) +f21_pac () +{ +} + +/* +**f21_bti: +** hint 34 // bti c +** nop +** ret +*/ +void +__attribute__ ((target("branch-protection=bti"), + patchable_function_entry (2, 1))) +f21_bti () +{ +} diff --git a/gcc/testsuite/gcc.target/aarch64/pr92424-2.c b/gcc/testsuite/gcc.target/aarch64/pr92424-2.c new file mode 100644 index 00000000000..0e75657a153 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr92424-2.c @@ -0,0 +1,12 @@ +/* { dg-do "compile" } */ +/* { dg-options "-O1" } */ + +/* Test the placement of the .LPFE1 label. */ + +void +__attribute__ ((target("branch-protection=bti"), + patchable_function_entry (1, 0))) +f10_bti () +{ +} +/* { dg-final { scan-assembler "f10_bti:\n\thint\t34 // bti c\n.*\.LPFE1:\n\tnop\n.*\tret\n" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/pr92424-3.c b/gcc/testsuite/gcc.target/aarch64/pr92424-3.c new file mode 100644 index 00000000000..0a1f74d4096 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr92424-3.c @@ -0,0 +1,12 @@ +/* { dg-do "compile" } */ +/* { dg-options "-O1" } */ + +/* Test the placement of the .LPFE1 label. */ + +void +__attribute__ ((target("branch-protection=bti+pac-ret+leaf"), + patchable_function_entry (1, 0))) +f10_pac () +{ +} +/* { dg-final { scan-assembler "f10_pac:\n\thint\t34 // bti c\n.*\.LPFE1:\n\tnop\n.*\thint\t25 // paciasp\n.*\thint\t29 // autiasp\n.*\tret\n" } } */ -- 2.17.1