From patchwork Wed Apr 9 14:01:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Karpov X-Patchwork-Id: 110115 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 44128385C41F for ; Wed, 9 Apr 2025 14:01:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44128385C41F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=microsoft.com header.i=@microsoft.com header.a=rsa-sha256 header.s=selector2 header.b=j4ZNZQ4T X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on20714.outbound.protection.outlook.com [IPv6:2a01:111:f403:2608::714]) by sourceware.org (Postfix) with ESMTPS id 57AEA3858D39 for ; Wed, 9 Apr 2025 14:01:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 57AEA3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=microsoft.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 57AEA3858D39 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2608::714 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207266; cv=pass; b=mrYYTCfRX4PHTOMlBcMFtVOc5Y/4CeExbVGPCP9f/+xQH5B2+MZS0BHIQGLDKAEPcP4afP1xn8nm5wYY9Tewo5R/0MbtnsQ9+cCXU7loUi7h/OwfFfaNYzVtT7Gztv4MNxkq3CGn0LAMvp+sFbRCovyCkY+6xg7+Vhx/CMmV3Aw= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207266; c=relaxed/simple; bh=sQlx3LNatcW47loFIM87XgyE4ah0Oz4uP9kSOjEYtJ0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=c5Azk8OmemMBbW4+RYClZJyERhvMkJR9DJrUmYwK3PXZel3BcLqD2vEhVpbpkfcNcS1o2h6UFvlDCQU0yVwBt19Www64JDjO+winS+lKlLl15lf5cm29HX1Ja6WgUohWxvLDpPDa5U46MGBFkVIRvlxsAUSqW04vq08M8tL7sUQ= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57AEA3858D39 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VlaIO+p9Oeptu6lsNl5fls4A3YoONGZTFy0428M/Nutoz557v0cangxLhFg+uoRiatpsOq/f/IDmJ4H55BITcYQPBofFSJWCgX1EDt9zEcOEO44nKRs0Xz4g3xpwg9VWSIx6vnFFSD5N9V/gzUryPox3jvucsNMtAkCGFirmhmwSRu1Zowas53t2XFFl0I6n/e9aVlU6KfK7WGcGhRODGSBgfrYAcSU3xhfn0TF4X6R2I7onHqH7QTDPlCjiZP/137Au3whsnjkXmQ0/d86hAO+Pw2kxe6lqv/AWrZYudfzNQCSjE+Ed/OJcyMmxUsnaVlfn/+N4XJwtTYdVZyztgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jaBYwjkB6uMu+vImBlCe2ju3O93pg1L6MnbegLXv4So=; b=mAzDic6iaEEEmw0PQlRGTpJ2NBXj7UNc2vsQSRrO4lDv8yXwnZuUHhRpGR1yvVzZpwUriyxE5Na8qIXWwTWnSwU0Dku7pmNFzYFeJWgLKqjFB8os4p1EMu1fJ9BvPIs5UQGjNDsaiBZe71KKBoPf4JNrJIDPAB/GZc4GLx8I3bpLZDfKWqoTjb+vd9qhMSfHHxwHzSV9peK6YcbCd2ED/DgUOdqXE/b5ME8xuUbrhPRlWcuzBor/RvuCVAiox7kXrfY1Lg/vzHucZhSSD+zJhhO62Jkjtd3ktiEUTOOAVRoLK9y0b8e9leMYTuyzX1T8gjk9egFjDwZGrrKV1qZe7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jaBYwjkB6uMu+vImBlCe2ju3O93pg1L6MnbegLXv4So=; b=j4ZNZQ4TlJKhVWR55bDtnEOob5Hd01lnXCchLXCpbG/ML9FN2r8iBLAPuNkd1mswNZFAuw42+mxET6yGBZ0Z+OVix11HHmzJKqCshD0N0XUGYkFvciuWCxyQAXRp+yVcz9his8qGVUX5zrL+ekeIyb0aXq1VGJgovf7qHS+s2IQ= Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com (2603:10a6:800:270::12) by DB9PR83MB0921.EURPRD83.prod.outlook.com (2603:10a6:10:5ca::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.15; Wed, 9 Apr 2025 14:01:03 +0000 Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb]) by VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb%5]) with mapi id 15.20.8655.002; Wed, 9 Apr 2025 14:01:03 +0000 From: Evgeny Karpov To: Binutils CC: "Richard Earnshaw (lists)" , "amodra@gmail.com" , Radek Barton Subject: [PATCH v1 1/7] Adjust pdata function table entries sorting for AArch64 Thread-Topic: [PATCH v1 1/7] Adjust pdata function table entries sorting for AArch64 Thread-Index: AQHbqVfU9RkNno6/N0uAFSl3qCnAHw== Date: Wed, 9 Apr 2025 14:01:02 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2025-04-09T14:00:41.054Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI2PR83MB0718:EE_|DB9PR83MB0921:EE_ x-ms-office365-filtering-correlation-id: 37b86e42-cf8d-4fe4-a3b2-08dd776ef6f7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?sNg+mcfIHuUHuc+FXv1hz5NCn7?= =?iso-8859-1?q?EdlMwbQ0RJIAx0fAvH48i7FhjuSqjy2XAwcr1JYNyra2fBnD9udF+nqL4W0Z?= =?iso-8859-1?q?CsSXEI033ZLGQMelpD8+eBVZoZbhARzXPdJMghhSzak+UkItAD7FdmxvmmKG?= =?iso-8859-1?q?o2x1KYNCIfoDg62aWpeEVI0zkHB7g2Png2As9zRrxngzgumJSi++Z73v6wKw?= =?iso-8859-1?q?QDtVXVn7WniTFw8zBfGbDy1K5XLr7KSwL56t5ZuXMC4CJcy9pW8A5Thm1I9F?= =?iso-8859-1?q?Gf5RORa+xWRL7f+j924JlfotZCUYwHyWMlXYJFMf+VaLw13UdYJioD0i5UG+?= =?iso-8859-1?q?OH8RVRkMQZH+w1QSgodKycVURpCuyMWp9mZAkxUzI9vVdKCtEt0U34kH6jfv?= =?iso-8859-1?q?6aMK12faPjZInW2MfbcCy9waD9G0ibitkQ72mp96DkDxsBqvFn7D2t+1wFxW?= =?iso-8859-1?q?QYVZqIii8W1ZTE1UXwJ2YdNHAX/VQGZfBS39szBKvS8uSLZR9dE7TGNuPOiw?= =?iso-8859-1?q?yDgjkpMavy+QY4NUO9W6VIrRBmyfZ4Zv+WFjUdJv5pzKE2T05iOS8p4LmFg/?= =?iso-8859-1?q?nTgTjCO7BCUba+ACX1eutW7r5gb17cj6Ukr1ARTBscW+L1xWbr//GlaPhE8P?= =?iso-8859-1?q?O51SLpTwGmRtKn3UFjlZFjN8RbZo78tZYF+1pKorsAUc2T//brbVThZ/QFyD?= =?iso-8859-1?q?LE5q9v2oH8emRHuraIQ3fT+DcsmjHZBZ/SoWbGzsm06GP0r/D1oBY7Rkpe64?= =?iso-8859-1?q?P444btKt3BudOSBdILkvRGB1Zt3//lzP5Bs8fwyTrzn/NjBjcuckMwTyeGNv?= =?iso-8859-1?q?JEHbEDNNiLfv3nlEYdcsB3Nk9i395anO6aQBuWCS53XqPYoIDmsb1BOFOdzP?= =?iso-8859-1?q?J3U8mrlqX8KpkMA2KZo3xa6/nEOc8XPLX04XialDW2BYt596xn3zgyEVbFgl?= =?iso-8859-1?q?FBEF17FjjJRXBNt6KHI/iBMc6mU7+8ZPHYpWlhGbPwM6CT0py4bd7F6C79ul?= =?iso-8859-1?q?Ogio5Qxpa13SuuatwNvU8+9LyMqmpo74xF/kshdRGFO8/Dolv6Iy7G22zMKu?= =?iso-8859-1?q?W7MdBU2OQGVmdP+QnKLNn188t27hcIchKC6I6xRqdSqCVZLF73dyVZt01GBP?= =?iso-8859-1?q?CViVyaiDla4TYDw+l6VbQKjpNBDYv+cTATysFt3dyamFXCjEqwk/xTN4nF42?= =?iso-8859-1?q?O6r3Pgrgyf3TLWcM9K4r+uIrdqP+Vs51yrDWKv30EEisvxnOZ6aNNhCUbiRF?= =?iso-8859-1?q?r3KR/v2J4VqfS466pyzPgijtf+vt1d73MnrfiKTepkGGm3pHZ/mBSU/rvasz?= =?iso-8859-1?q?4qGVvdf1RjkD8BnH1AUbrMWaFX6IkdcI0vaaWMfINAGNp5hfJmX9MBEgPML8?= =?iso-8859-1?q?dby8jp9hMofPx6k0XB2ezBicWSBoUTazZDAfVsTxILpoU1Un9XJBBbIDneXo?= =?iso-8859-1?q?V//KwVfpPBcgcSesvp1sVkRiXwhUUkIMiZiSMHMtx+jHY=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI2PR83MB0718.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?ovxXewgb0ZsUtpyjTjBa4iF?= =?iso-8859-1?q?MysvJniguc9aHhLeccg43nPBGl36d38/+Ft9QSdSJ+iFY28q3L/YrzaRlAST?= =?iso-8859-1?q?lmed24426iPRr6JXo24j4mvsOvNf96rBARt2ajiSS6dvy+sDTDw6m+a4ynHe?= =?iso-8859-1?q?steluqNAAZQ1MLflexVCnWUHLsskGD9VPGczp05sgqlvMp1/USAxcAZ/rTQY?= =?iso-8859-1?q?w8F3Nqjm/WCusUHszkCF0odicFWWiKCdGa2YMQQzpOxoudbZKpeOQmysKxsB?= =?iso-8859-1?q?kz0WbHkk7PL6Yqy7DG8eSRS8l7BpqlQrw7Ks58ezWMIUPwLDQC4J4svHIr0v?= =?iso-8859-1?q?0NWYzvcYBZekD8AVk1KxIRAjWgyLw98eC+S0jIlTQtbq2JIVT719kZweHZMB?= =?iso-8859-1?q?B5DHECsTv+JPdFmxGbTD1Rd6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5Z3+Svk9BctLQ8fFjo?= =?iso-8859-1?q?YvchR0ep9/UJagQmG54ejaRE8Q4SVU5oe0CJkYHV8riXrtem5vWT/IuRGSEf?= =?iso-8859-1?q?5NSUQeDcMuQv33hjRjIQ3kQiMMc56XWQQkRUJSAQvlsxoGtsCcwWNs0lx6dZ?= =?iso-8859-1?q?En7H5w/xJdk7W4ZoWr+oGrzEIbXHJynxCz0BMdCUVqBUzeT5WHzKZLkallk3?= =?iso-8859-1?q?vguBowYCKDb3SD4qPkFwBc5oGlAWElN8u500DMhGpsdfSsNvR6CNTF68PAwA?= =?iso-8859-1?q?RXS3yJEmrYO02LMTOiYefQefAqq4h4KqbiYQbt43hxOHZRBt4VQFibSx/NlW?= =?iso-8859-1?q?ESl52TIs4SOM276Zi?= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI2PR83MB0718.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37b86e42-cf8d-4fe4-a3b2-08dd776ef6f7 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2025 14:01:02.9944 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: XAbYU7bCPytVDj0leJ3fTHWYYzFFhZZEMFDpZzOKbGkpaKGmgO7CEEzBT34KIiJzwswhsaESPjcRf0mBTOZs0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR83MB0921 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org The .pdata section contains an array of function table entries that are used for exception handling. The entries should be sorted by begin address, which is usually the first 4 bytes RVA in the entry. Entry sizes are different for x64 and AArch64. This difference is addressed in this patch. bfd/ChangeLog: * peXXigen.c (defined): New. (_bfd_XXi_final_link_postscript): Use FUNCTION_TABLE_ENTRY_SIZE. --- bfd/peXXigen.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index 9938108ce6b..3230f465d63 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -4655,6 +4655,13 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) #if !defined(COFF_WITH_pep) && (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) { asection *sec = bfd_get_section_by_name (abfd, ".pdata"); +#if defined (COFF_WITH_peAArch64) +/* https://learn.microsoft.com/en-us/cpp/build/arm64-exception-handling#pdata-records. */ + #define FUNCTION_TABLE_ENTRY_SIZE 8 +#else +/* https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#the-pdata-section. */ + #define FUNCTION_TABLE_ENTRY_SIZE 12 +#endif if (sec) { @@ -4664,8 +4671,8 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) if (bfd_malloc_and_get_section (abfd, sec, &tmp_data)) { qsort (tmp_data, - (size_t) (x / 12), - 12, sort_x64_pdata); + (size_t) (x / FUNCTION_TABLE_ENTRY_SIZE), + FUNCTION_TABLE_ENTRY_SIZE, sort_x64_pdata); bfd_set_section_contents (pfinfo->output_bfd, sec, tmp_data, 0, x); free (tmp_data); From patchwork Wed Apr 9 14:03:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Karpov X-Patchwork-Id: 110116 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 94F083851AAC for ; Wed, 9 Apr 2025 14:04:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94F083851AAC Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=microsoft.com header.i=@microsoft.com header.a=rsa-sha256 header.s=selector2 header.b=Q+RmV53A X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2070d.outbound.protection.outlook.com [IPv6:2a01:111:f403:2608::70d]) by sourceware.org (Postfix) with ESMTPS id 5CEDC3850225 for ; Wed, 9 Apr 2025 14:03:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5CEDC3850225 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=microsoft.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5CEDC3850225 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2608::70d ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207411; cv=pass; b=JeNXMZeMwzy145UThaS+d/+QHSnS+Ek7tchIaBAzEhky3dIb+7/l5ZbTvvrd9HR/L2gfJAxHIfmfRIyPhby5zFvUiDwvu5XBw4ExStc2BQhJubNrAmpWQO6zho2kD32/IEVgQSiPVo9tebp3B+b3+2/Suka/cp7CVaJLqCtuoOs= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207411; c=relaxed/simple; bh=BGTO1fc3H41woS02Om+bwxFkHg3YRG9qyF/mPA+gdGo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TK6zugMgNx8ZjHXRDPmCo5gh0eMB9lnSF1VKPul8VeTpbu/vudpoVp1ej4lfKeau2uLn1c3/9ImGkKz1BVWhh6Z5WadhGb8qBvAC3ZRwDwdQjBU1W6iapKXpdWv5EOc0dwbT1E6REptwe8cwR0OMZyP7UwUFYL1K9RfJnrvPUS8= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CEDC3850225 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kE3qoy6sYlksXkwEVZixWi40BZuRwxdbNrBQi/lXf56DWqBsyfLaCx6tQeySqAGYloquWeCX3V4WfNQxj97x5ZsIx5C5JxM5IcvCO/8CApQRae8dI2po4Sq6WJc9RlOOTl0OKrp6HjWdYhwdQV0CT2imumG1dbYoVV7yD4nIEnf9/JuGnSx/7QmIN4k129xlDkywveIZLJrdL9HVmH4gE09u92DQ/UMngnAjMjQm5KlPPlKP76WGzcPjew9DSjnebAJ06AnbLaj2Z9rLsxElAJDMBcxo7ngKoHRnyWKc7L1C/t0hQqUO9ZFXdIyrwjg/P7n0KJEB9+aGGAiq/JP7GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=3+1kfz6fN/b2hTb/bCJHcVsyLw/10Qei3nsTBILOIvo=; b=UpPTJAvry05vVbpqh+rCzBV9qtKpT0AgkR40sWUs8UrdyLNZYnnxlZNanblEn5ntRi5m1O0E8eqLZT6YXhoF7rAb5DTaSjgBwCKAaUA5paQre08piL+T4N+jDuH85UQw6zUCRX6hs3y5OMPaGNYFg4oSWG8PI8KgDe/Yo0DPSMTb1EEdd8DWFob3Ooj2C4F8WNCUVef/udemkLrw6GcVlkLPBLTb5hdoueOKEw8lrM/zKWb+7LCslSI5hQRfB6Mc+mnk0T/1kHZERCx7KuuhbYdah7CyYebecDWDsgLRXQkq2FOk1fm6wjd7XRtIicBuzjD5Bn6AvA9cRhhlqqmUIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3+1kfz6fN/b2hTb/bCJHcVsyLw/10Qei3nsTBILOIvo=; b=Q+RmV53ATFWN47taRolE9BPUsstsc8VWaP9VlbBypFWWfwUZiQiuiVRf381wuq7rty7KBL6Q3vV3CDURp4tPLuXbmgFft+acK/fps1o1cY/Jtvi5/2rkHi0jG6ZMvUiU9dHbUYhveQwA+xF1g2FBgRjvVu3U7vq1pvuORJnKGKQ= Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com (2603:10a6:800:270::12) by DB9PR83MB0921.EURPRD83.prod.outlook.com (2603:10a6:10:5ca::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.15; Wed, 9 Apr 2025 14:03:29 +0000 Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb]) by VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb%5]) with mapi id 15.20.8655.002; Wed, 9 Apr 2025 14:03:29 +0000 From: Evgeny Karpov To: Binutils CC: "Richard Earnshaw (lists)" , "amodra@gmail.com" , Radek Barton Subject: [PATCH v1 2/7] Define unwinding and SEH data structures for aarch64 Thread-Topic: [PATCH v1 2/7] Define unwinding and SEH data structures for aarch64 Thread-Index: AQHbqVgrDxQB6k42yUalcR68RhiKpQ== Date: Wed, 9 Apr 2025 14:03:28 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2025-04-09T14:03:07.188Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI2PR83MB0718:EE_|DB9PR83MB0921:EE_ x-ms-office365-filtering-correlation-id: 4aaf1f4a-f101-4ddf-14ea-08dd776f4e01 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?2j6HMFzv2Z3Nmic62EV6Mt6sVq?= =?iso-8859-1?q?Zqr/693vInTn8QsEmtQLeV8J6YUCTcXeLhXTrtH0br0MBK5gJy0qTEklut+z?= =?iso-8859-1?q?IpF+k1N09zviz8rYCUkZpNn9pT/BhhTLLe0H2XvJqODTHmJkhi5+Bd9SnrH2?= =?iso-8859-1?q?08Jvmc+jwyQgUKhem2d135u/pRC8N1mfdSYlpDN0xiTtU0oDeCZ49aNeLmsZ?= =?iso-8859-1?q?QSZrFusE/xyPc+2mkN3hXqsVG7BHAhmOB3BK97dWtITwpNVZj+AN00MeyevT?= =?iso-8859-1?q?thjLeBtLxqb9w9p6dgmdw1neizTQOe+jyX4LYRriHDTzwudqN2ipivTereVR?= =?iso-8859-1?q?fWpeXoSIXxfkTTQ/Ww2mWZLEhV4h5aqu1m3kpfK8sMBTllwNh4KRLaneMSws?= =?iso-8859-1?q?24KMW/pHRsSHViKqYBqw6VmOBwgnwp2PVNFzgzl87J9ZSSeNY/Il4Hf8j6Nx?= =?iso-8859-1?q?2RneAur3L1UkQycr81XAsZOdYWDCtR3vLArs1meMcuncYCfwsYCIoPTcxVej?= =?iso-8859-1?q?VKiftmjQ2qfw08SWGMa82f721DRLNUs9vL62zORCdYLKpaN+JUSTotLTwOEE?= =?iso-8859-1?q?a07DeAbAe8RQi3X9k8arhPKVxmW/M7ol7b/LDeG4vf0/BN7uLhhU4j+tniAn?= =?iso-8859-1?q?GmWAh4OFwFcTvL0Ra4itIjAekCTVLWQUHItSwGybm4U1OpOJb8MliiQFUNdy?= =?iso-8859-1?q?VXpyVrt2uGQSO7yRTtMKEd4r3ubgIjGv4pHjN6t9p5x9NRAo9pys6fjnGOBZ?= =?iso-8859-1?q?RzpNsg60+n91bYBVTfU9dqP06u28v41QhlEBgyyX6WQR/H6UpJYqrg+b6GZ/?= =?iso-8859-1?q?2wwhO2WePZ1mYzTCuhnHJpg5UU2Zd71F4Pn34OeljE43mXGZEqOMQMXelmGX?= =?iso-8859-1?q?iFaq/jpPcPmglBm1JlKj+BdowORi11Puv0IMNZtzOzO2nYCWTpX3kgcRA967?= =?iso-8859-1?q?CWZrQtcXUWTEpawgp2C5ToKSvUSqeyJwnsZsjMCGaXQbAMkUAynD2ZsXKX7d?= =?iso-8859-1?q?20ngarfawFAtocClucbeqm8Jy6oUav4ygoujHhFaOM7gt/PWbd+y9EVqFg1X?= =?iso-8859-1?q?XPK0f9kj7sHtZjuOL5wirYbdKHDl4Ehoqm5zAm3l4ifW1hOZ1pDfC26xGbTW?= =?iso-8859-1?q?ZuDuZvTAYHrPOQDrOxCFSfYRxkQBtNZJk0ttSXB/kPdPQd/SdqMziykuIWzm?= =?iso-8859-1?q?gzS7cadTrqYSTdNbsqRhsnY7dqEygXzgXbnlK1wPjhMZyvzbhG8TTKVksQR+?= =?iso-8859-1?q?1xONPV0uSaD2zY9eii1yUpE97BGNtFEQG6MFaMfAeAJ1Ub/zHJz66JAzj66B?= =?iso-8859-1?q?Dr6O+zmaDp3MDt/uWEyj9H8DJ47EzPkNt+WqZ9Hu7gC59x7g4zzbzgWbaLfY?= =?iso-8859-1?q?qo3lzc7Gyut81NgWu5WGE1Mv3ElGJKZEcGolJPvHEXxsueiux9i335xoJrB7?= =?iso-8859-1?q?guUiJNDgDkE7ZH9TBy+XAN57XKczJrBa0TfA5RV0GPtzYXTGOXqcC3vtxD4u?= =?iso-8859-1?q?j0+eeNIIzCj+PfpZ3UmPDv7q5nrbBCwCxfANEKDiM9QucxwkA=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI2PR83MB0718.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?QXHB7AhqWNgHrY7FE1YR/G0?= =?iso-8859-1?q?BCAA+QNPbwuZ0rf+m9gRH7DzylmJBMFGFoskRj4JkmOx9nVrl9gSnnmrWTaR?= =?iso-8859-1?q?7ofUjYE2RbQ3vx56n2ce5lOF0hLCcymaHhh/bWvO4YAxyy39tMaG7cRy7cqY?= =?iso-8859-1?q?d28owlmW9ltCjmx0kfr3tElBKd5oDUf8SwC2L6U78oJ5vAWImu0Gftz47Tgr?= =?iso-8859-1?q?CU01m2tRacRbxTBxulfMSyV+g2PLG9R0++I47oCMttW4oRmBzZeoF5+zQA4T?= =?iso-8859-1?q?tFsXL2Ns/f42x8j58tERY2ziIQzPuEGxo4OlKVGFWl4MF51UWHtzOewDNun2?= =?iso-8859-1?q?xkprqyhCsurWtOGx1C3HAuJML2V9Asrz08EPoGLDqTfqf4lnMbO1pg9oE802?= =?iso-8859-1?q?t6riaYVCxfgQKT0eA8ioFFtad26NJ0yvfsFxUBf0YfrbDZ+SpcDvDfwYWmRv?= =?iso-8859-1?q?HtRIzWuG5SiFKQaep5BnKDyGyDe3+uRUWdMdVlnIAv0MWoL7I1Lc3w9tg4qv?= =?iso-8859-1?q?L58BZPJWff82s9lP8gqJ9MHLt6k0JI9xvImQ3SuMMKk4HYThSFnXizDHvx1z?= =?iso-8859-1?q?merrU4G3h60qoHXvzFeU9NoCZwwz2B1jkANCk6fd4clcTwXcTRAZZj1u+Gff?= =?iso-8859-1?q?QeCIR0J8V2kiYf3m5ODPbZ/VHnLZhWZTQp1oHEYmL5Xzk9tcLmGl2TmOetkp?= =?iso-8859-1?q?EpqUxsMTNlPyOROKLy6n+7tbFIwJt0uFj5i9mAHVG1JMkvsLujzGHAa0GK1k?= =?iso-8859-1?q?XQDqX+GZXHwRoJt+yYumw0LtnsXvQhDi974LBJtkyWRGKitWWcr1ouSioByW?= =?iso-8859-1?q?rJjnJEduQmVNNXNEYXngBCECONSM5eore9VILA/yBaIpZuYMejgAlOS+UfaD?= =?iso-8859-1?q?U3IF1k7TjpcE2qq4fYxLRoKnq+n0caztqP7dRXqhBqWA6n0sY5vJQblrKmdI?= =?iso-8859-1?q?F3simBjV8tlaXxf6+1vD40JVjAaXMmpvAyYc9igGwmhw8Tnfb0QilLRvaO8l?= =?iso-8859-1?q?WiYspbXGTsBACQxn9FaNs0uvTN5xURV7KRviS6GYgmYzsMpJ88ZEjjCsihbv?= =?iso-8859-1?q?aGZV3VmH9DDaQ/wGH2MGu8iTpFPa3n/Us26edma4ToIJ34HO8exT4X/rzLgx?= =?iso-8859-1?q?RZ8uGefq2wdbZmlqF2jLsSjQpKmQmpflDPAszvJgcf4lsmWVKA1e2bVxnNJV?= =?iso-8859-1?q?NjRfkp2WQs0ZoShRf+YZ7ZBu6UTyEcqcsCDDpSj1+YLV3Nz5pZlX4QjYW7Qb?= =?iso-8859-1?q?47FbWO0gKvArn7Uh+WzKZRLEBDOFWKCZ5mYT8wcMXxXIUg63Wxj6HZdmmYZ4?= =?iso-8859-1?q?teDxc9bjqvwEyqpFGrI8YbcGKtQ2czARJ6kkcz6RSIMMJvGMH0sjHFIeZK55?= =?iso-8859-1?q?Gbe1EmdJvAE5E2oXsGCHz5iqr+L2COfhfnsw5Qvj6MmztoEJ/FDJ+ivby3TG?= =?iso-8859-1?q?YCggu3DywwkSVXNj4mmUdor5FMS5Y4eMdmVBOyT8bXeAKM6xua9msah3hJaT?= =?iso-8859-1?q?1eKMjH55YBIdvgxakVg4ZpHl33vFLcHQSk53F7MTjEtsBZ6zh45Q8ZJBbkeg?= =?iso-8859-1?q?QPUqFkLIKSaFtLGIQpWgl4GXnmyeT2zPzN3GDVvHKp2lAhI4EOeHRwqNOMKn?= =?iso-8859-1?q?+2mu0fbhGHXzpCqZ/?= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI2PR83MB0718.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4aaf1f4a-f101-4ddf-14ea-08dd776f4e01 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2025 14:03:29.0040 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8Wch6aa+pegkbX2hCs+5fAR0YP+WJ4ib59OXk08ziQDniQl/790C6+Icxxv396J+iDOYJdv2MWoouRFvO6ludA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR83MB0921 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org This patch adds unwinding codes and records that are needed to emit SEH data to pdata and xdata sections, and an arm64 context to store data required for emitting. gas/ChangeLog: * config/obj-coff-seh.h (ARM64_MAX_UNWIND_CODES): New. (ARM64_MAX_EPILOGUE_SCOPES): New. (ARM64_UNOP_ALLOCS): New. (ARM64_UNOP_SAVER19R20X): New. (ARM64_UNOP_SAVEFPLR): New. (ARM64_UNOP_SAVEFPLRX): New. (ARM64_UNOP_ALLOCM): New. (ARM64_UNOP_SAVEREGP): New. (ARM64_UNOP_SAVEREGPX): New. (ARM64_UNOP_SAVEREG): New. (ARM64_UNOP_SAVEREGX): New. (ARM64_UNOP_SAVELRPAIR): New. (ARM64_UNOP_SAVEFREGP): New. (ARM64_UNOP_SAVEFREGPX): New. (ARM64_UNOP_SAVEFREG): New. (ARM64_UNOP_SAVEFREGX): New. (ARM64_UNOP_ALLOCL): New. (ARM64_UNOP_SETFP): New. (ARM64_UNOP_ADDFP): New. (ARM64_UNOP_NOP): New. (ARM64_UNOP_END): New. (ARM64_UNOP_ENDC): New. (ARM64_UNOP_SAVENEXT): New. (ARM64_UNOP_PACSIGNLR): New. --- gas/config/obj-coff-seh.h | 148 +++++++++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 2 deletions(-) diff --git a/gas/config/obj-coff-seh.h b/gas/config/obj-coff-seh.h index 598870ae4e0..d82d88cf901 100644 --- a/gas/config/obj-coff-seh.h +++ b/gas/config/obj-coff-seh.h @@ -19,12 +19,13 @@ 02110-1301, USA. */ /* Short overview: - There are at the moment three different function entry formats preset. + There are at the moment four different function entry formats preset. The first is the MIPS one. The second version is for ARM, PPC, SH3, and SH4 mainly for Windows CE. The third is the IA64 and x64 version. Note, the IA64 isn't implemented yet, but to find information about it, please see specification about IA64 on http://download.intel.com/design/Itanium/Downloads/245358.pdf file. + The fourth is the Arm64 version. The first version has just entries in the pdata section: BeginAddress, EndAddress, ExceptionHandler, HandlerData, and PrologueEndAddress. Each @@ -57,8 +58,43 @@ .seh_savexmm .seh_pushframe .seh_code + + The fourth verion for Arm64 partially intersects with the x64 + version, however it has a different extension to the unwind codes. + It emmits SEH data to pdata and xdata sections. In some cases SEH + data could be emitted to a packed record in the pdata section + without the need for data in the xdata section. However, the packed + pdata record is not implemented yet. + */ +typedef enum seh_arm64_unwind_types +{ + alloc_s, + alloc_m, + alloc_l, + save_reg, + save_reg_x, + save_regp, + save_regp_x, + save_fregp, + save_fregp_x, + save_freg, + save_freg_x, + save_lrpair, + save_fplr, + save_fplr_x, + save_r19r20_x, + add_fp, + set_fp, + save_next, + nop, + pac_sign_lr, + end, + end_c, + unwind_last_type = end_c +} seh_arm64_unwind_types; + /* architecture specific pdata/xdata handling. */ #define SEH_CMDS \ {"seh_proc", obj_coff_seh_proc, 0}, \ @@ -87,8 +123,87 @@ typedef struct seh_prologue_element symbolS *pc_addr; } seh_prologue_element; +typedef struct seh_arm64_unwind_code +{ + uint32_t value; + seh_arm64_unwind_types type; +} seh_arm64_unwind_code; + +typedef struct seh_arm64_packed_unwind_data +{ + uint32_t flag : 2; + uint32_t func_length : 11; + uint32_t frame_size : 9; + uint32_t cr : 2; + uint32_t h : 1; + uint32_t regI : 4; + uint32_t regF : 3; +} seh_arm64_packed_unwind_data; + +typedef struct seh_arm64_except_info +{ + uint32_t flag : 2; + uint32_t except_info_rva : 30; +} seh_arm64_except_info; + +typedef union seh_arm64_unwind_info +{ + seh_arm64_except_info except_info; + seh_arm64_packed_unwind_data packed_unwind_data; +} seh_arm64_unwind_info; + +typedef struct seh_arm64_pdata +{ + unsigned int func_start_rva; + seh_arm64_unwind_info except_info_unwind; +} seh_arm64_pdata; + +typedef struct seh_arm64_xdata_header +{ + uint32_t func_length : 18; + uint32_t vers : 2; + uint32_t x : 1; + uint32_t e : 1; + uint32_t epilogue_count : 5; + uint32_t code_words : 5; + uint32_t ext_epilogue_count : 16; + uint32_t ext_code_words : 8; + uint32_t reserved : 8; +} seh_arm64_xdata_header; + +typedef struct seh_arm64_epilogue_scope +{ + uint32_t epilogue_start_offset_reduced : 18; + uint32_t reserved : 4; + uint32_t epilogue_start_index : 10; + uintptr_t epilogue_start_offset; + uintptr_t epilogue_end_offset; +} seh_arm64_epilogue_scope; + +#define ARM64_MAX_UNWIND_CODES 286 +#define ARM64_MAX_EPILOGUE_SCOPES 32 + +typedef struct seh_arm64_context +{ + seh_arm64_pdata pdata; + union { + seh_arm64_xdata_header xdata_header; + valueT xdata_header_value; + }; + unsigned int unwind_codes_count; + unsigned int unwind_codes_byte_count; + seh_arm64_unwind_code unwind_codes[ARM64_MAX_UNWIND_CODES]; + unsigned int epilogue_scopes_count; + seh_arm64_epilogue_scope epilogue_scopes[ARM64_MAX_EPILOGUE_SCOPES]; + uintptr_t fragment_offset; + expressionS except_handler; + expressionS except_handler_data; +} seh_arm64_context; + typedef struct seh_context { + struct seh_context *next; + /* Initial code-segment. */ segT code_seg; /* Function name. */ @@ -126,13 +241,17 @@ typedef struct seh_context int elems_count; int elems_max; seh_prologue_element *elems; + + /* arm64-specific context. */ + seh_arm64_context arm64_ctx; } seh_context; typedef enum seh_kind { seh_kind_unknown = 0, seh_kind_mips = 1, /* Used for MIPS and x86 pdata generation. */ seh_kind_arm = 2, /* Used for ARM, PPC, SH3, and SH4 pdata (PDATA_EH) generation. */ - seh_kind_x64 = 3 /* Used for IA64 and x64 pdata/xdata generation. */ + seh_kind_x64 = 3, /* Used for IA64 and x64 pdata/xdata generation. */ + seh_kind_arm64 = 4 /* Used for ARM64 pdata/xdata generation. */ } seh_kind; /* Forward declarations. */ @@ -201,4 +320,29 @@ static void obj_coff_seh_code (int); (PEX64_OFFSET_TO_SCOPE_COUNT(COUNTOFUNWINDCODES) + \ PEX64_SCOPE_ENTRY_SIZE * (IDX)) +/* arm64 unwind code structs. */ + +#define ARM64_UNOP_ALLOCS 0b000U +#define ARM64_UNOP_SAVER19R20X 0b001U +#define ARM64_UNOP_SAVEFPLR 0b01U +#define ARM64_UNOP_SAVEFPLRX 0b10U +#define ARM64_UNOP_ALLOCM 0b11000U +#define ARM64_UNOP_SAVEREGP 0b110010U +#define ARM64_UNOP_SAVEREGPX 0b110011U +#define ARM64_UNOP_SAVEREG 0b110100U +#define ARM64_UNOP_SAVEREGX 0b1101010U +#define ARM64_UNOP_SAVELRPAIR 0b1101011U +#define ARM64_UNOP_SAVEFREGP 0b1101100U +#define ARM64_UNOP_SAVEFREGPX 0b1101101U +#define ARM64_UNOP_SAVEFREG 0b1101110U +#define ARM64_UNOP_SAVEFREGX 0b11011110U +#define ARM64_UNOP_ALLOCL 0b11100000U +#define ARM64_UNOP_SETFP 0b11100001U +#define ARM64_UNOP_ADDFP 0b11100010U +#define ARM64_UNOP_NOP 0b11100011U +#define ARM64_UNOP_END 0b11100100U +#define ARM64_UNOP_ENDC 0b11100101U +#define ARM64_UNOP_SAVENEXT 0b11100110U +#define ARM64_UNOP_PACSIGNLR 0b11111100U + #endif From patchwork Wed Apr 9 14:07:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Karpov X-Patchwork-Id: 110117 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 323DB3851C05 for ; Wed, 9 Apr 2025 14:07:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 323DB3851C05 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=microsoft.com header.i=@microsoft.com header.a=rsa-sha256 header.s=selector2 header.b=JrllPw9U X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2070a.outbound.protection.outlook.com [IPv6:2a01:111:f403:2613::70a]) by sourceware.org (Postfix) with ESMTPS id 767DB3858D39 for ; Wed, 9 Apr 2025 14:07:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 767DB3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=microsoft.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 767DB3858D39 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2613::70a ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207628; cv=pass; b=Z18rxlH1hw+kewpu5DPItijnQSaWlWLzeGdVmEpPxw5suq7s5oxhX/QZMWhm/pyiAOJeLje+9gFSO0ZugRItVG1YaL65dnJSWpVNIaW1tvMbZKyDONn4U+/MdJTuxePvMoN7737GZO1G/8Bfmu1ZqghW0qAd6SRfUZOn6V3eBPQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207628; c=relaxed/simple; bh=0UW/rs43pAeLL03bVr4r9i0aOYEH2oBgPmr/0UrrPbA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=U3DQnhudMaBgkPx8pk91d84SnTYfYyDqNpKsoz4Cf9sfPyb0d6/olhgIb+xhAU4a8yYXTfh+SD9IoY2bNWUOm9Nf5qxOfY+ZGDb1f1bWgVInp+huwqsOzCEdwK1YYmbIdzTNBd/rJpQ7m2HYb2fh0a5SMir6Rn5PUfTzvViGTUo= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 767DB3858D39 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IZObFFi6M3gTkD/wmIiveOHb+7OB9l8ABLjfJ9ibX9n06rYvtH/aLIbH7uVkzq6BjW7PiiHkZE5ojnCgqxyK2APXhd0YzViuge2vems2z+hCiOI3RVqMO3OQx0iXxQrbSN/Gd6rJ4Czp6HVCOHpqjy7R1/uBAEY1J7BCFDcOjJRbkfx5wpikBzowR+HtIa+0IBNmOl3kazpDfMxMBtkutz94uTKLqKKQo5XpQkGimQEklS7Hjw2irqyBsE0aJCnYkPnVee1fWABSicScrCgHGeBpnBy/sIyorM5Vny5F6l54PrFOFMVuS7DHg5AfO4g2QjKuAIVGGDOffE32jobRJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=7flSpL9F8xcV66hBBETeu1ZC2q2c7rnQK3TNxPzO/aM=; b=iSlzjTu6P8GTmHPOfUNLzeETNuAwerrVy1k9i/UIO881gJMAoZh+nG+RoPP1uzssiP8e5OjJX78QQibWUI6PU6x06yWENPWQSko6YBPLDMsZFpoxn8dENdeAc4rDmgpPX6Jp4/+repSlhp5pzKll2lwJaXOfmUudT2rm1zr96k+rJcdHf5jQktHCC8c0/ps+vX9dQh5RMcsZKg6F19MSzT12NflzZLPWl/tEpnjcZ6Y1XZQIrXwV46+UAIe6E9N5sisdOarSl434hl1d6cd16RumtQ6iC8NVCSPe5m+54COn3iMjVkp1P/HTJp5Ss3iAq2zYvNA8Ji94HwSOh18jNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7flSpL9F8xcV66hBBETeu1ZC2q2c7rnQK3TNxPzO/aM=; b=JrllPw9UfHLRIi5lvAIXtioc5AUpoNz0Om7pgD7ODqGuvvrSA2IGmYkyN8HOB5XtAa+0hmTKS2NRYOK10KNdvwpCPbbtIrZjCsMSmMiWjhFyCy/vUtiBxbE06Qii6mQxqDGQO1HGHZlO6ZQypC5k2Yj+qal0e1gSypTBw3x7QE8= Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com (2603:10a6:800:270::12) by GV2PR83MB0901.EURPRD83.prod.outlook.com (2603:10a6:150:277::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.5; Wed, 9 Apr 2025 14:07:04 +0000 Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb]) by VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb%5]) with mapi id 15.20.8655.002; Wed, 9 Apr 2025 14:07:03 +0000 From: Evgeny Karpov To: Binutils CC: "Richard Earnshaw (lists)" , "amodra@gmail.com" , Radek Barton Subject: [PATCH v1 3/7] Adjust x64 SEH implementation for AArch64 Thread-Topic: [PATCH v1 3/7] Adjust x64 SEH implementation for AArch64 Thread-Index: AQHbqVirovY6BTqWIker5aIMvodP2w== Date: Wed, 9 Apr 2025 14:07:03 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2025-04-09T14:06:41.640Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI2PR83MB0718:EE_|GV2PR83MB0901:EE_ x-ms-office365-filtering-correlation-id: 6178bd7e-1ddf-40cc-3d26-08dd776fcdcc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|366016|1800799024|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?rrTEHlNlfBvzRVXs4Ni1KwetVU?= =?iso-8859-1?q?f2JgOLE/BFvR25e/K1nTD0KF04rdwb7US8nspnXmhtlm9Gu99u3NyTuIzBnK?= =?iso-8859-1?q?VcdV53lh0BEnt+Df0C/X2BP/M00eO1mOu8oKkVrYUVkEyX3RMQns66TY8LeF?= =?iso-8859-1?q?alCcHj8T15Oh4Wz2DyS+fgWvfSxRh5tLw4/0l8CejmAt8fBS+RT4mqQBLN//?= =?iso-8859-1?q?6OCJUNmBkMBlCSYehbZkHR3d9S6XHdOHMoBqcPrpr8xHqkFuqLKezqhp6Rhq?= =?iso-8859-1?q?K3oz+LJR0NzWSFoYb486JJyI9IMlMBlqDcqZ+MiDusofGrCNgWFD6mO44Ks2?= =?iso-8859-1?q?s9RiPcV0fRCURYSJkvQEG/qf4WSLtM45uyLGuVC2oWkUggaGDWOFKj6QQ1xJ?= =?iso-8859-1?q?AtKKdSr6CHDA8+MY+Rmio27PT2Fv9AJ21vh3rKJw1awLpA259kwdRqnpQ2lF?= =?iso-8859-1?q?WxdyZofH6tmDPBNp0oFnYqbMGoNprje8xp+Xs6W9fD/xNgzdbKMB/xiKzwIX?= =?iso-8859-1?q?d98L5u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b8EAALLQt/uBKil+/kNQeYnFSWH/CifOR?= =?iso-8859-1?q?z8093MVMPEefCLoeAwwX3PyFNsHyvf2BK34IumSEWeMl0NYgPMr08r1z7pt6?= =?iso-8859-1?q?E6Qv9ABlLjZwNlz8NtijPgEHZG6Yche/5oS8/EOQBfkN8rWgY=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI2PR83MB0718.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?Qx+fOmZ24O8UVLDWglwnFx3?= =?iso-8859-1?q?W6Px8KQQyGIhx8tgO9Tc5nCQuHXOo/hfP0JednzA4PiGXTt5zUSv2ycSWEel?= =?iso-8859-1?q?s/lPuF4TItcbcHHVo+c15mdrlHuIrW2SoEWHrrSEqjqoPEMyevYC0KpIj4Tq?= =?iso-8859-1?q?ASTJ01/LrtLPCFxN1FIXBxmZZsRYknXr7gf7cRMMTAnN6OnXLoEPai3QwUww?= =?iso-8859-1?q?Z5aYk7SCxolNM0C6XKrgwKDGLcoMvosP28wFPFzm1R2EyWj6NRrDs9bFjnzd?= =?iso-8859-1?q?0P3GAQXnQGLmIS3hfSzojM9I9iHtcyVxkvwRcVACoYnXQP2/0qpg3gnIHWOU?= =?iso-8859-1?q?3kESOv1d3pMb09mbbXq1To4bJIqJSvJ4l6gSC1x9zaLG6mYaitdsV+lKKrHe?= =?iso-8859-1?q?Df+gH1qfPGeGrj/e3rQT+IgYDpCR9GnrXASwVFYNYkYEU+Yse2U8at6Y7liE?= =?iso-8859-1?q?sxrQXFtbd+dVn3UmpRIL2JOrz8LINI1pLHBWUDIRe7vlcwOqW9tRA3a2l0/W?= =?iso-8859-1?q?IAs5W3rkV0wG/dRlD5UBP3uvlbXFsMT6OaixrKj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uaTuU8Bi?= =?iso-8859-1?q?AijaoyyzdXVwPU+YipMIcHnNIZjqXT2XxjmMJ/acmzorBM7R9DYW7/pVoLuh?= =?iso-8859-1?q?+PwPmBwMIjcL6W2mfZ+7QaUsi2YJRrjFNQusEavQGiabPhFMwkmrle1AL9YA?= =?iso-8859-1?q?xBiVeFzpKpa3oI4A2NJwy4rlLYJDYetNcXMqEQvMP8soLgBBUtZrRH3PIaP2?= =?iso-8859-1?q?Ssa8psTxMSmoctgNm?= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI2PR83MB0718.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6178bd7e-1ddf-40cc-3d26-08dd776fcdcc X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2025 14:07:03.4220 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 5yl04yTrPEDvD1Q/640dT6cW5TEhTZGjNEYrkdmT6LD/QO7sHHL38DtdL9AgHoVypRmRRaJNbg5yCN9PF7Uebw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR83MB0901 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org This patch defines the required unwind codes for AArch64 and updates handlers for SEH commands that are used by both x64 and AArch64. It implements encoding for unwind elements that will be emitted to pdata/xdata sections. gas/ChangeLog: * config/obj-coff-seh.c (struct unwind_code_pack_info): New. (seh_get_target_kind): New. (verify_context_and_targets): Update. (obj_coff_seh_handler): Update. (obj_coff_seh_handlerdata): Update. (seh_arm64_add_unwind_element): New. (obj_coff_seh_proc): Update. (obj_coff_seh_endprologue): Update. (obj_coff_seh_stackalloc): Update. --- gas/config/obj-coff-seh.c | 245 ++++++++++++++++++++++++++++++++++---- 1 file changed, 222 insertions(+), 23 deletions(-) diff --git a/gas/config/obj-coff-seh.c b/gas/config/obj-coff-seh.c index 70cb4e4aa64..250cbc236ef 100644 --- a/gas/config/obj-coff-seh.c +++ b/gas/config/obj-coff-seh.c @@ -28,6 +28,20 @@ struct seh_seg_list { char *seg_name; }; +struct unwind_code_pack_info { + const char* directive; + int offset_bits; + int reg_bits; + int code_bits; + int code; + int offset_right_shift; + int offset; + int reg_right_shift; + int reg_offset; + int type; + int size; +}; + /* Local data. */ static seh_context *seh_ctx_cur = NULL; @@ -36,6 +50,51 @@ static htab_t seh_hash; static struct seh_seg_list *x_segcur = NULL; static struct seh_seg_list *p_segcur = NULL; +const struct unwind_code_pack_info unwind_code_pack_infos[] = { + {NULL, 5, 0, 3, ARM64_UNOP_ALLOCS, 4, 0, 0, 0, + alloc_s, 1}, + {NULL, 11, 0, 5, ARM64_UNOP_ALLOCM, 4, 0, 0, 0, + alloc_m, 2}, + {NULL, 24, 0, 8, ARM64_UNOP_ALLOCL, 4, 0, 0, 0, + alloc_l, 4}, + {".seh_save_reg", 6, 4, 6, ARM64_UNOP_SAVEREG, 3, 0, 0, 19, + save_reg, 2}, + {".seh_save_reg_x", 5, 4, 7, ARM64_UNOP_SAVEREGX, 3, 1, 0, 19, + save_reg_x, 2}, + {".seh_save_regp", 6, 4, 6, ARM64_UNOP_SAVEREGP, 3, 0, 0, 19, + save_regp, 2}, + {".seh_save_regp_x", 6, 4, 6, ARM64_UNOP_SAVEREGPX, 3, 1, 0, 19, + save_regp_x, 2}, + {".seh_save_lrpair", 6, 3, 7, ARM64_UNOP_SAVELRPAIR, 3, 0, 1, 19, + save_lrpair, 2}, + {".seh_save_fregp", 6, 3, 7, ARM64_UNOP_SAVEFREGP, 3, 0, 0, 8, + save_fregp, 2}, + {".seh_save_fregp_x", 6, 3, 7, ARM64_UNOP_SAVEFREGPX, 3, 1, 0, 8, + save_fregp_x, 2}, + {".seh_save_freg", 6, 3, 7, ARM64_UNOP_SAVEFREG, 3, 0, 0, 8, + save_freg, 2}, + {".seh_save_freg_x", 5, 3, 8, ARM64_UNOP_SAVEFREGX, 3, 1, 0, 8, + save_freg_x, 2}, + {".seh_save_fplr", 6, 0, 2, ARM64_UNOP_SAVEFPLR, 3, 0, 0, 0, + save_fplr, 1}, + {".seh_save_fplr_x", 6, 0, 6, ARM64_UNOP_SAVEFPLRX, 3, 1, 0, 0, + save_fplr_x, 1}, + {".seh_save_r19r20_x", 5, 0, 3, ARM64_UNOP_SAVER19R20X, 3, 0, 0, 0, + save_r19r20_x, 1}, + {".seh_add_fp", 8, 0, 8, ARM64_UNOP_ADDFP, 0, 0, 0, 0, + add_fp, 2}, + {".seh_set_fp", 0, 0, 8, ARM64_UNOP_SETFP, 0, 0, 0, 0, + set_fp, 1}, + {".seh_save_next", 0, 0, 8, ARM64_UNOP_SAVENEXT, 0, 0, 0, 0, + save_next, 1}, + {".seh_nop", 0, 0, 8, ARM64_UNOP_NOP, 0, 0, 0, 0, + nop, 1}, + {".seh_pac_sign_lr", 0, 0, 8, ARM64_UNOP_PACSIGNLR, 0, 0, 0, 0, + pac_sign_lr, 1}, + {NULL, 0, 0, 8, ARM64_UNOP_END, 0, 0, 0, 0, + end, 1}, +}; + static void write_function_xdata (seh_context *); static void write_function_pdata (seh_context *); @@ -200,6 +259,8 @@ seh_get_target_kind (void) switch (bfd_get_arch (stdoutput)) { case bfd_arch_aarch64: + return seh_kind_arm64; + case bfd_arch_arm: case bfd_arch_powerpc: case bfd_arch_sh: @@ -270,6 +331,32 @@ verify_context_and_target (const char *directive, seh_kind target) return verify_context (directive); } +/* Verify mulitple targets. */ + +static int +verify_context_and_targets (const char *directive, const seh_kind targets[], + int count_targets) +{ + bool match = false; + for (int i = 0; i < count_targets; ++i) + { + if (seh_get_target_kind () == targets[i]) + { + match = true; + break; + } + } + + if (!match) + { + as_warn (_("%s ignored for this target"), directive); + ignore_rest_of_line (); + return 0; + } + + return verify_context (directive); +} + /* Skip whitespace and a comma. Error if the comma is not seen. */ static int @@ -362,6 +449,10 @@ obj_coff_seh_handler (int what ATTRIBUTE_UNUSED) else expression (&seh_ctx_cur->handler); + const seh_kind target_kind = seh_get_target_kind (); + if (target_kind == seh_kind_arm64) + seh_ctx_cur->arm64_ctx.xdata_header.x = 1; + seh_ctx_cur->handler_data.X_op = O_constant; seh_ctx_cur->handler_data.X_add_number = 0; seh_ctx_cur->handler_flags = 0; @@ -369,7 +460,7 @@ obj_coff_seh_handler (int what ATTRIBUTE_UNUSED) if (!skip_whitespace_and_comma (0)) return; - if (seh_get_target_kind () == seh_kind_x64) + if (target_kind == seh_kind_x64 || target_kind == seh_kind_arm64) { do { @@ -401,13 +492,65 @@ obj_coff_seh_handler (int what ATTRIBUTE_UNUSED) static void obj_coff_seh_handlerdata (int what ATTRIBUTE_UNUSED) { - if (!verify_context_and_target (".seh_handlerdata", seh_kind_x64)) + const seh_kind targets[] = { seh_kind_x64, seh_kind_arm64 }; + if (!verify_context_and_targets (".seh_handlerdata", targets, + sizeof (targets) / sizeof (seh_kind))) return; demand_empty_rest_of_line (); switch_xdata (seh_ctx_cur->subsection + 1, seh_ctx_cur->code_seg); } +/* Obtain available unwind element. */ + +static void +seh_arm64_add_unwind_element (seh_arm64_unwind_types unwind_type, int offset, + int reg) +{ + if (seh_ctx_cur == NULL + || seh_ctx_cur->arm64_ctx.unwind_codes_count >= ARM64_MAX_UNWIND_CODES) + { + as_warn (_("no unwind element available.")); + return; + } + + seh_arm64_unwind_code *arm64_element = seh_ctx_cur->arm64_ctx.unwind_codes + + seh_ctx_cur->arm64_ctx.unwind_codes_count++; + const struct unwind_code_pack_info *unwind_code_pack_info; + unwind_code_pack_info = unwind_code_pack_infos + unwind_type; + arm64_element->value = 0; + int value_offset_bits = 0; + + if (unwind_code_pack_info->offset_bits) + { + offset = (offset >> unwind_code_pack_info->offset_right_shift) + - unwind_code_pack_info->offset; + offset &= (1 << unwind_code_pack_info->offset_bits) - 1; + arm64_element->value |= offset << value_offset_bits; + value_offset_bits += unwind_code_pack_info->offset_bits; + } + + if (unwind_code_pack_info->reg_bits) + { + reg = (reg >> unwind_code_pack_info->reg_right_shift) + - unwind_code_pack_info->reg_offset; + reg &= (1 << unwind_code_pack_info->reg_bits) - 1; + arm64_element->value |= reg << value_offset_bits; + value_offset_bits += unwind_code_pack_info->reg_bits; + } + + if (unwind_code_pack_info->code_bits) + { + int code = unwind_code_pack_info->code; + code &= (1 << unwind_code_pack_info->code_bits) - 1; + arm64_element->value |= code << value_offset_bits; + } + + arm64_element->type = unwind_code_pack_info->type; + seh_ctx_cur->arm64_ctx.unwind_codes_byte_count += unwind_code_pack_info->size; +} + + /* Mark end of current context. */ static void @@ -465,11 +608,18 @@ obj_coff_seh_proc (int what ATTRIBUTE_UNUSED) seh_ctx_cur->code_seg = now_seg; - if (seh_get_target_kind () == seh_kind_x64) + seh_kind kind = seh_get_target_kind (); + if (kind == seh_kind_x64 || kind == seh_kind_arm64) { x_segcur = seh_hash_find_or_make (seh_ctx_cur->code_seg, ".xdata"); seh_ctx_cur->subsection = x_segcur->subseg; x_segcur->subseg += 2; + + if (kind == seh_kind_arm64) + { + seh_ctx_cur->arm64_ctx.unwind_codes_count = 0; + seh_ctx_cur->arm64_ctx.epilogue_scopes_count = 0; + } } SKIP_WHITESPACE (); @@ -498,6 +648,23 @@ obj_coff_seh_endprologue (int what ATTRIBUTE_UNUSED) as_warn (_("duplicate .seh_endprologue in .seh_proc block")); else seh_ctx_cur->endprologue_addr = symbol_temp_new_now (); + + if (seh_get_target_kind () == seh_kind_arm64) + { + const int n = seh_ctx_cur->arm64_ctx.unwind_codes_count; + + /* Unwind codes need to be reversed. */ + for (int i = 0; i < n / 2; ++i) + { + seh_arm64_unwind_code *unwind_codes; + unwind_codes = seh_ctx_cur->arm64_ctx.unwind_codes; + seh_arm64_unwind_code temp = unwind_codes[i]; + unwind_codes[i] = unwind_codes[n-i-1]; + unwind_codes[n-i-1] = temp; + } + + seh_arm64_add_unwind_element (end, 0, 0); + } } /* End-of-file hook. */ @@ -691,34 +858,66 @@ obj_coff_seh_stackalloc (int what ATTRIBUTE_UNUSED) offsetT off; int code, info; - if (!verify_context_and_target (".seh_stackalloc", seh_kind_x64) + const seh_kind targets[] = { seh_kind_x64, seh_kind_arm64 }; + if (!verify_context_and_targets (".seh_stackalloc", targets, + sizeof (targets) / sizeof (seh_kind)) || !seh_validate_seg (".seh_stackalloc")) return; off = get_absolute_expression (); demand_empty_rest_of_line (); - if (off == 0) - return; - if (off < 0) - { - as_bad (_(".seh_stackalloc offset is negative")); - return; - } + switch (seh_get_target_kind ()) + { + case seh_kind_x64: + if (off == 0) + return; + if (off < 0) + { + as_bad (_(".seh_stackalloc offset is negative")); + return; + } - if ((off & 7) == 0 && off <= 128) - code = UWOP_ALLOC_SMALL, info = (off - 8) >> 3, off = 0; - else if ((off & 7) == 0 && off <= (offsetT) (0xffff * 8)) - code = UWOP_ALLOC_LARGE, info = 0, off >>= 3; - else if (off <= (offsetT) 0xffffffff) - code = UWOP_ALLOC_LARGE, info = 1; - else - { - as_bad (_(".seh_stackalloc offset out of range")); - return; - } + if ((off & 7) == 0 && off <= 128) + code = UWOP_ALLOC_SMALL, info = (off - 8) >> 3, off = 0; + else if ((off & 7) == 0 && off <= (offsetT) (0xffff * 8)) + code = UWOP_ALLOC_LARGE, info = 0, off >>= 3; + else if (off <= (offsetT) 0xffffffff) + code = UWOP_ALLOC_LARGE, info = 1; + else + { + as_bad (_(".seh_stackalloc offset out of range")); + return; + } - seh_x64_make_prologue_element (code, info, off); + seh_x64_make_prologue_element (code, info, off); + break; + + case seh_kind_arm64: + /* arm64 offset should be encoded in multiples of sixteen. */ + if ((off & 0xf) != 0) + { + as_bad (_(".seh_stackalloc offset < 16-byte stack alignment")); + return; + } + + if (off < 0x200) + seh_arm64_add_unwind_element (alloc_s, off, 0); + else if (off < 0x8000) + seh_arm64_add_unwind_element (alloc_m, off, 0); + else if (off < 0x10000000) + seh_arm64_add_unwind_element (alloc_l, off, 0); + else + { + as_bad (_(".seh_stackalloc offset out of range")); + return; + } + break; + + default: + as_bad (_(".seh_stackalloc invalid target")); + return; + } } /* Add a frame-pointer token to current context. */ From patchwork Wed Apr 9 14:08:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Karpov X-Patchwork-Id: 110118 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 B6687384F002 for ; Wed, 9 Apr 2025 14:09:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6687384F002 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=microsoft.com header.i=@microsoft.com header.a=rsa-sha256 header.s=selector2 header.b=ftzZjTHY X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on20722.outbound.protection.outlook.com [IPv6:2a01:111:f403:2607::722]) by sourceware.org (Postfix) with ESMTPS id 0B1A03861016 for ; Wed, 9 Apr 2025 14:08:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B1A03861016 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=microsoft.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0B1A03861016 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2607::722 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207729; cv=pass; b=Y5Iev3UeqhMKmMsTXWikUfq2H4RtoTL4lhNFqjlR8oX5oO6AUFHAT9haMoKPmHLncSVN/BFh7pXKvRAZZ72dpfVRSp3KtCzbXw2w+GMUDWUdCynvRzxl32EWRZ7YVvUcgTzbEaBssgh7movMV6HTb9LgniwcISweTpabJ4thLiA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207729; c=relaxed/simple; bh=MYBiXxbfDYhsz5Zhc/9J//+rMYGwtC0465RDs+IukNo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FvZHSStPO70v9AZhCgGxYdKBqptD4Bku+kyi32OgrKmA4Vxas87dbqxViCOlsOq2ZWPCV597ikvB5JJ8Lcr8PhY2xF1T3+xGL0tPouYyyxybYXPeNRaXrkku1jE2gC0AqIwxE+VX/fy00t+2Dfw6qBK2HsXMSsenO/+KR063cLs= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B1A03861016 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VKwuERu4lkaZIku+S3KoiElQjy1LASLzGZH1p5t9PY2nUyEZJNmKDfZSPlj0l1AwSZUzDdJqF6ZhgrprO33PHCVba2ymkp5jkoqAKp/51F8jrFC41mBNo8QV5HnwpjX3rMjKk3IgE/pQq/PTv2IK4iAraAI739JPl0C6p/3TjiZPdC+PS3AMyahHF94nm2aUNtz8kI7cckJzhp2wXgSnmk6yeWTR+P/EwkhH/xgmICMHalAceqUqbVioEj7Cx12Gqyz1ZJu6GMR5wRmyaOdnbS/DWOKPj2Ea5nt+6SiY5ZgOykwc1nq3pHgzun1AGRQvPoWhA6ZQHxj9Tuk5bgul5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=4wxuaNlHbVLQjXKWuHxURDLKtMVDzuBrBHkdJT7l9Y0=; b=nR4JmAZssxBQS3omXYlsXtzn6ufrBv7FUStLvt5/oF92I0WG0wLWkgC6MyYGeJFI7ZTUFKSKa8YetVsByA07mkFJWD/9coXRurv4Jg+sU3pt1KUK/6wPer4RZHGC/0OBHc5o6udFwUSw9s4w8vM5YXlvpPtxAVDxnXi9KBT87kclVBqT2Rz+IN3Yylv0K39oRLg0WIDZa/Y9szQAXZHQgpl1QlB9G/QO4lMJFbnP3vUtbmVNKT2OMbNYB4tDH83qFbU00VJgq2RQNaSUJbf3vZqcSs3/MOVHFCZ8QZzDzphP+AQMHLnNtENXnFZdtzHpQ7mNMjYgl9PG4gQWShVCMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4wxuaNlHbVLQjXKWuHxURDLKtMVDzuBrBHkdJT7l9Y0=; b=ftzZjTHYi46c+Fz9EB6XpCuE4uEiNeFuTHwFzWM02RGG3a9p6ns5efNG/9dFE7DmYw5BxOYkwCWciVELIM03tp6GYBlFQJlxFZsnalfW6pg5QyGBnhtdfT8TVvSxYOdXhjK1W53hQwKwPKdOOCONirwoEFUnKHIB6zqBHWx8qG4= Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com (2603:10a6:800:270::12) by GV2PR83MB0901.EURPRD83.prod.outlook.com (2603:10a6:150:277::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.5; Wed, 9 Apr 2025 14:08:44 +0000 Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb]) by VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb%5]) with mapi id 15.20.8655.002; Wed, 9 Apr 2025 14:08:44 +0000 From: Evgeny Karpov To: Binutils CC: "Richard Earnshaw (lists)" , "amodra@gmail.com" , Radek Barton Subject: [PATCH v1 4/7] Add aarch64-specific SEH commands Thread-Topic: [PATCH v1 4/7] Add aarch64-specific SEH commands Thread-Index: AQHbqVjn27Tj6HBd1UmiIfjwDgKtCQ== Date: Wed, 9 Apr 2025 14:08:44 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2025-04-09T14:08:22.935Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI2PR83MB0718:EE_|GV2PR83MB0901:EE_ x-ms-office365-filtering-correlation-id: 6310c671-e9cb-4b3a-b9c8-08dd77700a32 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|366016|1800799024|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?pO4fKbVk5LvAjvGWoR8F6P20uK?= =?iso-8859-1?q?zRWMue4MEh5KODG3OUOeVW5tvCf6O5cBIJSxVbDnbZW6dCvDY2T3Ob/iYiqW?= =?iso-8859-1?q?8HJ6bOrd8gVT/4FrNsC4UNSwVcsMTprqTr8CTxupKtvxItllS53fvlAkTEuQ?= =?iso-8859-1?q?VA5XB1Bov+i6WF1cSTKQ5t4BG1/YSRvUpRtZV3jEDTa7BUkrhvizQC2awvLv?= =?iso-8859-1?q?lViN8mleYf2A9/jNSvQP1RB/X2NRXMnVTKWB/xc0nRfSBcCECu9Hofz7yoSV?= =?iso-8859-1?q?pa4AcKBCZiC1XAp54w75jQTO38t2I4bte+sF7qsT8N8NNngr/utEmOyhzXKk?= =?iso-8859-1?q?R9txgYjRpR8MjAKkkTTxUegPwx7mmxsviuQ3PfoO+sdDFLCSuwSVYgNULqLp?= =?iso-8859-1?q?wGKDlA6akUxVE53eRm80siwWhdygNCtYGVmAeIWoiPjJhkalY1xbp8EWJ9LD?= =?iso-8859-1?q?iFFntcVyUQUoQtjBXNSzlFcY4wGFShI6j0AmqmzUydUgR1U6g3uNamxznIpk?= =?iso-8859-1?q?lkrr7smAKixIWZX+/4EcqAwM4gNlBOtJdCYfEESTQl/aZLhaEhOyG1jIat1W?= =?iso-8859-1?q?6DkS6I3jNMBw03W6WBJRk/LGezIAhN3YUnX0RCsi7tbr0YK5YlvPD4FfR3RM?= =?iso-8859-1?q?b30LaKdAoezEKPc6i7Np1+2tsXS738aCFdveToMWQvbjR0NnmU6ilvHG1FFq?= =?iso-8859-1?q?p8Qa+aPISq8zqGlqAOUVQt9gRLU43z14qnRQ6ojqGdW/5Bq26pMyAVwJk09S?= =?iso-8859-1?q?IfJmwqRN6pDs0/DMtP9/f53OKU5m/E2jqlIgBbqqBnyHMtpW4pc/y9PmoufM?= =?iso-8859-1?q?V7Q94re/as4pveEo3GVx3mfKvMNhlSlPHUlavveNUpp7rrprQ+KbIPXOUjX3?= =?iso-8859-1?q?X7DlgQnJDMcqgOuog7RoW7srAJVZ1V16R8KHjVuy0IUeJTisHOdLEu+yqsPF?= =?iso-8859-1?q?+2PDYVmzsV5nGAl82GUEW1jDyKZiYI3ahyu/ooAKBHAZuMUSX4YouaIjh3zE?= =?iso-8859-1?q?N1HRER9Vs1gDj+XenfQsui3tAC9tG4y4qzsS1e19YctmLQCnUZoc4Tr3tEUC?= =?iso-8859-1?q?/GLzocDgX38L0leQZOBR8cerN4zSk0u5xBuEtxcT69qFszaBtHO8QWBVfFod?= =?iso-8859-1?q?0wUo8PC9hEugRyRCceVqACufwkv7H2jtTSe7ltHtos8YF299qkH51NbCXX6r?= =?iso-8859-1?q?l6H8zgb4aj0eKVWPrBPm8bIRu/LGqDSZPfq34bRQ9vjLdZRcAkwEPMyJ8536?= =?iso-8859-1?q?Qc9k2snWgt2jQqAfkpY0GUW4IsGvTtgRkcpNslAullHIspoSai5b2ixWLVVw?= =?iso-8859-1?q?FsGIpVvx8fst/hzuA8Fk6Acbh5kcnoHnnz/EYywuVHWWsT8WPRH2zyNymMPq?= =?iso-8859-1?q?MyAVRsBKZNadjVOmO72oWU6Yg9kLXQRsiAKpxVfNInwLLlk8WYPlb+dhLOdP?= =?iso-8859-1?q?rvtPxuw6lcLtTiN0LEZndls9XJRejg0jDqMh1dCgNxo+aU/HmsnBJKMng3Cn?= =?iso-8859-1?q?Sl4xKhTHzpsfXf/hgyv//IuD1aWIVMtAw+WH9s2yEMuQs3uzM=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI2PR83MB0718.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?8rbMFIL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q?KdjtZtEcjYzrUpP4f72/L9eGeg1Dn8+9Q7t5yW70Xz6+jlClLjegKNZnGR5A?= =?iso-8859-1?q?Pc15ypZYEosK++bwTAk2V89FXxMzDPX4f9lz/krS8eLoKlJQlGSWzQ1+OdEX?= =?iso-8859-1?q?Tp06dGR0k/seEKb6XUOxM0l9busubN/q4Gr2CRlfokt+AsbItfO5AuRvYg/y?= =?iso-8859-1?q?2wD5F7pvY4+CxuhLZd+WV19ks7usP94eq97FqXAIovVGL33mu9NCslKxxJ83?= =?iso-8859-1?q?Q+VbhWrAdmhd9yqniRAfKXhTV1/HL6ESdoFBqZyqZbSwbBTUNxgJcYza+OkL?= =?iso-8859-1?q?WZeZ7/Drs7Fyad9ogeQ9QXh048/2kY29wyYV7GqqqgfporDMqmoFifF+Qh45?= =?iso-8859-1?q?aK31sdDfPDAiufLLNH5CboWNCk4/dc5FQW6A43yLlvFpN2eyj6Ggx89fq2nD?= =?iso-8859-1?q?5UFIRaWtzjXvEfR53lwMe1LeuNq8TNQQUt/pUqu7mYzSAt0v2efLIdRZMAXi?= =?iso-8859-1?q?Q+TcNhExxBkzOV6CyUlhBDGj7BMkuZWndidPyCcYSXWgsVxrga4aHQejxLT5?= =?iso-8859-1?q?s0NxP7DTLbIbwsO34s7tAEwuva8+dQGRQLbQ9i5Oexcpbvb1qc1kN0qVos4q?= =?iso-8859-1?q?+d2x9PJ/G2oo+MqflYFBHQT3Y+cYKJqf1YqmVDSIKRuBav537JIjJzDU5b1W?= =?iso-8859-1?q?S6tyAgQOwEOz4vfQNEJJm1nCbkOfpoUNe5X110fGEuYbWQ2F1rnDmCsIVdjT?= =?iso-8859-1?q?UgML4h1AqWlTVzsDh?= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI2PR83MB0718.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6310c671-e9cb-4b3a-b9c8-08dd77700a32 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2025 14:08:44.7012 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: FafJELCD0OG9eveIH/yDCP0ydtR0lcPBsSHrPSk/TFM8ydWyR5cS7v0ukwRFzxFjel+ozxdw/aFGUSIeCOCIoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR83MB0901 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Implementation for aarch64 contains SEH commands that are not present for x64 architecture, such as .seh_startepilogue/.seh_endepilogue, .seh_save_reg*, .seh_save_freg*, and others. gas/ChangeLog: * config/obj-coff-seh.c (obj_coff_seh_startepilogue): New. (obj_coff_seh_endepilogue): New. (obj_coff_seh_endfunclet): New. (obj_coff_seh_save_reg): New. --- gas/config/obj-coff-seh.c | 134 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/gas/config/obj-coff-seh.c b/gas/config/obj-coff-seh.c index 250cbc236ef..96ddfd51a82 100644 --- a/gas/config/obj-coff-seh.c +++ b/gas/config/obj-coff-seh.c @@ -667,6 +667,84 @@ obj_coff_seh_endprologue (int what ATTRIBUTE_UNUSED) } } +static void +obj_coff_seh_startepilogue (int what ATTRIBUTE_UNUSED) +{ + symbolS *epilogue_start_addr; + expressionS exp; + + if (!verify_context (".seh_startepilogue") + || !seh_validate_seg (".seh_startepilogue")) + return; + demand_empty_rest_of_line (); + + if (seh_get_target_kind () != seh_kind_arm64) + return; + + epilogue_start_addr = symbol_temp_new_now (); + exp.X_op = O_subtract; + exp.X_add_symbol = epilogue_start_addr; + exp.X_op_symbol = seh_ctx_cur->start_addr; + exp.X_add_number = 0; + + if (!resolve_expression (&exp) || exp.X_op != O_constant + || exp.X_add_number < 0) + as_bad (_(".seh_startepilog offset expression for %s " + "does not evaluate to a non-negative constant"), + S_GET_NAME (epilogue_start_addr)); + + seh_arm64_epilogue_scope *epilogue_scope; + epilogue_scope = seh_ctx_cur->arm64_ctx.epilogue_scopes + + seh_ctx_cur->arm64_ctx.epilogue_scopes_count; + epilogue_scope->epilogue_start_offset = exp.X_add_number / 4; + epilogue_scope->reserved = 0; + epilogue_scope->epilogue_start_index + = seh_ctx_cur->arm64_ctx.unwind_codes_byte_count; + seh_ctx_cur->arm64_ctx.epilogue_scopes_count++; +} + +static void +obj_coff_seh_endepilogue (int what ATTRIBUTE_UNUSED) +{ + if (!verify_context (".seh_endepilogue") + || !seh_validate_seg (".seh_endepilogue")) + return; + + demand_empty_rest_of_line (); + + expressionS exp; + symbolS* epilogue_end_addr = symbol_temp_new_now (); + exp.X_op = O_subtract; + exp.X_add_symbol = epilogue_end_addr; + exp.X_op_symbol = seh_ctx_cur->start_addr; + exp.X_add_number = 0; + + if (!resolve_expression (&exp) || exp.X_op != O_constant + || exp.X_add_number < 0) + as_bad (_(".seh_endepilogue offset expression for %s " + "does not evaluate to a non-negative constant"), + S_GET_NAME (epilogue_end_addr)); + + seh_arm64_epilogue_scope *epilogue_scope; + epilogue_scope = seh_ctx_cur->arm64_ctx.epilogue_scopes + + seh_ctx_cur->arm64_ctx.epilogue_scopes_count - 1; + + epilogue_scope->epilogue_end_offset = exp.X_add_number; + + /* End code. */ + seh_arm64_add_unwind_element (end, 0, 0); +} + +static void +obj_coff_seh_endfunclet (int what ATTRIBUTE_UNUSED) +{ + if (!verify_context (".seh_endfunclet") + || !seh_validate_seg (".seh_endfunclet")) + return; + + demand_empty_rest_of_line (); +} + /* End-of-file hook. */ void @@ -850,6 +928,62 @@ obj_coff_seh_save (int what) seh_x64_make_prologue_element (code, reg, off); } +static void +obj_coff_seh_save_reg (int type) +{ + if (type < 0 || type > unwind_last_type) + { + as_bad (_("invalid pseudo operation.")); + return; + } + + const struct unwind_code_pack_info *unwind_code_pack_info; + unwind_code_pack_info = unwind_code_pack_infos + type; + + if (!unwind_code_pack_info->directive + || !verify_context_and_target (unwind_code_pack_info->directive, + seh_kind_arm64) + || !seh_validate_seg (unwind_code_pack_info->directive)) + return; + + SKIP_WHITESPACE (); + + char *symbol_name = NULL; + int reg = -1; + + if (unwind_code_pack_info->reg_bits) + { + char name_end = get_symbol_name (&symbol_name); + reg = atoi (symbol_name + 1); + (void) restore_line_pointer (name_end); + + if (!skip_whitespace_and_comma (1)) + return; + + if (reg < 0) + { + as_bad (_("register is negative")); + return; + } + } + + offsetT off = -1; + if (unwind_code_pack_info->offset_bits) + { + off = get_absolute_expression (); + + if (off < 0) + { + as_bad (_("offset is negative")); + return; + } + } + + demand_empty_rest_of_line (); + + seh_arm64_add_unwind_element (type, off, reg); +} + /* Add a stack-allocation token to current context. */ static void From patchwork Wed Apr 9 14:11:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Karpov X-Patchwork-Id: 110120 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 8FA6E3850227 for ; Wed, 9 Apr 2025 14:12:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FA6E3850227 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=microsoft.com header.i=@microsoft.com header.a=rsa-sha256 header.s=selector2 header.b=Q0zXM3qI X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on20723.outbound.protection.outlook.com [IPv6:2a01:111:f403:2607::723]) by sourceware.org (Postfix) with ESMTPS id E3BA0384DEC5 for ; Wed, 9 Apr 2025 14:11:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3BA0384DEC5 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=microsoft.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E3BA0384DEC5 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2607::723 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207881; cv=pass; b=gPBT4h1jRCuOEDTLxbUt+wbFBtGDEmm9dTVDfa7AbjHbtqJ3NVmTDimosDkpqtWEHwAKOYJMdeAro1T5V56AQ/zP9RdtEqTw3svA8Z7RziNPSS7KBlVXKobdzilU1+upadLBQ+9S8xJpOopjOHyhGvMcatThulALHVF5JPiODRs= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744207881; c=relaxed/simple; bh=dj+PgrbkFZ09wEqwu328peUdhS38FOhHq2CSuj8FkbY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dsMcXXrPIP99rgzw/2dsM3wd6eZTed+5mh1QWQ3WpWUsp0yJPj+39oneE2YiqQNdTimylgdHNo0IiTLl2wvb10BwHlVMdQ2yjAxbdUAWwCH+5ki2mmYkHKiRQkvyqs11dCJ1ztCbz3Wa4rv70ZZE9E3GT2zLK45gpRaAN3x/LJU= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3BA0384DEC5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iAjxavhBSQyeEPCIqtAyFtt9+OiJrOOYtiqai3oRmEgTRweeiRhTjviy3kxYAR6o6g5wLEdKFiBePJnRoidS702DpGUxfze5laj2if/snsA7B7Hr/HD3gfz9OTlTbaCY2uPBr56rVknfn3ijd2IQL43/n2ohHEM/D7+DRvVjVgYwG3xyjRRgXInrvtvIzFs1bBqxSakL8qdhjFksXcWCzxKA6Myb1iFTxUMMW49lK6+Y/9VBuArJWKVZqGXpEdOB2IkbJu9xlcjAomerRpaj1/aEx/DMHP9w/ktupIL9QZid3SOaocVR+lQgaaOPBdt9+4whEHHPIV/ns54E2kAFsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=lJ3pi+C3ZAWh5sOi8MWorStEQmRilerBxY0klfKchc4=; b=FSkr/RsSBAZdM0LEw3tEo/y4ckW7zLF95EgA5teAfkBmq5inwWc3tKILMu3XePRZoEcAGKlmJFwusFjtdNUHQTfcHH/G51US9x85HtBgsz/PdHZ3xNL6HiVTr46xL9a6In4KBmeUzz17dp8cyfu1Z12PCAfMCqWHcq+gmbGd7v8N6D7rc4+VSZoY7T2pglSa6cFYVhRKVClnwKb37BnykhF5DqGUZbkVUdEKoDPuR0macIwLn/lWMtZ40L3rds5ETrXj3gpVVEBhL7Zvhn0oPlYBjDeAmqbMxrPKDBamLhhU+peHC3WEcjwL/Wt/xLgHjnOgvAxZrbKXN5Tf8kxWVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lJ3pi+C3ZAWh5sOi8MWorStEQmRilerBxY0klfKchc4=; b=Q0zXM3qIcdQkYbyGGnxYYRL0GclXiAn7vEZk28GSOXnX3eFYnfYI5v2c4hGv4chUhNd27xW+HxcRTAUyYOILGfoCxVrJs+msNYIag/xjPRhS6N3LBvi/+rHMsK9sFsHyZIxsqpvefuocHjkQ7B2kql54Wn1UU89CqKr5E2z9q5Q= Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com (2603:10a6:800:270::12) by GV2PR83MB0901.EURPRD83.prod.outlook.com (2603:10a6:150:277::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.5; Wed, 9 Apr 2025 14:11:18 +0000 Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb]) by VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb%5]) with mapi id 15.20.8655.002; Wed, 9 Apr 2025 14:11:18 +0000 From: Evgeny Karpov To: Binutils CC: "Richard Earnshaw (lists)" , "amodra@gmail.com" , Radek Barton Subject: [PATCH v1 5/7] Write SEH records to pdata/xdata Thread-Topic: [PATCH v1 5/7] Write SEH records to pdata/xdata Thread-Index: AQHbqVlCqJzLLz4RdkKMNyxD4OQslA== Date: Wed, 9 Apr 2025 14:11:17 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2025-04-09T14:10:55.747Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI2PR83MB0718:EE_|GV2PR83MB0901:EE_ x-ms-office365-filtering-correlation-id: 3d4ca662-c80f-4902-2082-08dd77706547 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|366016|1800799024|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?3LKAEldX0WaWOtH2JlzKPnqmOO?= =?iso-8859-1?q?w3KMhc0/HWV8GzYh/a5/e0w7XG1IHRJOnKaDpb4mjR850mQXEZ+Jexnb6Mti?= =?iso-8859-1?q?hyDT4QeEew+y9vktraNarB0do/yPStOFWgx8pDYKGD+DwrneMz+iIlMXFsP6?= =?iso-8859-1?q?9609+OwZzL5FL9WKVXM9jjRMmOY5EmoCvDKGPOu7IfJShtdRtWX4z7w+lY+Z?= =?iso-8859-1?q?L0htfYuPKZd0Uja5irVRDn0M71RLz8/bpgIS508a7f40WKi7z220YgDTtEZB?= =?iso-8859-1?q?4uV4sXs1Y4aKt2iilSlMSuHcNSXVeQ/f+KIcnyynFO53m1zfQbzwEgt0atui?= =?iso-8859-1?q?expqLeIB/rbvpqmD3i/Kh7lSWMvdWgPY4S1oadUUOwHoTMZOOFypnDaqnIe9?= =?iso-8859-1?q?zEEdPCBfXE3bwF617oq37zelscMVGaRlP74TSvKnVDw+rHitT3w7URDPu6jV?= =?iso-8859-1?q?dja6VcY8yCnGw/83zYEaDPcslf2av1ppbEgKP1EFvU8zoyRgxISZoqVbjDkw?= =?iso-8859-1?q?C540WNxc2FNFfZLLZFvPtmmU3XW+VY4RotPPP1wjZdLx+WmNaJS/dGY4Av4s?= =?iso-8859-1?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3k+/DgNaBPJM8Q5CyxKlb1Kx19uV5i?= =?iso-8859-1?q?x57bSIrZlXwHT0tLKJVDiZXOmEDDfzov3Ldh4PwcAAzQ1j13k=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI2PR83MB0718.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?TyodUjD6yhwoz6JuddWofat?= =?iso-8859-1?q?nNakNPHHDrg73ru2hjjM+aX03qxFyVMEFd11ZWvda5l+kG0zTMVccdmrPXRG?= =?iso-8859-1?q?qmHd2MCPmm7v1qbcwIeUT6D64dsi1plq2D4CoJUP0AQeDCR0MWth79NVpDSz?= =?iso-8859-1?q?bhkL/9w6mZNrHL7N//3MHFa5vH1pEd2bXfM5Q4Ob+a5UwtweajkEYwTq94+u?= =?iso-8859-1?q?kmBLrpk7G2izwGMo7pNVxGKFy150lh/joOP5v7KpZrAACGtkThyJS04HBzIL?= =?iso-8859-1?q?EsROgJjzxMHfQ2gOY1o+Cppml7PpNUEFZf+VoJ/TLJJAab5dxvB9xGjTLvCG?= =?iso-8859-1?q?dWZU4CQb/ATv0YDyGABkSTNICXJC56RiKglguQViSy/9WNV/67/aHNTZklap?= =?iso-8859-1?q?vOkZ+FIIQo/r/JoIcTeJ46nwuiOjwZM3xlI29VrcmaDORw2CrceWiPgyB6Gb?= =?iso-8859-1?q?b9k3lY2zJux5tq0hFFXWzxj55XAppE/0n5xREkolsWPSD10z/lNOhSXTAaSA?= =?iso-8859-1?q?Z8tgzvdu9F1rHqy6UgjYqqEKmSIUhYWKcU6PWysNdngaf+yyQLqiYYYGpij8?= =?iso-8859-1?q?NFiEptgWQ9JDA/iQ9Zqb8d+2YPZ/0VpecCNH3i3fSGFywFp+Xhz09YA+1Hoz?= =?iso-8859-1?q?BAYl37z+28m5MH9V7KVXgAe9of8pDn24VzJZGwSXteeAFv1qQSCnDknP5ADE?= =?iso-8859-1?q?aX1FaS/lq7YqVPKCIWfxZnEuE2lOxtTrhFQ8AZUV+frCirNhkE2y9xPr4gex?= =?iso-8859-1?q?6CsunJWCkAZ4QREx8eK9VE0JnqeIcBxyAxu6keMcC++QmNolYWC12kgSUXiw?= =?iso-8859-1?q?nNiWkmqtyttiisbOYHbUJ5Rjxa/I+DUCizxSQF74neYVbMf4zuM0O5PV2g8p?= =?iso-8859-1?q?q1sZkDtYwTMkTHNAnMfg4ZUsnUpz4JewJ1jYEANG4EZpUqYN5fk7CbYG2mT8?= =?iso-8859-1?q?qdj6Zp+xfZX5TKOk6yng0EKcrGlVf+Bi82UrnoEGh3v5VzlnuwJqFbfDYPXo?= =?iso-8859-1?q?Wi64o6syxocRHwdp9Am+TWGolngY0LG3UImoPboecq7DkGcuYOloWKLzwcOj?= =?iso-8859-1?q?opKF3Gh8IjQviFH5qdBx64t35c7sn9j8dObrsZUe0sEQ5Tmr6het1aC7+0a9?= =?iso-8859-1?q?6lWZ+2IpDnYrubSYF8cy7FwIeHfMC05/eSytr7wq+KkaNk/DAsTDbAuN9x2x?= =?iso-8859-1?q?YjEBEnW+mSVScFOXRJovlE9ANXHYlu/9odNrRaIFIK+OtE3Eeg0JsGza21ze?= =?iso-8859-1?q?edzoiIdoLiT2pdU0fnTRjH7ZMUp+MESyRiOYGB1PeI9vaa94Kt2+VdQfU5rX?= =?iso-8859-1?q?+vlS03eHxjzTBgvfOnKqLd1K90jPEQm29YPIQzoOVh0R9scVTnhcLPm0kBo9?= =?iso-8859-1?q?GhAYoh09TCYxOHbZtiLJKT7LgrQiGHu8l2N5rsOYbWmgprk+Ntq9fP5XG5Ld?= =?iso-8859-1?q?UCX/J1/7S60M4J4HxBXYMfNqg00RE0ArwDhi8NuUm385Ij8QSAHHjKp4h80y?= =?iso-8859-1?q?uen4C/lW/sef8TUv2GxTaDrt4ncDQZSWCKhhumR/1c+oCXt+9q69lKOetqyE?= =?iso-8859-1?q?0tQHhEl7+6WxCvJTemaUMTgCUxL2jfTZ+/oQo4LFApnbIyIUfAxL+s0OCHBv?= =?iso-8859-1?q?cmYDA2E3jUtvwdQkC?= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI2PR83MB0718.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d4ca662-c80f-4902-2082-08dd77706547 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2025 14:11:17.5432 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Zvz8oPdhey+L0XiSk8Xs5ebsAntEJrZbCCXuVosZp7Hp29ngj+MS8UCr3k7z04fpVECS3EKaxjxm8NGZbNXQSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR83MB0901 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org The patch emits the required records to the pdata/xdata sections that contain unwinding information for SEH. gas/ChangeLog: * config/obj-coff-seh.c (do_seh_endproc): Update. (seh_arm64_emit_epilog_scopes): New. (seh_arm64_emit_unwind_codes): New. (seh_arm64_write_function_xdata): New. (write_function_xdata): Update. (write_function_pdata): Update. --- gas/config/obj-coff-seh.c | 312 +++++++++++++++++++++++++++++++++++++- 1 file changed, 304 insertions(+), 8 deletions(-) diff --git a/gas/config/obj-coff-seh.c b/gas/config/obj-coff-seh.c index 96ddfd51a82..f9a8ea80c28 100644 --- a/gas/config/obj-coff-seh.c +++ b/gas/config/obj-coff-seh.c @@ -557,13 +557,23 @@ static void do_seh_endproc (void) { seh_ctx_cur->end_addr = symbol_temp_new_now (); + const seh_kind kind = seh_get_target_kind (); - write_function_xdata (seh_ctx_cur); - write_function_pdata (seh_ctx_cur); - free (seh_ctx_cur->elems); - free (seh_ctx_cur->func_name); - free (seh_ctx_cur); - seh_ctx_cur = NULL; + if (kind != seh_kind_arm64 + || seh_ctx_cur->arm64_ctx.unwind_codes_byte_count > 0) + { + write_function_xdata (seh_ctx_cur); + write_function_pdata (seh_ctx_cur); + } + + while (seh_ctx_cur) + { + seh_context *ctx = seh_ctx_cur; + seh_ctx_cur = seh_ctx_cur->next; + free (ctx->elems); + free (ctx->func_name); + XDELETE (ctx); + } } static void @@ -1169,6 +1179,74 @@ seh_x64_write_prologue_data (const seh_context *c) } } +static void +seh_arm64_emit_epilog_scopes (const seh_context *c, uint64_t fragment_offset, + uint32_t prolog_size, + uint32_t first_fragment_scope, + uint32_t last_fragment_scope, + bool has_phantom_prolog) +{ + int32_t start_index_offset = 0; + const + seh_arm64_epilogue_scope* scopes = seh_ctx_cur->arm64_ctx.epilogue_scopes; + if (first_fragment_scope < seh_ctx_cur->arm64_ctx.epilogue_scopes_count) + start_index_offset = scopes[first_fragment_scope].epilogue_start_index + - prolog_size; + if (has_phantom_prolog) + start_index_offset -= 1; + for (int i = first_fragment_scope; i < last_fragment_scope; ++i) + { + seh_arm64_epilogue_scope scope = seh_ctx_cur->arm64_ctx.epilogue_scopes[i]; + scope.epilogue_start_offset_reduced = (scope.epilogue_start_offset + - fragment_offset) >> 2; + scope.epilogue_start_index -= start_index_offset; + out_four (*(uint32_t*) &scope); + } +} + +static void +seh_arm64_emit_unwind_codes (const seh_context *c, uint32_t prolog_size, + uint32_t first_epilog_index, + uint32_t last_epilog_index, + bool has_phantom_prolog) +{ + uint32_t total_byte_count = 0; + + if (has_phantom_prolog) + { + ++total_byte_count; + md_number_to_chars (frag_more (1), ARM64_UNOP_ENDC, 1); + } + + uint32_t unwind_bytes_offset = 0; + for (int i = 0; i < (int)c->arm64_ctx.unwind_codes_count; ++i) + { + const seh_arm64_unwind_code *code = c->arm64_ctx.unwind_codes + i; + const int byte_count = unwind_code_pack_infos[code->type].size; + unwind_bytes_offset += byte_count; + + if (unwind_bytes_offset > last_epilog_index) + break; + + if (unwind_bytes_offset > prolog_size + && unwind_bytes_offset <= first_epilog_index) + continue; + + /* emit unwind code bytes in big endian. */ + number_to_chars_bigendian (frag_more (byte_count), code->value, byte_count); + total_byte_count += byte_count; + } + + /* handle word alignment. */ + int required_padding = (4 - total_byte_count % 4) % 4; + if (required_padding) + { + const uint32_t nop_chain = 0xe3e3e3e3; + md_number_to_chars (frag_more (required_padding), nop_chain, + required_padding); + } +} + static int seh_x64_size_prologue_data (const seh_context *c) { @@ -1263,6 +1341,195 @@ seh_x64_write_function_xdata (seh_context *c) /* Handler data will be tacked in here by subsections. */ } +/* Write out the xdata information for one function (arm64). */ +static void +seh_arm64_write_function_xdata (seh_context *c) +{ + /* Set 4-byte alignment. */ + frag_align (2, 0, 0); + + uintptr_t func_length = 0; + expressionS exp; + exp.X_op = O_subtract; + exp.X_add_symbol = c->end_addr; + exp.X_op_symbol = c->start_addr; + exp.X_add_number = 0; + if (!resolve_expression (&exp) || exp.X_op != O_constant + || exp.X_add_number < 0) + as_bad (_("the function size expression for %s " + "does not evaluate to a non-negative constant"), + S_GET_NAME (c->start_addr)); + + func_length = exp.X_add_number; + + const uint32_t max_frag_size = ((1 << 18) - 1) << 2; + uintptr_t fragment_offset = 0; + bool is_fragmented_function = func_length > max_frag_size; + + /* [first_fragment_scope, last_fragment_scope). */ + uint32_t first_fragment_scope = 0; + uint32_t last_fragment_scope = 0; + uint32_t prolog_size = 0; + uint32_t prolog_insruction_count = 0; + for (int i = 0; i < c->arm64_ctx.unwind_codes_count; ++i) + { + if (c->arm64_ctx.unwind_codes[i].type == end) + { + prolog_insruction_count = i + 1; + break; + } + } + + if (c->arm64_ctx.epilogue_scopes_count) + prolog_size = c->arm64_ctx.epilogue_scopes[0].epilogue_start_index; + else + prolog_size = c->arm64_ctx.unwind_codes_byte_count; + + while (true) + { + c->xdata_addr = symbol_temp_new_now (); + c->next = NULL; + c->arm64_ctx.fragment_offset = fragment_offset; + + uintptr_t frag_size = func_length - fragment_offset; + if (frag_size > max_frag_size) + frag_size = max_frag_size; + + bool is_first_frag = fragment_offset == 0; + bool is_last_frag = (fragment_offset + frag_size) == func_length; + + if (!is_fragmented_function) + last_fragment_scope = c->arm64_ctx.epilogue_scopes_count; + else + { + first_fragment_scope = last_fragment_scope; + for (int i = first_fragment_scope; i < c->arm64_ctx.epilogue_scopes_count; + ++i) + { + const seh_arm64_epilogue_scope *scope = c->arm64_ctx.epilogue_scopes; + scope += i; + if (scope->epilogue_start_offset >= (fragment_offset + frag_size)) + break; + + if (scope->epilogue_end_offset >= (fragment_offset + frag_size)) + { + frag_size = scope->epilogue_start_offset - fragment_offset; + break; + } + + last_fragment_scope = i + 1; + } + } + + seh_arm64_xdata_header* header = &c->arm64_ctx.xdata_header; + const + seh_arm64_epilogue_scope* scopes = seh_ctx_cur->arm64_ctx.epilogue_scopes; + + header->func_length = frag_size >> 2; + header->vers = 0; + header->e = 0; + header->code_words = 0; + header->epilogue_count = 0; + + header->ext_code_words = 0; + header->ext_epilogue_count = last_fragment_scope + - first_fragment_scope; + header->reserved = 0; + + uint32_t first_epilog_index = 0; + uint32_t last_epilog_index = 0; + if (!header->ext_epilogue_count) + { + first_epilog_index = prolog_size; + last_epilog_index = prolog_size; + } + else + { + first_epilog_index = scopes[first_fragment_scope].epilogue_start_index; + if (last_fragment_scope == c->arm64_ctx.epilogue_scopes_count) + last_epilog_index = c->arm64_ctx.unwind_codes_byte_count; + else + last_epilog_index = scopes[last_fragment_scope].epilogue_start_index; + } + + uint32_t unwind_bytes = 0; + if (is_first_frag || is_last_frag) + unwind_bytes += prolog_size; + + if (header->ext_epilogue_count) + unwind_bytes += last_epilog_index - first_epilog_index; + + if (is_fragmented_function && is_last_frag && unwind_bytes) + { + unwind_bytes += 1; + ++header->ext_epilogue_count; + } + + header->ext_code_words = (unwind_bytes + 3) / 4; + + if (header->ext_code_words == 0 && header->ext_epilogue_count == 0 + || header->ext_code_words > 31 + || header->ext_epilogue_count > 31) + md_number_to_chars (frag_more (8), c->arm64_ctx.xdata_header_value, 8); + else + { + header->code_words = header->ext_code_words; + header->epilogue_count = header->ext_epilogue_count; + if (header->epilogue_count == 1) + { + header->e = 1; + if (is_fragmented_function && is_last_frag) + header->ext_epilogue_count = 0; + else + { + uint32_t start_index; + start_index = scopes[first_fragment_scope].epilogue_start_index; + header->ext_epilogue_count = start_index; + } + } + out_four (c->arm64_ctx.xdata_header_value); + } + + bool has_phantom_prolog = is_fragmented_function && is_last_frag; + if (header->ext_epilogue_count && !header->e) + { + seh_arm64_emit_epilog_scopes (c, fragment_offset, prolog_size, + first_fragment_scope, last_fragment_scope, + has_phantom_prolog); + if (is_fragmented_function && is_last_frag) + { + uint32_t epilog_start_offset = frag_size - prolog_insruction_count * 4; + md_number_to_chars (frag_more (4), + (1 << 22) | (epilog_start_offset >> 2), 4); + } + } + + if (header->ext_code_words) + seh_arm64_emit_unwind_codes (c, prolog_size, first_epilog_index, + last_epilog_index, has_phantom_prolog); + + if (header->x == 1) + { + if (c->handler.X_op == O_symbol) + c->handler.X_op = O_symbol_rva; + + emit_expr (&c->handler, 4); + } + + fragment_offset += frag_size; + if (fragment_offset == func_length) + break; + + seh_context *next = XCNEW (seh_context); + memcpy (next, c, sizeof (seh_context)); + next->elems = NULL; + next->func_name = NULL; + + c->next = next; + c = next; + } +} + /* Write out xdata for one function. */ static void @@ -1271,13 +1538,25 @@ write_function_xdata (seh_context *c) segT save_seg = now_seg; int save_subseg = now_subseg; + seh_kind target_kind = seh_get_target_kind (); + /* MIPS, SH, ARM don't have xdata. */ - if (seh_get_target_kind () != seh_kind_x64) + if ((target_kind != seh_kind_x64) && (target_kind != seh_kind_arm64)) return; switch_xdata (c->subsection, c->code_seg); - seh_x64_write_function_xdata (c); + switch (target_kind) + { + case seh_kind_x64: + seh_x64_write_function_xdata (c); + break; + case seh_kind_arm64: + seh_arm64_write_function_xdata (c); + break; + default: + break; + } subseg_set (save_seg, save_subseg); } @@ -1362,6 +1641,23 @@ write_function_pdata (seh_context *c) emit_expr (&exp, 4); break; + case seh_kind_arm64: + while (c) + { + exp.X_op = O_symbol_rva; + exp.X_add_number = c->arm64_ctx.fragment_offset; + exp.X_add_symbol = c->start_addr; + emit_expr (&exp, 4); + + exp.X_op = O_symbol_rva; + /* TODO: Implementing packed unwind data. */ + exp.X_add_number = 0; + exp.X_add_symbol = c->xdata_addr; + emit_expr (&exp, 4); + c = c->next; + } + break; + case seh_kind_mips: exp.X_op = O_symbol; exp.X_add_number = 0; From patchwork Wed Apr 9 14:14:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Karpov X-Patchwork-Id: 110121 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 405963851162 for ; Wed, 9 Apr 2025 14:15:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 405963851162 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=microsoft.com header.i=@microsoft.com header.a=rsa-sha256 header.s=selector2 header.b=Jp7rKqY/ X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2072f.outbound.protection.outlook.com [IPv6:2a01:111:f403:2613::72f]) by sourceware.org (Postfix) with ESMTPS id 1CF36384CBB1 for ; Wed, 9 Apr 2025 14:14:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1CF36384CBB1 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=microsoft.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1CF36384CBB1 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2613::72f ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744208051; cv=pass; b=DEQB3f9mOMC6ZdGUcsvJCliZcxFcVgkwVUPyM3ADX1bJNnjSWBn1hxSL2W2zNZeoVFQgz2K/z6wFPn3jB4yTGbawrvXbGesx8BmAwbogM1hYAbyPrJyseHVdBwNa+wrBBq9AF+l6Hexny36xBVm3jT9HiPHyZr4qB04khabDOJg= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744208051; c=relaxed/simple; bh=fDmpzoG2/Lw27wOGENw16o1UBGjfNdPb1YPt3ptH9g8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YaYojP3GUNbO2T7HmIHxcv3pZHEBhGVXz7Nl9Z29da3RUHu//wSJY4ZR9lpa00Qi910iLUKv3HuVE89jzsUvBoZiA0sZp5jKaPcA4aEw5w/Zcd30GNU5iEiUglXpYMQhgg+M1TWLIIsq3RCmY0j7YqBoj62cTrnaFbP1iaNneaE= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1CF36384CBB1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YmJUwfrFsJqOeCLpMcz97fiRumtusPKvenvBavsie/0JBosxojI/UCqHpSc+nsxl34cgTAfwzXNX0F0iLW8ngoluBAg30LN8ztKCawfS2BJ5chOQPNYTwpWV3vjFTlInuHHQkH/U8mX/tF0Zvbqnq0VBnyDx7FHA/ZeVqCiu6v08BHJHMmLyL8zwdkG18pF9qKgZZFr49wjYX2pZwdXN4JT5fvg60NznGYcvjO61mKSXxOWl+6xJ8LDpc/J+aV11i+HI2HLcZkDujRMISogdyq0LHOWEpXzDmnsz2nmBZvsUb23uarq9tfExO9C3vC/8uh/GPSBOuGuPh5k4I+rQig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=6cXJaZJ0oDOUxkan3Hl3vHQbQWsxjRDifq5sWz7GruY=; b=wERXr3QX5LrFSXLyrXq0c9hdzsPN8qEhSyn6CFTbnA4D2png1h0icf+ufyXhB60M21jJvITs9WH/G1CdS2Y4e1VU9u7i9CLBJHH435EfudYEEzGoPyMrGHWVkGBT6zcbrGhhyHhckE4P7Ex/ttqPQga+IJQZvd6enjcPeiTqHSFdPgOVvSD3VSwv3BCJ35zEWibLnIwA/US/PpHhM9kBNmtxKNCpIzktGdYTuZF4qaSp+/iwT8mqlrjNqbrWJ3zb/KmqyTXKby0hlvys1cP8U2DhxUSrHNoolEdJ7yHkjKgK2DxNb5/4Aw8672QVJQw1gE0hUq4gdqUpomhrgB7dug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6cXJaZJ0oDOUxkan3Hl3vHQbQWsxjRDifq5sWz7GruY=; b=Jp7rKqY/bcPhrD7PqUL38HkCXc1x/vWjdkZfZxrHVWOupsuXbFHufc+Oa17HABqxZXHkUhIloL5bpxQMnxfVQ0+kU6XQtlHBJIMtfLSJkLIl/w1MXQOwKNpES108uQ/OyqwbQ9chAoHoAilOv33GXdn5ie8VDMj37Fwg6Fn+R2A= Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com (2603:10a6:800:270::12) by GV2PR83MB0901.EURPRD83.prod.outlook.com (2603:10a6:150:277::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.5; Wed, 9 Apr 2025 14:14:06 +0000 Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb]) by VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb%5]) with mapi id 15.20.8655.002; Wed, 9 Apr 2025 14:14:06 +0000 From: Evgeny Karpov To: Binutils CC: "Richard Earnshaw (lists)" , "amodra@gmail.com" , Radek Barton Subject: [PATCH v1 6/7] Apply SEH to AArch64 Thread-Topic: [PATCH v1 6/7] Apply SEH to AArch64 Thread-Index: AQHbqVmn4VO3v0z7dEe46QwSUk1IFA== Date: Wed, 9 Apr 2025 14:14:06 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2025-04-09T14:13:44.762Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI2PR83MB0718:EE_|GV2PR83MB0901:EE_ x-ms-office365-filtering-correlation-id: 4cab3100-65c0-4540-0de4-08dd7770c9ff x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|366016|1800799024|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?9ZwMg9JNugIClxm0e5X5BKRHFe?= =?iso-8859-1?q?BinY0bCuzanjlw7pxmwAd4VPLD5beBYa2xi+Rq4G2NnnAwyIDDPX6wBzoE1e?= =?iso-8859-1?q?2CU1RTNBMbyPTHySBWFq26meHzkLBt9gQx25m971LwhNO4O3Zlno1Qh6NSeP?= =?iso-8859-1?q?ne0liQCKmm8Qo9Cm+Nl9xRt79KIvXFJzs/UPiGSnts2mFZmwPuzPqL41KmlQ?= =?iso-8859-1?q?5RnRW/edfpEen8REgxeh8FRSUCdwOag2nVek6s+aFB5Zu8RNtj1E20bKzlqu?= =?iso-8859-1?q?3gXj/Pc/IAYPWdMSyTXS8kK03xyr4Ko75KYdnm77X7ASagSQjcTPfkF6FPCH?= =?iso-8859-1?q?zVWvyrLk0pkvXuFxvb6SWkCqowOLP1Z4TiEiE2P1X8nvJlOkzlHsiHK0JEyy?= =?iso-8859-1?q?t2+ZzAVr/i6RGN45yNj2gZYwes3BboCKF7dY8B0nWVum73ldeegcup84OQLa?= =?iso-8859-1?q?byhIp29NqH+t/+wqnKsdSYiFX27TgyIiS7w0pDn0R+V3I4gchuoRQdhNqa8y?= =?iso-8859-1?q?vPAfMeZ+R2oJmYoON6lohwBpOpPxNs+jrzJRlNlqlXr7YJkOg4pgB1T39FkJ?= =?iso-8859-1?q?TNEQ1woy+0XTRNl20EragD+Up1coYtDdCLY7CQKEMgjAPRHhFk/c+EqPXLMc?= =?iso-8859-1?q?Fwjc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Oe2BPNtshd2GzuLkImh/AOBoIc=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI2PR83MB0718.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?1J0biBRscVFloj8eDC8TAGd?= =?iso-8859-1?q?gw387KPTzahXiSzmFzI7AeAaoI4rKsPjkNtqBbRIF9G9hbP5dWpLUTeBHawP?= =?iso-8859-1?q?YYKdF8ZJCDYSMRThUBnvW2nw4BHcjk6VigXFCQzvbPFA0qPxPwvVODAOaCL2?= =?iso-8859-1?q?W0ZyGXZ9W2qPEk5BAcfJ2ZCx2mbOmIqAQZakYZSMmBPPF/XttyNXVtHAWcVV?= =?iso-8859-1?q?YfN5K3xpXhx+eNJZLPFXdMCXWzGM+6a69sZPzCr9/UW0Q73qas10tKPkdlah?= =?iso-8859-1?q?FmtkKdjopgOshAiAOPI2UlH7XOit0RddrQ+jJxrGUHjfzXKVeBnthI8EntWC?= =?iso-8859-1?q?MVjznefMmVN1IdhlevlxhdoKYY6l+FserQQJ8JMQp8fiZORDFQSQ0Nkd7jKP?= =?iso-8859-1?q?Tiva8Wxcwv7KQ5kIx7Y7zXwxZSYePAm32RfnjJcjfuavtIdux2sb6nniojHf?= =?iso-8859-1?q?H9AM2BBvfMqYpKNTvFNqqnm+NhmAX7qCr0YQ0BMUhaN3CgTaMSKS59SicJND?= =?iso-8859-1?q?CO+tg46NhlTkOH7f+RxmP0wygs64DYzDvI8x6AkJGLxLBlVOTx6tyiT+a+fX?= =?iso-8859-1?q?gcjjlJxICQJgmLGekWf8/T9Dc55CpabFnFBuwz2vzNANwqgeUHQugQnc2+LB?= =?iso-8859-1?q?ErBieCsuwLsAGlegoAvSTighQjPZOccYWksC6b9T86mwT0f7IDzo4uyCmeKq?= =?iso-8859-1?q?MF0g94eq1FyrDFpo86+bUOd+79ZbeQ3wE4ueSqXuOmNTb5yCwOUVpD5wPoHQ?= =?iso-8859-1?q?iJsHA1bTRs3Rmb7InGk31+oGFVq7NYhf5Q0rDRcEd+HABzX1sqp6vyjOeOeC?= =?iso-8859-1?q?IJvfslT1mKAur1Z3vf+nvWuc4r5D+Nzqy+Kv6e6Tvtne2VdFpw9tS4BkIhQb?= =?iso-8859-1?q?8fatqqC7HOX7T/pLXUEalDGd1iEgW5M608uG49KSogky8a1hAlnWyxIgSwde?= =?iso-8859-1?q?pl8fbW+bi075kpmiebA3LVbo/7SttOHpIQ5YEiKKVPqd/+FU1T5s+gRaTWPa?= =?iso-8859-1?q?sm8b2luRHltWTN4nGUwtbX2S2jSgnAmTIpUGle8g9kPqXISpQaD5tP/S/8v7?= =?iso-8859-1?q?SScxVXySg4VZlajiErXWQCGM8pS4ZIe+maPTTb/gL1QiAagdjEorRj55jXVv?= =?iso-8859-1?q?6jYN2bg+KTRQxKkWnscSVKDzvKP3Vdm2pqZWmsexD9s6FKTl/cx6xu2A4lOQ?= =?iso-8859-1?q?tH5iYu/Ne1ynq5HvHe4rs6HdHIsTMEtByMli8zpvUyeHyyfpfEW2hlmCiON+?= =?iso-8859-1?q?6k6OucMaHrvjZVsbdf/CfGAo9VJOafTWC58pbtxd9m/TjyXu86YDzlGgAncL?= =?iso-8859-1?q?ScGpSG+8VFER5JFQ4f//ud73S4M7AgFsoH8l2DvtpqgE7yplytzmTvDBcnqq?= =?iso-8859-1?q?DlYb3qmB2Op63ZohnLvOr8NIiC7juvNZoJGaP6XQMpqFm6dYBdXpAsJkNuhb?= =?iso-8859-1?q?9LbxH2kTekh+rnv34arMdViLxBsJLnqismVqLu1ZDUuQe1vhbuiXtuaGU5YO?= =?iso-8859-1?q?fqKUiy1W1fihdPxmoQmsXKn/7iT8BzkuDatNdeP2v61nC/7jqONqfdIVwKjX?= =?iso-8859-1?q?mFj/Je4emqtUKJ9l4hGj2EeXJsce/lwytXyzw/POfmL0lFCCI+G3tLWMojh0?= =?iso-8859-1?q?wogAXOrtMZ1sblUkS?= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI2PR83MB0718.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cab3100-65c0-4540-0de4-08dd7770c9ff X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2025 14:14:06.5052 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7dcL1cMeROB868iDlU8hSC6HSPvvNPaPl3Ym9wX2JQwVGMF1Jfi/8vWJtLaNevPV38lTbI8GDb6jgKf+YB9diw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR83MB0901 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org This change introduces the required commands for SEH on AArch64. gas/ChangeLog: * config/obj-coff-seh.h (SEH_CMDS): New. --- gas/config/obj-coff-seh.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/gas/config/obj-coff-seh.h b/gas/config/obj-coff-seh.h index d82d88cf901..28257488350 100644 --- a/gas/config/obj-coff-seh.h +++ b/gas/config/obj-coff-seh.h @@ -113,6 +113,37 @@ typedef enum seh_arm64_unwind_types {"seh_code", obj_coff_seh_code, 0}, \ {"seh_handlerdata", obj_coff_seh_handlerdata, 0}, +#ifdef COFFAARCH64 +#undef SEH_CMDS +#define SEH_CMDS \ + {"seh_proc", obj_coff_seh_proc, 0}, \ + {"seh_endproc", obj_coff_seh_endproc, 0}, \ + {"seh_endprologue", obj_coff_seh_endprologue, 0}, \ + {"seh_startepilogue", obj_coff_seh_startepilogue, 0}, \ + {"seh_endepilogue", obj_coff_seh_endepilogue, 0}, \ + {"seh_stackalloc", obj_coff_seh_stackalloc, 0}, \ + {"seh_handler", obj_coff_seh_handler, 0}, \ + {"seh_handlerdata", obj_coff_seh_handlerdata, 0}, \ + {"seh_endfunclet", obj_coff_seh_endfunclet, 0}, \ + {"seh_save_reg", obj_coff_seh_save_reg, save_reg}, \ + {"seh_save_reg_x", obj_coff_seh_save_reg, save_reg_x}, \ + {"seh_save_regp", obj_coff_seh_save_reg, save_regp}, \ + {"seh_save_regp_x", obj_coff_seh_save_reg, save_regp_x}, \ + {"seh_save_lrpair", obj_coff_seh_save_reg, save_lrpair}, \ + {"seh_save_fregp", obj_coff_seh_save_reg, save_fregp}, \ + {"seh_save_fregp_x", obj_coff_seh_save_reg, save_fregp_x}, \ + {"seh_save_freg", obj_coff_seh_save_reg, save_freg}, \ + {"seh_save_freg_x", obj_coff_seh_save_reg, save_freg_x}, \ + {"seh_save_fplr", obj_coff_seh_save_reg, save_fplr}, \ + {"seh_save_fplr_x", obj_coff_seh_save_reg, save_fplr_x}, \ + {"seh_save_r19r20_x", obj_coff_seh_save_reg, save_r19r20_x}, \ + {"seh_add_fp", obj_coff_seh_save_reg, add_fp}, \ + {"seh_nop", obj_coff_seh_save_reg, nop}, \ + {"seh_pac_sign_lr", obj_coff_seh_save_reg, pac_sign_lr}, \ + {"seh_set_fp", obj_coff_seh_save_reg, set_fp}, \ + {"seh_save_next", obj_coff_seh_save_reg, save_next}, +#endif + /* Type definitions. */ typedef struct seh_prologue_element From patchwork Wed Apr 9 14:17:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Karpov X-Patchwork-Id: 110123 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 8E3A6384A46B for ; Wed, 9 Apr 2025 14:25:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E3A6384A46B Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=microsoft.com header.i=@microsoft.com header.a=rsa-sha256 header.s=selector2 header.b=Iccn9xGb X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on20704.outbound.protection.outlook.com [IPv6:2a01:111:f403:2606::704]) by sourceware.org (Postfix) with ESMTPS id 9076B385DDD0 for ; Wed, 9 Apr 2025 14:17:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9076B385DDD0 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=microsoft.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9076B385DDD0 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2606::704 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744208274; cv=pass; b=gHQjKT+BW36Bo6Rq+G6GFmMm2UlbmP6ip/q0kQexv2hGu7DP2ID9LmgjilYBH4XPgAMSS0OM4dFJzs6On9kbnw9UKNH7gb6BYXVUjZrVrk9LGGNhnmtdNB3RxZRgySbeRmPR/+FsWcg+FvuMF7z0CBhjig85+MoDUFznx7AGvM0= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1744208274; c=relaxed/simple; bh=UXImm+8qOdK6MXAF/9zy0SRDzBrRfQiu514oc+fiVig=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jYwoYAcnetjrbVUdr1c3MPvmJ1ZHNWEQ0BxJICbqTzHs8mYWo1Qo3jbc/i72jvAqiuI0ib1nzE+zmzvV4+fjNtD8DEvTOhbtHb1rhuA8w32aZrcja65B9Bkp7QvfCdIJrhn92UzQ+pWUpMPUqQmWodB2GSu4dBUJoPEU6PYLZtY= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9076B385DDD0 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=k/udRRQr1tIRyziN0h8jrAsLU1/8DQArThrOxsBPN1L0eXVMHyC3w04rWb3RmLJfdayTAKbamti5jS4gCoDX0Y6GYQ82gBoAgZfQWM1FvnpLD0RhUtIZJx7p8dkjMqoNEcScq0b5bmS3Q8NCYfxriSCZRrhorIJj/MpHJzm6Zu8+5YG2kCC48b+QXXj99lhoLIdd7IPlqQJLDXuSJWgndkAl79t4bm6yrpb7+86s6togO6Fy6fNFji4jP11gdCdYwVuVbVzT6pIQEBqnzqQLSv44G9io+W4n1BgDmNqMl9OAhVV5WdvV++0T0I6+f9NLMnp/OsGD3MgFj9wXRbah4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=y/f3yt3laWLRJs06V8sd5HHkZ7dXNZkDwbz8yXs08AU=; b=EG0N4m7bBtAYBowQCthwLm0K9AfBdWc/rrdTW9yUSKfnBnab+IguqwR5WkBThznRbhvcmdDkhlT5Py02Agbic1s76TSmCP9BKPvFeK2M6nuiSRuyyhG10tCfpdLNQvBXTxvgOJ5jw9JqStkKAszeo1NQNhf6oZzOvYphVOYUN1RM15kiIbenXUIGSpbR6RVHhJ4q7YyHMpbZC5G3pZ4b8MndcwmsTkj+cI4zLnx/l7i+dJbd7A0CQ8aq8RSDMCfSeuIkwRJCICtrc3hKu9gHxvtRTPXq2FvLjwc2bXH6RUJ7M9PHvNAS+TdSU/lgcvYQwJbtcXPSnzCNPRnJkGRldg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y/f3yt3laWLRJs06V8sd5HHkZ7dXNZkDwbz8yXs08AU=; b=Iccn9xGbjhCm9/pwQxkFAkbvFtaC7BQZufD0WqCwpwXIVD9oB3pn+ikV6bZ1YyvubvNd6RVIVU8r+I6JfWGhfx1h/hE5PyKuGmc58QxRWQxxgGiWXKwOtmozYTYje+WYCDIvPGZkTciC0JR/kqD9ObsgBVMsypdL13dilUS84dI= Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com (2603:10a6:800:270::12) by GVXPR83MB0606.EURPRD83.prod.outlook.com (2603:10a6:150:154::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.21; Wed, 9 Apr 2025 14:17:49 +0000 Received: from VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb]) by VI2PR83MB0718.EURPRD83.prod.outlook.com ([fe80::9b44:280f:9a72:cfb%5]) with mapi id 15.20.8655.002; Wed, 9 Apr 2025 14:17:49 +0000 From: Evgeny Karpov To: Binutils CC: "Richard Earnshaw (lists)" , "amodra@gmail.com" , Radek Barton Subject: [PATCH v1 7/7] Add a temporary workaround to address the issue of calculating the function length. Thread-Topic: [PATCH v1 7/7] Add a temporary workaround to address the issue of calculating the function length. Thread-Index: AQHbqVosMq9HxxRFS0OPd2LLKk2r3Q== Date: Wed, 9 Apr 2025 14:17:49 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2025-04-09T14:17:27.334Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: VI2PR83MB0718:EE_|GVXPR83MB0606:EE_ x-ms-office365-filtering-correlation-id: d3906285-b286-46d6-c7e8-08dd77714eac x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?NBQw5EU+FSGrvX6JcexwL9u668?= =?iso-8859-1?q?iaTBmEsg3aakatPRuiCtpoIwLfr4SlxC9E1GFf2xwHyGNFJzLFTThci2NzCa?= =?iso-8859-1?q?jkpXCwMD1yslEqwuv8wo+Ult3lQJLEqBFjjZBtCxFcbKuqbmWpmc1bawMZbR?= =?iso-8859-1?q?F4oVUIJjwuZ4YhgbanuWgRfcbjC0U7zWzAPh4Ez4YcgTR0ePuPAhXU4TpOId?= =?iso-8859-1?q?k3xWSWKFCHP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Gw9MFkfrcLFnFkLnK?= =?iso-8859-1?q?7CAT0ddDpVQY/TLQ7U7OX7vimsZYeKtWpQiq5+k/lwxCEmwrG1T+6oX2U6ok?= =?iso-8859-1?q?9onojp+5H7R4QTU5sn1/IsD13gTJWasAKwx9vnnkC6Ol6x/9pseD4u/EtAhK?= =?iso-8859-1?q?8LeOxpnyiscil5+KMnhFneTAm9ahQSvoRwx8FKfdxGTMiz0oZgyP80bX1V5M?= =?iso-8859-1?q?4RqfmYL66TZkYB/1b975fgM34uHzfAP/+AC+7QiFr4v1QTATahoTBdGxB2ML?= =?iso-8859-1?q?6iXD3RC1yoSVWznylbim7spxzMwbGM7YmEoX4TXwrPuXsd5XB/oo6QPM/nwL?= =?iso-8859-1?q?UOVWgWs/n0hy50jZeQ5YQuReLNQBDSI5/5ncromZhbB1JhpZxm5/1yHPcPg0?= =?iso-8859-1?q?t5umbsQrsb3E7JbzRon687QdQLug=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI2PR83MB0718.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?HbX8AaC0M9ZX5MK4jfY1ZXw?= =?iso-8859-1?q?O9bYcBAhMMiOEpLrbmWhj2jKuNxC0uwRXICwFvqsAj1sKSeUxomPO1czqhV9?= =?iso-8859-1?q?DcoRIIXtbtxw9ut2xy5jhXkYe5BTHzo25iOtYkMqwQeg7Cf3UbelKn2I/UnS?= =?iso-8859-1?q?WNDnuzCNGOmdlxRuBabSwKWWaOPjYjpWbHQTDTbAoQ8efXYZRff6e8E/y4xG?= =?iso-8859-1?q?otx5wK3gIcPZashPJ+xpdHpDKjakDn9tUntvPkUAdy6CL7jxu0tguCICxbzT?= =?iso-8859-1?q?asgHlNV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I+tjpneBbBgtPJp+wC1otdbNe3U8UQB?= =?iso-8859-1?q?gSuWpcyROwvkbdbBBfDISQbccpr/q0nceGuETVFvU0p4tlc+vVI0ft4XzyL+?= =?iso-8859-1?q?NydMASJBgWm4BhE7ram56AzPnCxL3aHRA9no0Gsd5NrzSVcVFbtKQJlr3BY5?= =?iso-8859-1?q?jPhAUCzRi2A/UAYBSwtZiskyqbKKK+GC7e1FTj3glAF9KjdilOtElzt3lkWH?= =?iso-8859-1?q?OqPuHupOYk43TltistndM8wzrjk/KQDowr8UdmqoG2skPn9sttslSGArf9w7?= =?iso-8859-1?q?J0/M6EYd+61V3OBPwlnnSauzqVygZypSZZk1h8tadHQ7ajZEunRMjNvHLZGu?= =?iso-8859-1?q?j1+kszMcysWSrNSy8Z7VVm43DjGVVhkzgW007Sp7yseS8JsTwkxkgg7PiBqr?= =?iso-8859-1?q?F1zKp0T6RK6tPjFlrMnjhJMmjgmL2SQaplnSAEuMeI24+abxP80xxqjlpzyy?= =?iso-8859-1?q?W6fllgI1QWGE6dbHJ?= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI2PR83MB0718.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3906285-b286-46d6-c7e8-08dd77714eac X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2025 14:17:49.1341 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7X3wcgEazdRH9nd3W3SxhRSDdkXh5W75FoeJGuPo2hNwC0+GLuIy50bKvwcbPy4/Ersb14kqa9WSllsG0V0bUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR83MB0606 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org This workaround will be replaced with a proper solution before merging to resolve the issue. gas/ChangeLog: * read.c (do_align): Update. --- gas/read.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gas/read.c b/gas/read.c index 31b89b7cbc8..647e58851cd 100644 --- a/gas/read.c +++ b/gas/read.c @@ -803,6 +803,11 @@ in_bss (void) void do_align (unsigned int n, char *fill, unsigned int len, unsigned int max) { +/* A temporary workaround to resolve the issue of calculating + the function length after applying the code alignment. */ + if (subseg_text_p (now_seg)) + return; + if (now_seg == absolute_section || in_bss ()) { if (fill != NULL)