From patchwork Wed Sep 20 23:03:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 76471 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 695433875442 for ; Wed, 20 Sep 2023 23:05:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 695433875442 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695251128; bh=UYZnqsTdFTwZOGnRs8QkBHkLbYbyo5IAogtHFlR6k/U=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=uJEuS/5YK4jd4QDITfTPvKsPc0crWbmhC63e6r5N4xoekoK820GvUuhtVUGMwe+rr brTfsa3TQC6Xdo1n85EHri9f65ZCyXl6qYfuMCyPSrmxZCgc62Vw1Q9xM8wDE3yc0u MjxR0ZmY44bEFrTMiQidMpDgKPZF2ndRaxGMogFw= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 65D6D3856DFE for ; Wed, 20 Sep 2023 23:04:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 65D6D3856DFE Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38KKJOYA022819 for ; Wed, 20 Sep 2023 23:04:56 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t548bgenx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 20 Sep 2023 23:04:56 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38KKjLlm030978 for ; Wed, 20 Sep 2023 23:04:55 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t52t7r7vn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 20 Sep 2023 23:04:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dp/hf8fwE7N9XRWEsQtdB36CU4chFPPTxRWNlf33eBihSafcY3d+u1vJHQC4TGljM9AighXX/W9u/gY2mgyTFV8iY+xsXdOwR1ocVdT63y6tloboC3zzL68JerYPVcGSHOoRdvwKg6VQjHnMeoJtaAEVJbeLNrDpMfJYzMnAwTgFZpAAWuGyrbzcB4NaaxgLL43D21WSrb1iku+ce7z5IckG/0HoDQEVOIXTSK0BCFYQnSQjHF32GiK55g2yY+VvETAMjpfbRfT0c+uEToF9v0V/v7rN7fCrXQW9KO+qCuQcro2JHR7XKNHc78jBGay8Y4Duk2nCJSpxL8nQaLDZtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UYZnqsTdFTwZOGnRs8QkBHkLbYbyo5IAogtHFlR6k/U=; b=jd5lfFGM3j1TtmQPzB0YycNUzIKvsYk2QiR1jyinaZlbO+O3Mu9LlgYJc+NnfbRqPaZmQMLpHk810e3ZmtAAhIENW/cWw9Ye+XTpwnFOu/vPIj0N4Eyt5yuk+dNIfhc8VlZWRlqwVNI/dAiP52FwrEIdSMbsgA2nAu28EmwzaQtqjmeu/Qr5VeHBsOHu+fDcGAYLQNkoEQZyfAedf9+exjUQi8tpEq7jM0uQbd1ironlvdaFsKl2KNQR2nvHmhsc2rnuMizHRHLZSut3Kc3+BU8XIXgzFzt1uqNoYj24a1GPFKa5guKl4wolXACbKezeOPqrdrW5Lz611pfRI4JHYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by CO6PR10MB5553.namprd10.prod.outlook.com (2603:10b6:303:140::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.38; Wed, 20 Sep 2023 23:04:50 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::44f7:ba76:db28:606e]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::44f7:ba76:db28:606e%3]) with mapi id 15.20.6813.017; Wed, 20 Sep 2023 23:04:50 +0000 To: binutils@sourceware.org Cc: Indu Bhagat Subject: [PATCH, RFC 7/9] gas: scfidw2gen: new functionality to prepapre for SCFI Date: Wed, 20 Sep 2023 16:03:59 -0700 Message-ID: <20230920230401.1739139-8-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920230401.1739139-1-indu.bhagat@oracle.com> References: <20230920230401.1739139-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW4PR03CA0053.namprd03.prod.outlook.com (2603:10b6:303:8e::28) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2158:EE_|CO6PR10MB5553:EE_ X-MS-Office365-Filtering-Correlation-Id: 86e3b5e5-14ca-40bb-4494-08dbba2dfe29 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RA41iK6/8JAOE0uV9i+xXRPX1FPwXXibAtj8olJ+i5WXmfilgd5ytXuTb8TlrffI9inHmi1mpHgmZWTwbOsQCdHhRfqwrosFTvjNeopHtc2nimgiKBUVYg9xmFqgsd/T4SOpnoxG3sS/4xpn0Jt4H5aj9RjpuQ3XU8AsL2QaxhKL3WI8V1YJihzgSSDwAT+saj/PO2DPiqvMxaXJhv7uEq29DVkiD4yXh7aCucZyY8oFM/L+u3/to6RFjMB9b/WZphPqfifpHBgwQJ2+FoBABmy7xtr25uRcmLO+1w2d48pyrCZwS7kvUDl4kFjtdTmcUTFxYK4u545UIBekSZ+JooYZrweSwB957pUNjjpCldPaUzPpgrIdWGCkacuzrk7fStp8rmn5jRhFOvsH8oIEaj9QwtWSkBodMnt/v6/zYauRPe+TSq2/t+ZaSw+ZKvupqlHRogzw+pP5G6dHiSi6CE4bN64QWGHOLR3NZvMr2LVBW6tLpA/b6SUmL/nmkNP2ndxFCz2CsrWf6B4IMAmlHDWXeqjytO01PGLC/w9OyhElp++5LaOhA048wa6VEP3D7PkwbIWuVsvhrRZb9XC+3aTiTcJrX75EeZYnho5D3/A= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(376002)(136003)(366004)(39860400002)(396003)(451199024)(186009)(1800799009)(41300700001)(8936002)(5660300002)(8676002)(66946007)(2906002)(316002)(6916009)(38100700002)(66556008)(478600001)(66476007)(86362001)(4326008)(44832011)(1076003)(83380400001)(6506007)(2616005)(107886003)(6486002)(36756003)(6512007)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UNSV1o9eqF73XShF5mxTcWD6TSrQ1IsiK3RzYQ+YZUtQfKjAwJtm8TTC3rEoCi1g3MLNs45vSxig0dCItRwyO9rB18e8DkQe9v4CJHCOsbkEGjKKP/CjAa/xl8dA/4kLfguVU84jR1XkV6BvihEGo2YsK9nEQjHI3FzZxEfWqrirVteMHenGz+/dX01MzfJf3XVZtlDzq9sxpd+shbC4crRwIU/H9AqQRLJ2C0lygb5fy4m8/YYAi89uAQLrO8RFXfDVuAxqFSVyeusob1yvfWlyBc0ZPeQs072gw02SFpYr7/EfuWKF+RQ08jfxXoJoGMwf6Mo8AP0FJj7pwJWksLP/28Ad2rfAVo5J5hVlihbRY+MaC8k+CRXZE+wJTZsNhYVVAbv7HmggSItUL6fVUFAzJ7qNL1fn0QV/tc7oX/ymzOCkFEdI7XB1CMiuzDKek212Z8tDz3qXO+D+4bQ+0MO8FSVkwfwTEzfWAFe8a/v9DAMEVIUh4yxs1WJO5H4bh7dafG0LRP0IHS72wuw5fQrE4F1mLM5AZZAebPks5TyS3ic33snfX9MFb2ZB4bBofI9rKP9b3hc1bjXHOsJ2JSczRHFSXSIQOP5+H2qo7Z2h6dcQvLid/uW66oDheEjKlF+OquHlUO1+BSn/D66H2Ov3foIGj0z9gkmoBBdx3wkZi/PVvgYoBpxzPncfMOp3zQ7TOjReqR/OLAlrh8HQS8CFZl3qSuRWBv8J7444fGyVOcrI5opFeGU1ejalSXjlNz8Px8iygMHaF+QOiZfS4e+gXlYlaLTBkfKZhXskCVObRgZUbebD4DKZl4P1yAnzs/8kjuowm/9JWwlHkkyrpbCGBHTGSmaPVXSbyF0usmRO1jLG8UTSupXF57w97F52w+50VB7F4PpChSMAIdjYNzZGsE4he071iuEmR8uHe4x+BX1vtsvqZiycutAwzAYkwZBF7+E0xjqQZtZfWDmeu5qqW4T6U+YVSVMOWSIU/99j+ieAT1Y6EzI7hAvo/cJ0BPZO6q6nE8ttMHADamKfT0DGsB3or+XAEffnwK5DEcHLPrh6prQPHJSmhfecTzhx0jUiJSTNpbpZJzdamAWV9Z54qKceaYrdhEdS27EJ01DI98Ue8HjAceqxFoGtyNQ0kNMX+F01OPfsFFJfMR3oBgX/hL8TB8RRK0etC4qZJoEdH4QimUGpvxpaQMOw29cvR2k3UbsDYSF+TFti6qmBRaNmRCw6UQQ68Ojgn/w7LiQUV/oPWpwYM7uRriD09UopwoBk8zmqKWFY3m0W3E08xS7Oku1ojD3AL0gFg54vUxrRhXwDT7R/cUu36MZ262P4gpzMRMDDZBqj4fj2j2IFVnFOXm58e+sgX9GBRKvF43iHLkStrNgS7so/FNrCXYg7nGtMNfL2V++uRyQtUt/IaumOrELb2fqQ7g3+7DaAMDGJbZUUUU5VRZDvSX4i4GABRmRvK9KvBJoKqs4gsbtQPexlY1gSnCnINbzI8CggwfKdi1QjVAO9aN1NQ03LC+sJxL7sMY15G/1qMd69HN+c1wetAaQ9nugzNfmqn5BxCydCNgQbzY+LEN6HQxzx/DNOY44l2dg4VdQdTB1ScQNYFB4tWGQlg1zOf5reqCOt6LU= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: h5gZ5FaSnN8KqtdHefKORvWU7wngnkL9pwgoKSFAgvKflOoAMxbxLCALyh8HfNE0nM+LuZo8viuwblwmoRGzWcd82zFPKDKUWNdBJb66hbZj5DrbV69hh3nxY/LYs66HHMeowgHw0KwcoeEF35EjvWecUo7cbcB8JK3wuMByydf4nDUvQA4067F6X7xSW4HhQP6dqAvvbkZpFpCu32NVU9AJDKgpRXGpoBXsG41mHFzyMzJsc3Nx0eTP/4EndwtpnlJ9KdSLiORyDWO7JARRlZ+0KExRJpIQTHOfCp8EvMxDs/M+6jpmssfAFl8jdLkmxMw+0PDv00QeOaoRf0aIbaKfxiRT7jZnbuhfmV9Td25gCGa3xc742GtZE723aSR1NWtp+xErWZ4lDpAboI7BZlJEpHIBQmLO9sTNWH1tmfhcx9yAwvJIswwpELgrH6RwtPr3PxKkXr+mIJJhQP7cBthIm9d9Jy4+s2JwHqRJRdQ8pNoGXGEC3Ulopuim2Tp0h53T1nghPzDWdkXNoA9qUlQ8VuQEd3Mh+plEuZLDxZOJY4IcVwN3yulX2oUYeUCQ+/6xBVM7SlHg3zTRygH78xAIbWc58qh5FoWXro6qLnqnLwt9qWfL05r7+J6+AqeRE0mTzBNx72D24RV8mg80oIlQK2w/P0vgwZvH19Aro+E7AYLinz85fPzu7pMrhGlnksOu40TASPXvSwoIyflya5hOzPgnXZvkOe65K7G+hrXPBqyCq2ndYsLVbYxbHLWolxOrb1cyG3flfD2MPJdU4Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86e3b5e5-14ca-40bb-4494-08dbba2dfe29 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 23:04:50.6441 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9hx7gBSSccfBkTel00fuNxrQyPlcVTkIBJoDuTlIUhN9FWNf+USohSKZESn0zOkVu0zVQbJaexBeCvsgFjEMiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5553 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-20_11,2023-09-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309200193 X-Proofpoint-GUID: HglhqLB8QbonoZsc_7Qpa8hmJTHnNq8o X-Proofpoint-ORIG-GUID: HglhqLB8QbonoZsc_7Qpa8hmJTHnNq8o X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Binutils From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Sender: "Binutils" Since the option --scfi=inline still needs to be worked out, the implementation in scfidw2gen remains in the form it currently is. This implementation needs to be cleaned up thereafter. gas/ * Makefile.am: Add new files to GAS_CFILES and HFILES. * Makefile.in: Likewise. * scfidw2gen.c: New file. * scfidw2gen.h: New file. --- gas/Makefile.am | 2 + gas/Makefile.in | 9 ++- gas/scfidw2gen.c | 185 +++++++++++++++++++++++++++++++++++++++++++++++ gas/scfidw2gen.h | 35 +++++++++ 4 files changed, 228 insertions(+), 3 deletions(-) create mode 100644 gas/scfidw2gen.c create mode 100644 gas/scfidw2gen.h diff --git a/gas/Makefile.am b/gas/Makefile.am index 0e98ca3ec85..e174305ca62 100644 --- a/gas/Makefile.am +++ b/gas/Makefile.am @@ -93,6 +93,7 @@ GAS_CFILES = \ read.c \ remap.c \ sb.c \ + scfidw2gen.c \ sframe-opt.c \ stabs.c \ subsegs.c \ @@ -128,6 +129,7 @@ HFILES = \ output-file.h \ read.h \ sb.h \ + scfidw2gen.h \ subsegs.h \ symbols.h \ tc.h \ diff --git a/gas/Makefile.in b/gas/Makefile.in index fae3a47c144..87428bc46b8 100644 --- a/gas/Makefile.in +++ b/gas/Makefile.in @@ -170,9 +170,9 @@ am__objects_1 = app.$(OBJEXT) as.$(OBJEXT) atof-generic.$(OBJEXT) \ hash.$(OBJEXT) input-file.$(OBJEXT) input-scrub.$(OBJEXT) \ listing.$(OBJEXT) literal.$(OBJEXT) macro.$(OBJEXT) \ messages.$(OBJEXT) output-file.$(OBJEXT) read.$(OBJEXT) \ - remap.$(OBJEXT) sb.$(OBJEXT) sframe-opt.$(OBJEXT) \ - stabs.$(OBJEXT) subsegs.$(OBJEXT) symbols.$(OBJEXT) \ - write.$(OBJEXT) + remap.$(OBJEXT) sb.$(OBJEXT) scfidw2gen.$(OBJEXT) \ + sframe-opt.$(OBJEXT) stabs.$(OBJEXT) subsegs.$(OBJEXT) \ + symbols.$(OBJEXT) write.$(OBJEXT) am_as_new_OBJECTS = $(am__objects_1) am__dirstamp = $(am__leading_dot)dirstamp as_new_OBJECTS = $(am_as_new_OBJECTS) @@ -581,6 +581,7 @@ GAS_CFILES = \ read.c \ remap.c \ sb.c \ + scfidw2gen.c \ sframe-opt.c \ stabs.c \ subsegs.c \ @@ -615,6 +616,7 @@ HFILES = \ output-file.h \ read.h \ sb.h \ + scfidw2gen.h \ subsegs.h \ symbols.h \ tc.h \ @@ -1337,6 +1339,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/remap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sb.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scfidw2gen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sframe-opt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stabs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subsegs.Po@am__quote@ diff --git a/gas/scfidw2gen.c b/gas/scfidw2gen.c new file mode 100644 index 00000000000..6ae45183012 --- /dev/null +++ b/gas/scfidw2gen.c @@ -0,0 +1,185 @@ +/* scfidw2gen.c - Support for emission of synthesized Dwarf2 CFI. + Copyright (C) 2003-2023 Free Software Foundation, Inc. + + This file is part of GAS, the GNU Assembler. + + GAS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GAS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GAS; see the file COPYING. If not, write to the Free + Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include "as.h" +#include "dw2gencfi.h" +#include "subsegs.h" +#include "scfidw2gen.h" + +void +scfi_dot_cfi_startproc (symbolS *start_sym) +{ + if (frchain_now->frch_cfi_data != NULL) + { + as_bad (_("previous CFI entry not closed (missing .cfi_endproc)")); + return; + } + + cfi_new_fde (start_sym); + + cfi_set_sections (); + + frchain_now->frch_cfi_data->cur_cfa_offset = 0; + + /* By default, SCFI machinery assumes .cfi_startproc is used without + parameter simple. */ + tc_cfi_frame_initial_instructions (); + + if ((all_cfi_sections & CFI_EMIT_target) != 0) + tc_cfi_startproc (); +} + +void +scfi_dot_cfi_endproc (symbolS *end_sym) +{ + struct fde_entry *fde_last; + + if (frchain_now->frch_cfi_data == NULL) + { + as_bad (_(".cfi_endproc without corresponding .cfi_startproc")); + return; + } + + fde_last = frchain_now->frch_cfi_data->cur_fde_data; + cfi_set_last_fde (fde_last); + + cfi_end_fde (end_sym); + + if ((all_cfi_sections & CFI_EMIT_target) != 0) + tc_cfi_endproc (fde_last); +} + +void +scfi_dot_cfi (int arg, unsigned reg1, unsigned reg2, offsetT offset, symbolS *advloc) +{ + if (frchain_now->frch_cfi_data == NULL) + { + as_bad (_("CFI instruction used without previous .cfi_startproc")); + // ignore_rest_of_line (); + return; + } + + /* If the last address was not at the current PC, advance to current. */ + if (frchain_now->frch_cfi_data->last_address != advloc) + cfi_add_advance_loc (advloc); + + switch (arg) + { + case DW_CFA_offset: + // reg1 = cfi_parse_reg (); + // cfi_parse_separator (); + // offset = cfi_parse_const (); + cfi_add_CFA_offset (reg1, offset); + break; + + case DW_CFA_val_offset: + // reg1 = cfi_parse_reg (); + // cfi_parse_separator (); + // offset = cfi_parse_const (); + cfi_add_CFA_val_offset (reg1, offset); + break; + + case CFI_rel_offset: + // reg1 = cfi_parse_reg (); + // cfi_parse_separator (); + // offset = cfi_parse_const (); + cfi_add_CFA_offset (reg1, + offset - frchain_now->frch_cfi_data->cur_cfa_offset); + break; + + case DW_CFA_def_cfa: + // reg1 = cfi_parse_reg (); + // cfi_parse_separator (); + // offset = cfi_parse_const (); + cfi_add_CFA_def_cfa (reg1, offset); + break; + + case DW_CFA_register: + // reg1 = cfi_parse_reg (); + // cfi_parse_separator (); + // reg2 = cfi_parse_reg (); + cfi_add_CFA_register (reg1, reg2); + break; + + case DW_CFA_def_cfa_register: + // reg1 = cfi_parse_reg (); + cfi_add_CFA_def_cfa_register (reg1); + break; + + case DW_CFA_def_cfa_offset: + // offset = cfi_parse_const (); + cfi_add_CFA_def_cfa_offset (offset); + break; + + case CFI_adjust_cfa_offset: + // offset = cfi_parse_const (); + cfi_add_CFA_def_cfa_offset (frchain_now->frch_cfi_data->cur_cfa_offset + + offset); + break; + + case DW_CFA_restore: + cfi_add_CFA_restore (reg1); + break; + + case DW_CFA_remember_state: + cfi_add_CFA_remember_state (); + break; + + case DW_CFA_restore_state: + cfi_add_CFA_restore_state (); + break; + +/* + case DW_CFA_undefined: + for (;;) + { + reg1 = cfi_parse_reg (); + cfi_add_CFA_undefined (reg1); + SKIP_WHITESPACE (); + if (*input_line_pointer != ',') + break; + ++input_line_pointer; + } + break; + + case DW_CFA_same_value: + reg1 = cfi_parse_reg (); + cfi_add_CFA_same_value (reg1); + break; + + case CFI_return_column: + reg1 = cfi_parse_reg (); + cfi_set_return_column (reg1); + break; + + case DW_CFA_GNU_window_save: + cfi_add_CFA_insn (DW_CFA_GNU_window_save); + break; + + case CFI_signal_frame: + frchain_now->frch_cfi_data->cur_fde_data->signal_frame = 1; + break; +*/ + default: + abort (); + } + + // demand_empty_rest_of_line (); +} diff --git a/gas/scfidw2gen.h b/gas/scfidw2gen.h new file mode 100644 index 00000000000..c08cbb38a97 --- /dev/null +++ b/gas/scfidw2gen.h @@ -0,0 +1,35 @@ +/* scfidw2gen.h - Support for emitting synthesized Dwarf2 CFI. + Copyright (C) 2003-2023 Free Software Foundation, Inc. + + This file is part of GAS, the GNU Assembler. + + GAS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GAS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GAS; see the file COPYING. If not, write to the Free + Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#ifndef SCFIDW2GEN_H +#define SCFIDW2GEN_H + +#include "as.h" +#include "dwarf2.h" + +extern int all_cfi_sections; + +void scfi_dot_cfi_startproc (symbolS *start_sym); +void scfi_dot_cfi_endproc (symbolS *end_sym); +void scfi_dot_cfi (int arg, unsigned reg1, unsigned reg2, offsetT offset, + symbolS *advloc); + +#endif +