From patchwork Wed Sep 20 23:03:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 76473 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 728CB3882644 for ; Wed, 20 Sep 2023 23:06:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 728CB3882644 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695251174; bh=9WhMrNCSrwUvi7cas8SPGoQvhxfBHJcdidkH+7wxVcM=; 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=UQNcHwbSYVBiZ5clCtc7ms8NJIg63wKVnEolOjs4h+VyZJZ1iEx9K76/O4tCjn0vX L8KXuxuH8kSLl1LyedqSJ3aReEfh6iRE9o0UvTyIKBcm/dCghm/eWsUS2SDNm0orLf 7V+WiIUnDdJk8QwFCpFzVcFtigDoMu117q9tjamg= 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 F37BB3858428 for ; Wed, 20 Sep 2023 23:04:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F37BB3858428 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38KKJccw009247 for ; Wed, 20 Sep 2023 23:04:47 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t52y20jyc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 20 Sep 2023 23:04:46 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38KLsgvZ012088 for ; Wed, 20 Sep 2023 23:04:45 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3t52t81098-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 20 Sep 2023 23:04:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kzn4YR1CL8HZga1LaUmn5+KechAgpXAV4zUEL7uSKQkFXm9YyLxB/UXzOOQZw+xjpLFibt6hP5U+/3r2J1wCFQqOOJJyHxqE/AZHbNk9kRpoNS35rfO6ZQ53blwFEe/455lNAjXnbSOMhe11274yaatIWaS9mXpgABRqA/PpovHk3ttGN6//yPziHWQv7/3yGRAMolvBKhAzV/nTjyLIE0cDO7o+i3sBXg+w2SyJ4WvTjOfK45DpNRoKMwB6ESCKNwUaFSMG74dVET2SbHCtGP16SV8OEde4M5fqVGe7/QwGz1QSan9sk+DKp6aCdK69rIkbSj8poC/zG8fksLZ8+A== 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=9WhMrNCSrwUvi7cas8SPGoQvhxfBHJcdidkH+7wxVcM=; b=BUh14eeOviIdZeUP/hwD1Rd4dPHxmoVXY5ILBDUL9OjifwVklpGl4Ua8gg7m1Ow4i+e1XLnXnfh/HDgo3peBStWcX1HiPWtFesGN18MDSxaUggg3pFI+cIrLjU1DVrV7sYcs4rG09EbcdpmGc75i1An7vA/A+Wi0L+/Vuwp19AybvY90rMsWUTr1YOBJTHhXMVIUaLh0SlthfZBO+mETuezVxJMZ1vZx5pYbMPQ6hBh+BXLm6X1MUfkQfVPVS32m7NKCz+u78T46s4suHe8pKbvkvM7S2LaWUt6Yfej//dRusIMqka2rk5DgpgUyWyfyhk3T9bECtKBYEVQcRqkjJQ== 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:42 +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:42 +0000 To: binutils@sourceware.org Cc: Indu Bhagat Subject: [PATCH,RFC 5/9] gas: add new command line option --scfi[=all,none] Date: Wed, 20 Sep 2023 16:03:57 -0700 Message-ID: <20230920230401.1739139-6-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: MW4PR04CA0097.namprd04.prod.outlook.com (2603:10b6:303:83::12) 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: 3635b2b3-e7b7-4404-aba4-08dbba2df926 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rmNGo2/hGHIedQJpxkAI4YUwQdkatSdB1izdb0/FtE7Q5A4ccjDUMRarl7hvGoFRX2cbwNb1xKEyVztVQwYTfSbZFsjsfNm7YvMlq7BY4cUuKqNV3Igr8Va+rtvXHO7JxuBjLL+bY1tVPqrvh9ePoaWfc3FH0n2/FwdK1GFrarDwzKlKbHw2p8iHHWCCnw4PPWhRdDBi3bTZnW2lU34O3BCkVw5SN48pbqH0RSC99OutMtih/pPMeH58ma4AO8U5kKKB74M8wmT1Xe7s273rXI0TDDVDW9GKHYzpsj7rBOUKxtNFMt+xTQ1wUzFxX4bL3YYchq1O6jGGjjgMSQpctjEiQl8BciYxNduXgXomDKSGSvi2waRcY4fRFXh7GD0kaTohB2DKOR1WWo8FEceBatQDe0ObUYePP3TbpBkwGP7nMdG60RogSzpIj/BcF827Bi0JDwzhU/ayP9K/JoAd1ULKgHCz0Mk4ffprO4EL1Cw3O5vYqFTpb24zEjrcfG2fTP/T8DO3g4wCWlC5XgL/9bSqASscEV01JlHm3AuVe7SkyYDKa8FrWA4Us0USwTuJ 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)(6666004)(41300700001)(8936002)(5660300002)(8676002)(66946007)(2906002)(316002)(6916009)(38100700002)(66556008)(478600001)(66476007)(66899024)(86362001)(4326008)(44832011)(1076003)(83380400001)(6506007)(2616005)(107886003)(6486002)(36756003)(6512007); DIR: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Hm8SVvbq9FybimB9n7QNPr0OCiZMEmkvhGssZswTVfYT/ZO0TyDEWlaRpg02Nnghk5VDQpMixB2i7I3rlpQ5xOXQUb2lL4jYnYvf69fiAANg+ECNpeeQsZ6HuZIx7TEZETrs5xXXjT379xqLtSSS1HVUyWhg9mR1VdTfHiqZvnTFekdQolEBksqns3TrtuKuf0efRSN/hYJBuSPN17cbp9PxcgSaOHhNKuDuCqLU0SWdI6m1cWLZYzWbKUpKM5n6MI6cSXZK+4T4sGal5OhaDm234i7uz5pRrbUKgKRS5RqtPHE2j7YMPjS59pRHeRXOPdgCPL1ApNMfi9rErg0xCAINK8q5mffwLOd2SsSBOt2qCrt3HzoFeeG7aL+ziqQAyvCsBQ3t3EdqzGpt7QojvxzQtSWsmzCnPJHar6yQTih/ciwZPIrES2purJMA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3635b2b3-e7b7-4404-aba4-08dbba2df926 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:42.0867 (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: fYVBt1m6Tlgm9QWqmvHgS6LFAODtcwp48znqlASQOo+TgYR+6DgGG//3HpfSbmfyMHujJQ6hbcdspPwzS+R41A== 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 phishscore=0 mlxscore=0 malwarescore=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=974 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309200193 X-Proofpoint-GUID: YrrvVowm48kcGUW-EaHLW5O3N-o8vkhR X-Proofpoint-ORIG-GUID: YrrvVowm48kcGUW-EaHLW5O3N-o8vkhR 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" When the command line option --scfi (default is --scfi=all) is passed to the GNU assembler, it will synthesize DWARF call frame information (CFI) for the assembly. The option --scfi=all ignores any existing .cfi_* directives already contained in the provided assembler file. To use SCFI, a target will need to: - define TARGET_USE_SCFI and TARGET_USE_GINSN, and other necessary definitions, - provide implementation of some APIs to help GAS understand the target specific semantics. The --scfi=[all,none] may see more options added in future. For example, --scfi=inline, for dealing with inline asm may be added in the future. In this option, the GNU assembler will consume (and not ignore) the compiler generated CFI for the code surrounding the inline asm. Also document the option. gas/ * as.c (parse_args): Add support for --scfi. * as.h (enum synth_cfi_type): Define new type. * doc/as.texi: Document the new option. --- gas/as.c | 20 +++++++++++++++++++- gas/as.h | 8 ++++++++ gas/doc/as.texi | 5 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/gas/as.c b/gas/as.c index 6839c841588..523169e66e3 100644 --- a/gas/as.c +++ b/gas/as.c @@ -372,6 +372,11 @@ Options:\n\ -R fold data section into text section\n")); fprintf (stream, _("\ --reduce-memory-overheads ignored\n")); +# ifdef TARGET_USE_SCFI + fprintf (stream, _("\ + --scfi=[all,none] synthesize DWARF CFI for hand-written asm (not inline)\n\ + (default --scfi=all)\n")); +# endif fprintf (stream, _("\ --statistics print various measured statistics from execution\n")); fprintf (stream, _("\ @@ -511,7 +516,8 @@ parse_args (int * pargc, char *** pargv) OPTION_NOCOMPRESS_DEBUG, OPTION_NO_PAD_SECTIONS, OPTION_MULTIBYTE_HANDLING, /* = STD_BASE + 40 */ - OPTION_SFRAME + OPTION_SFRAME, + OPTION_SCFI /* When you add options here, check that they do not collide with OPTION_MD_BASE. See as.h. */ }; @@ -586,6 +592,9 @@ parse_args (int * pargc, char *** pargv) ,{"no-pad-sections", no_argument, NULL, OPTION_NO_PAD_SECTIONS} ,{"no-warn", no_argument, NULL, 'W'} ,{"reduce-memory-overheads", no_argument, NULL, OPTION_REDUCE_MEMORY_OVERHEADS} +#ifdef TARGET_USE_SCFI + ,{"scfi", no_argument, NULL, OPTION_SCFI} +#endif ,{"statistics", no_argument, NULL, OPTION_STATISTICS} ,{"strip-local-absolute", no_argument, NULL, OPTION_STRIP_LOCAL_ABSOLUTE} ,{"version", no_argument, NULL, OPTION_VERSION} @@ -982,6 +991,15 @@ This program has absolutely no warranty.\n")); flag_execstack = 0; break; + case OPTION_SCFI: + if (!optarg || strcasecmp (optarg, "all") == 0) + flag_synth_cfi = SYNTH_CFI_ALL; + else if (strcasecmp (optarg, "none") == 0) + flag_synth_cfi = SYNTH_CFI_NONE; + else + as_fatal (_("Invalid --scfi= option: `%s'"), optarg); + break; + case OPTION_SIZE_CHECK: if (strcasecmp (optarg, "error") == 0) flag_allow_nonconst_size = false; diff --git a/gas/as.h b/gas/as.h index 99ffe77afd2..42fc44bd494 100644 --- a/gas/as.h +++ b/gas/as.h @@ -322,6 +322,14 @@ COMMON int flag_fatal_warnings; /* --fatal-warnings */ are detected. */ COMMON unsigned char flag_always_generate_output; /* -Z */ +enum synth_cfi_type +{ + SYNTH_CFI_NONE = 0, + SYNTH_CFI_ALL, +}; + +COMMON enum synth_cfi_type flag_synth_cfi; + /* This is true if the assembler should output time and space usage. */ COMMON unsigned char flag_print_statistics; diff --git a/gas/doc/as.texi b/gas/doc/as.texi index 6a3e5eed39f..c4755721407 100644 --- a/gas/doc/as.texi +++ b/gas/doc/as.texi @@ -255,6 +255,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}. [@b{--multibyte-handling=[allow|warn|warn-sym-only]}] [@b{--no-pad-sections}] [@b{-o} @var{objfile}] [@b{-R}] + [@b{--scfi=[all,none]}] [@b{--sectname-subst}] [@b{--size-check=[error|warning]}] [@b{--statistics}] @@ -932,6 +933,10 @@ Ignored. Supported for compatibility with tools that apss the same option to both the assembler and the linker. @ifset ELF +@item --scfi=all +@itemx --scfi=none +Synthesize CFI for hand-written asm. + @item --sectname-subst Honor substitution sequences in section names. @ifclear man