From patchwork Wed Dec 14 20:07:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 33336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp442425wrn; Wed, 14 Dec 2022 12:10:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf6xCBea0j2qtzmNaI13exrg5PkEMpVKqokYftrZtEkIvjg9etEVVEQOiqN49d1gamedGDom X-Received: by 2002:a05:6402:446:b0:46a:3bd0:4784 with SMTP id p6-20020a056402044600b0046a3bd04784mr22101617edw.7.1671048616933; Wed, 14 Dec 2022 12:10:16 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b9-20020a056402278900b0046ff38a9345si8147259ede.587.2022.12.14.12.10.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 12:10:16 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Xz1j6gcs; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 534FE38369E3 for ; Wed, 14 Dec 2022 20:09:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 534FE38369E3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671048578; bh=rvBG8V69h6zXMPrV9hjlB2iiY+fMfBPTJTgcA0tedvU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Xz1j6gcsRSbln2xp2MHfMFGx/ggGqyeLaJnYWVzXmcJEr8aUJdhY+G1llvsvYNasW ooKePWZJpOFXSHg2GQkOgX3SiYEj06TcIwYcsqKO0CSbdrij+t2Y91/g3a8xgnS3mJ b4/v98ZtmDisrW5nTvHeGcLs549RHftHKbcM+MY0= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 00CEA3871D24 for ; Wed, 14 Dec 2022 20:09:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 00CEA3871D24 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BEHFfpV006689 for ; Wed, 14 Dec 2022 20:09:16 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3meyewu901-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 14 Dec 2022 20:09:15 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BEJ0fPZ003951 for ; Wed, 14 Dec 2022 20:09:14 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3meyewm6rc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 14 Dec 2022 20:09:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oP95hBlmfopOb3MK0cB3/RvG3KmerR+t42vLRYS0iKRDr7XG316o1burW+345duQhwrguGWcXd9NxjMMnpDwjTsPVHcgGz3ldwscC5PglkCR0yr6QmZv3se3bu1kmrJv59Mci44SuedR3fzGOxEoxgbszwaFqX9KG6nZoAVhIrq7WmuXhAR34A9hKsdISbuhsR6qhCo6aq465KkqBstSQsk01cfN5JC1ZS0Vb+q6rkXNj17pjY92kQUVXzFEghPnpLGL8dPfzE6HhEv8dW6Cdx12oKf830jGAAGYvfyzi7l/p7if15dL3XhKaabJxd9zP7muHn/HwZ6Cs3WgqbCv3A== 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=rvBG8V69h6zXMPrV9hjlB2iiY+fMfBPTJTgcA0tedvU=; b=ZFe1LCgVY0EDnaFegZIJ9tjyEDmhYLxyIewy1eN1mBWehUIA+z7VBARl2acYYRDzqC96gXbVebnDmzgkB7ohfpV09ay3cJzipv/l+reLt4oxyBJGjcEr9MqUTMLVr6acLWAPcW/bjGsL29LpLyxvP6prK7m2uhIi8RWEZmoz1Rj5uEjB3GJ9bkffvjfd/mQgf07/2XvyumAiQ1QsZBIUb7v57qGVocBD6lt7y4pwc2wsBwef3EOBqi18MNgjtN0L9w6L2j6DneDQ6MRRTDAmz6FhHl4JXQ7xqw9bDfqOxZyYcHjxwfzQly0cbnFUeABPpbpwgd/FA6LNxt7sAD1f9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by BL3PR10MB6043.namprd10.prod.outlook.com (2603:10b6:208:3b3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11; Wed, 14 Dec 2022 20:08:09 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::ee70:1952:4416:1bdc]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::ee70:1952:4416:1bdc%5]) with mapi id 15.20.5880.019; Wed, 14 Dec 2022 20:08:09 +0000 To: binutils@sourceware.org Cc: Indu Bhagat Subject: [PATCH 2/5] [2/5] gas: sframe: add support for .cfi_b_key_frame Date: Wed, 14 Dec 2022 12:07:53 -0800 Message-Id: <20221214200756.1234528-3-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221214200756.1234528-1-indu.bhagat@oracle.com> References: <20221214200756.1234528-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW2PR16CA0038.namprd16.prod.outlook.com (2603:10b6:907:1::15) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2158:EE_|BL3PR10MB6043:EE_ X-MS-Office365-Filtering-Correlation-Id: ebcfb444-0a8c-4d6d-7c30-08dade0eebea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ibg2ycLcoKZJuyYwhM0mV6coahUef9b5dJ5RrDidjvcloiKVHd9DLoRimbjORV4k8eoIPFg7SPg6Ij/EqWqvWVyJNRkzX/1TdoqJpJEsBeEVQMTwe4Mt8lUXXeYGMXIa0Y0xJkeo0okcAG1/Qoz8XJi8QkoXInkvkNtz47UgcSpbiUjcguO7B96WcQ5Vjy0d2bheSd3x/wfIj//LNNNl8XpDjqXxaob1rprxO6DbCehGuqJpq/iJlL2aJxNB3Ka+ucfZmLM6+4TDLDb4FovY7CeZ07UlpZQwWGRAdMckVwu8QTziCMIyru0JU6lD9O/JIEkCPw6bIcMJR//FsSqjX+kXowXzKeeiUdJqclVW9+t3Ihix3+xB2CGqH2pGbD2deHKTNkR89BYCAPX2KN36wgn/ck4m5yD3Tl94Pab8CbZzfn3DrUwLuUyHn/MvvXA0SyLzYVgC/LJ5Voi2DVNeLL8V3+pmcI8Eqg33lJ8RpUaRF32jiWKigdKOSKrbm0IK0iVirj6InSnt743198ux+3mTyWyTiIU3Sj5u6HODwbPh3hOuyT/458Yy6zOwU1elCTNhPFui6wk8olnjSGhHmBCpmOP/fKI3TkqWtRVLbLqezCpEvrIINQmSpmy9ZEpWcRHzXP8hYNAOwWC+SVe7cWQ++ShPvBRSuVVNqd2MfjDq+dRtX4sRwgKc+CHfdiJmiKuenIUJDq7iXmQ1Xc2kuA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(346002)(396003)(39860400002)(366004)(376002)(136003)(451199015)(86362001)(83380400001)(38100700002)(66556008)(44832011)(5660300002)(2906002)(66476007)(66946007)(8676002)(4326008)(41300700001)(186003)(6512007)(107886003)(6506007)(6666004)(2616005)(1076003)(6916009)(316002)(478600001)(6486002)(8936002)(36756003)(142923001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RmylkBCiInlgxUtKOGdJ6V61YDZ3xek/RHiAC9qBbaBn13qYVgoLcdtPZat+kdwwdoKu4VP82awyklYPlSG6waJt3LmVx9k9S1AmiS+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U9Xwf+HWOJicndy7ZqXmBwbq4E70PM9FVVaRpa6idD4QbqOtC//TaPB4/ZQ0i92ed99DiIBtDPASqNPnX72XhaueiSNytcPashAS1AmU/0aVwOteBvP/XLnCXuXXbOrxdDZf5v2JXJLtL9qSkyobXOdA0FVporg26djjNbYlhggatqJGlijYzkeb+yDPVRKNOjUY8khgKctm63oTb72ZvOSiG23spuQj/SmFKVMKGbzEUf/kkYJYi8JI5wbwTyOAs0y/cu0LpR7K80ydAdppX/6VbcjJKu6NuKYcQB5pW2jn4AsCZrqSIH6TX25W8sSc66K/70Go6WKZC6yU7Iezct/FAX9XX6R33WDAriiTohkHKfQJjrJU3ojVUrH1AhowDHgImjdENoO4/8QRaAfCpNsNX02xlGhymIgjM59xuU40/XklDcg1iObqTV6V+VWeAMV0gymDetq0G7tFs1Pk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebcfb444-0a8c-4d6d-7c30-08dade0eebea X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 20:08:09.7611 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yfAjJVc4PK5/qURIx5upSprV4ZYu69scaHDHCLls7nexzDKXbzRgmUyjlga0sEqgupPY2jESCelcI58S7I8brw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6043 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-14_11,2022-12-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212140164 X-Proofpoint-ORIG-GUID: iZjRwOtzbnRXKQOx6tAxL1jkWFQRsu-V X-Proofpoint-GUID: iZjRwOtzbnRXKQOx6tAxL1jkWFQRsu-V X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Binutils From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752221474233319956?= X-GMAIL-MSGID: =?utf-8?q?1752221474233319956?= Gather the information from the DWARF FDE on whether frame's return addresses are signed using the B key or A key. Reflect the information in the SFrame counterpart data structure, the SFrame FDE. ChangeLog: * gas/gen-sframe.c (get_dw_fde_pauth_b_key_p): New definition. (sframe_v1_set_func_info): Add new argument for pauth_key. (sframe_set_func_info): Likewise. (output_sframe_funcdesc): Likewise. * gas/gen-sframe.h (struct sframe_version_ops): Add new argument to the function pointer declaration. * gas/sframe-opt.c (sframe_convert_frag): Handle pauth_key. --- gas/gen-sframe.c | 26 ++++++++++++++++++++++---- gas/gen-sframe.h | 2 +- gas/sframe-opt.c | 3 +++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index f31a66da377..5a642f9a683 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -106,6 +106,17 @@ get_dw_fde_end_addrS (const struct fde_entry *dw_fde) return dw_fde->end_address; } +/* Get whether PAUTH B key is used. */ +static bool +get_dw_fde_pauth_b_key_p (const struct fde_entry *dw_fde ATTRIBUTE_UNUSED) +{ +#ifdef tc_fde_entry_extras + return (dw_fde->pauth_key == AARCH64_PAUTH_KEY_B); +#else + return false; +#endif +} + /* SFrame Frame Row Entry (FRE) related functions. */ static void @@ -253,10 +264,12 @@ sframe_v1_set_fre_info (unsigned int base_reg, unsigned int num_offsets, /* SFrame (SFRAME_VERSION_1) set function info. */ static unsigned char -sframe_v1_set_func_info (unsigned int fde_type, unsigned int fre_type) +sframe_v1_set_func_info (unsigned int fde_type, unsigned int fre_type, + unsigned int pauth_key) { unsigned char func_info; func_info = SFRAME_V1_FUNC_INFO (fde_type, fre_type); + func_info = SFRAME_V1_FUNC_INFO_UPDATE_PAUTH_KEY (pauth_key, func_info); return func_info; } @@ -285,9 +298,10 @@ sframe_set_fre_info (unsigned int base_reg, unsigned int num_offsets, /* SFrame set func info. */ ATTRIBUTE_UNUSED static unsigned char -sframe_set_func_info (unsigned int fde_type, unsigned int fre_type) +sframe_set_func_info (unsigned int fde_type, unsigned int fre_type, + unsigned int pauth_key) { - return sframe_ver_ops.set_func_info (fde_type, fre_type); + return sframe_ver_ops.set_func_info (fde_type, fre_type, pauth_key); } /* Get the number of SFrame FDEs for the current file. */ @@ -544,6 +558,7 @@ output_sframe_funcdesc (symbolS *start_of_fre_section, expressionS exp; unsigned int addr_size; symbolS *dw_fde_start_addrS, *dw_fde_end_addrS; + unsigned int pauth_key; addr_size = SFRAME_RELOC_SIZE; dw_fde_start_addrS = get_dw_fde_start_addrS (sframe_fde->dw_fde); @@ -575,8 +590,11 @@ output_sframe_funcdesc (symbolS *start_of_fre_section, /* SFrame FDE function info. */ unsigned char func_info; + pauth_key = (get_dw_fde_pauth_b_key_p (sframe_fde->dw_fde) + ? SFRAME_AARCH64_PAUTH_KEY_B : SFRAME_AARCH64_PAUTH_KEY_A); func_info = sframe_set_func_info (SFRAME_FDE_TYPE_PCINC, - SFRAME_FRE_TYPE_ADDR4); + SFRAME_FRE_TYPE_ADDR4, + pauth_key); #if SFRAME_FRE_TYPE_SELECTION_OPT expressionS cexp; create_func_info_exp (&cexp, dw_fde_end_addrS, dw_fde_start_addrS, diff --git a/gas/gen-sframe.h b/gas/gen-sframe.h index aa8be5df457..590bf7b505b 100644 --- a/gas/gen-sframe.h +++ b/gas/gen-sframe.h @@ -146,7 +146,7 @@ struct sframe_version_ops unsigned char (*set_fre_info) (unsigned int, unsigned int, unsigned int, bool); /* set SFrame Func info. */ - unsigned char (*set_func_info) (unsigned int, unsigned int); + unsigned char (*set_func_info) (unsigned int, unsigned int, unsigned int); }; /* Generate SFrame unwind info and prepare contents for the output. diff --git a/gas/sframe-opt.c b/gas/sframe-opt.c index f08a424fd88..cf7ca5c1893 100644 --- a/gas/sframe-opt.c +++ b/gas/sframe-opt.c @@ -95,6 +95,7 @@ sframe_convert_frag (fragS *frag) offsetT rest_of_data; uint8_t fde_type, fre_type; + uint8_t pauth_key; expressionS *exp; symbolS *dataS; @@ -116,6 +117,7 @@ sframe_convert_frag (fragS *frag) dataS = exp->X_add_symbol; rest_of_data = (symbol_get_value_expression(dataS))->X_add_number; fde_type = SFRAME_V1_FUNC_FDE_TYPE (rest_of_data); + pauth_key = SFRAME_V1_FUNC_PAUTH_KEY (rest_of_data); gas_assert (fde_type == SFRAME_FDE_TYPE_PCINC); /* Calculate the applicable fre_type. */ @@ -130,6 +132,7 @@ sframe_convert_frag (fragS *frag) /* Create the new function info. */ value = SFRAME_V1_FUNC_INFO (fde_type, fre_type); + value = SFRAME_V1_FUNC_INFO_UPDATE_PAUTH_KEY (pauth_key, value); frag->fr_literal[frag->fr_fix] = value; }