From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id D48A03849AC3 for ; Wed, 17 Apr 2024 20:20:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D48A03849AC3 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D48A03849AC3 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713385244; cv=pass; b=UUkujjllopWl6lTHej1tAE14qX0RW9QPHx7T9jOLtHvexAwoo93Ll8ppODxShMHmP9v2j3nner2qe+Xqt1bUGMzf3GYfDiI4G68wC8zqypcq/NRPKeXcO5ioifhf2ylqBOE/l+Bt1hoNtds6I4kiSmi1eBDc7VUvECC8DxS1K0c= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1713385244; c=relaxed/simple; bh=4hWbiQXGWrWAjSKJUHfiQI3yhaK+yKBWRx+Vj5fCW/g=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=V5ta6lCO6OHwV7CaDZb33W/6UQs5NYokT2rejF+uH9s0adDPEYzj+9/2qmqmgD3gWrZhmZ+MBfNjzi8rf78Q5sWbnChlHH234Cx9qBWdFCw17pVAZ1SuNLzgF8eyp3CukygwS5sv0j1Pd4w9MryzgwNQ3b5NrnTNRnUY6YNOlfo= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43HHiVRV011076 for ; Wed, 17 Apr 2024 20:20:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=VXmamvDZCAgZ1sUWtEK/J8QR0gJQ3QutpcZHgJsdvcM=; b=X5MvtblbhafP4w67C3k2DyzMlwiUuTDO9HssXd+TOS2Q6pMNoSkB1CyRFPWJkx+i1ODa oDse71WWzeZ85HBVeAwz4ZcSxvUd9Je3OknKu0DtHcOjTYPf2n9+GZyYYPAnK5n8LsBW ARlNPpM33bCD7nkJcbVXHeeJ5U8a8bGgwvA20wew9Ied3tjQrSEXALjkD+SofVo+vcV+ 5DLWFM2+60QrF8aI8fEmuIFqV8xMMBKP0fhyczGS+xMQ0mNJJOdriZkB8hWY9GUXUvWB VVXfIFqhqjHWmc7SW6SQ3MCuwmJIfSu1b2f1sSHrXq3awV/SPdwkf7VvQ8VF6RJdnITy Rg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xfgycrva2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 20:20:39 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 43HJWdJS012600 for ; Wed, 17 Apr 2024 20:20:38 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xgkwhfdcp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 17 Apr 2024 20:20:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J3uelstMue3C8Sr8fEBu6sRJgTK6d+Qeiv5+obyQrVuiCHM/h/tM3TAyv3GHcUVxiEmQAxUwPwpubuOQye6wy87XEz1h1htzGIKiAifB6kIv8C+xS1a/+yaKkxQciqtopUFDv4w8XsY6HEcRYOmH8ApmdxDJScsxIXaTcR9okhKMIr08YN0yLbRQhjDR7GOE2fqQTS+7kDrloK0HLbHy7gPWN+k2uhYsNOfTv6w0FmM5ToUu6WtjiVezKfP8g95cL74zznGSKrZn8apIJxSXe8mIhPF9V0Dc7l5yrapK+O2TwSuC/OwuOtfu8k4QUpqmXrFV83O3oOdrcRxC52z1VA== 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=VXmamvDZCAgZ1sUWtEK/J8QR0gJQ3QutpcZHgJsdvcM=; b=UcZvCu5yE6TWSNm/hMma2etYmd832wzijUaMgNDNpPcnYExzwFGZBZJG1KixFvCXGw+aHrYbaopuVohZR7XmCAw9L5S2rF2U4heU3F3+86vcZ1dBWDLa5K3H6FUF96Vekvx1GxZ7ivyfY8M6yyFw6mVGWO8YUI+jYp4ezqTUdK2NrhyXxGmCIAnzoUE0WJMJWoAnZInE/goH6rxxlPOV+wBkSkY+HelS75mXn5dgT939x9WhPe2t/oHtmmQvsVRgvAPQExg/md35pwfOXw0eRWYWY4gec8bvxBpG75YQvkbwBYlg9wfhw4tLpZVCUnvPi9Irq1jPLiPyFhO7Fl5U8Q== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VXmamvDZCAgZ1sUWtEK/J8QR0gJQ3QutpcZHgJsdvcM=; b=I4aJg0X/SA/m7QYnF3keBVmE4IPBzf9r5NDwBMyh6iPFUnGkEpb1943v48McX4SC805dfNlgy1k/3z50GF+peSeMUR2DcPg9XyDB0Pg8IK1WCvLVlMDcCAgAJgQElGZIrOvBMgLGSo19GP+K3kDKuWUw0sfenWrARj667fQ6XLQ= Received: from MW4PR10MB6608.namprd10.prod.outlook.com (2603:10b6:303:22e::8) by SA1PR10MB6640.namprd10.prod.outlook.com (2603:10b6:806:2b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Wed, 17 Apr 2024 20:20:36 +0000 Received: from MW4PR10MB6608.namprd10.prod.outlook.com ([fe80::67a4:9544:7249:7751]) by MW4PR10MB6608.namprd10.prod.outlook.com ([fe80::67a4:9544:7249:7751%7]) with mapi id 15.20.7472.037; Wed, 17 Apr 2024 20:20:36 +0000 From: Nick Alcock To: binutils@sourceware.org Subject: [PATCH 01/22] binutils, objdump: Add --ctf-parent-section Date: Wed, 17 Apr 2024 21:19:57 +0100 Message-ID: <20240417202018.34966-2-nick.alcock@oracle.com> X-Mailer: git-send-email 2.44.0.273.ge0bd14271f In-Reply-To: <20240417202018.34966-1-nick.alcock@oracle.com> References: <20240417202018.34966-1-nick.alcock@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: LO2P265CA0509.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:13b::16) To MW4PR10MB6608.namprd10.prod.outlook.com (2603:10b6:303:22e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR10MB6608:EE_|SA1PR10MB6640:EE_ X-MS-Office365-Filtering-Correlation-Id: c827b4ce-db38-4616-9e2d-08dc5f1bd736 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CQd0N+Z2eO+Olj3gmNcBw3BW4yzBmfagkil3HHlEoXIpZjhlOMMIkO4dryTfcHmzQd0wI/SLSTMaDV8NXkDEpnfxiwLS/zJC72VPI7Nw2J48ocbpSlgqV8wVWZ0x+g+MCt54N14ITvNF3AcYIVEveRgFXnx0u3yL3JYUvwbJId3GNOjO55p4MlF1nllvSDtwGfKoYmnfAqMqDjqtM66mkD64/u9ZJv6Q5PAV7tLwOYoR6CamVysxzLXf+86688TIP+RLFscTo5ijVTLdyAR7h9uf2EwDvBl4Vp9pdrQkUwK6y83lBMHJqgOA/n6DoYpt/159CIzpt+jtdOWij/slvwTBgzUh8T+WMEHSLxUdAJEfZnZXd6g6Y1Et7GvQo2ePW6G+yigXuj+1UShs/Ref50U9nidRf4Vou/VAg+qzdf0XZyRRUWbcvwJ0JPRIkTKKrNb8UYbKyxVmtowkQEIF4BpTQcoFemZ2azdfxiYvqzeXrAI6ndXVprVDMCcGkunvBCWGAfICqK/S9akdRI7TzkG0knNb61r0CjFhI3XxVLuRmK59Kqa1uhzHzLdrQ/9owWSrPcYDbINZTg6dMK0oJpKxs4ns/lL63GpL/a1ztTNfcWmpnJdmZA+s3U590rgeK7pLeE40sFAKlPfu6ANm8xq/zcURuwF3d4FTgCi/+9U= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR10MB6608.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?5hQqS3pUDKknhEQLe5C2eLgJ7ZqmrU/wwYoU3CCT7oSmhF3sMLzRR6YF86Zk?= =?us-ascii?Q?JQkHLoE4YdSP1cU03+uJsl2vGIQ6t91ep2FjqxYCktOmndC01cwh8DA19FW9?= =?us-ascii?Q?Jw2K4+Z+KEX+SqGbaSiQeSVQjG13CwK84b8Nf8WxSJmK3ZcIh1I9LLgXaJTv?= =?us-ascii?Q?7UPVwqZsmcpj2hw8Jnp7hxMUQG/rQiaMYQG7OnPFKNQcoiqr+oXtFGAeHX63?= =?us-ascii?Q?zL1QwOUvIs4nUGEDdXL6F7MIu1ExUPIG9s3ZMakQp4KmYSjJ0vzsyLEZybki?= =?us-ascii?Q?7JWT2Mk9Y9WGW5+QXwgyLANCksuUd2grbfmSMQeUens6k0+Ed6uYthSfgl9n?= =?us-ascii?Q?Zv1y0ZM/SicF0yrhN+nB8iJC+QdkdQliSRPWofUEIlm6oYlM/n205ZJXBQ0i?= =?us-ascii?Q?caiIZ0MQafVRhXDUNSdUCcXplNsjc44NK3+ikmF1I3XmAT/wB3p5kbHDA4vN?= =?us-ascii?Q?nmfAq+5qD5z/Ctg3gW7R4QDCvpsHwQ/XbJh9wJvuHVBlNIzOJi8+Rx9kz3nf?= =?us-ascii?Q?fIHcqxLAhbc6MM+IffGVgAWISolJi2411pj65r5FPYUbxqorJa8lG0STgfqK?= =?us-ascii?Q?n1zn2jYIEm91+j6VeNJptXiQfGDrt8LJJsErC2cN/NLecCwSYX7JGI8plCa6?= =?us-ascii?Q?SCW/qAGUeV4x4nV+mfx1sPjK9DUwiAH9nlLTMB3e6EEABKkzPWlKzmfaRcQ3?= =?us-ascii?Q?P7Umm/8q1gqdYwUzcymAGD19ztA/TG5r1dRW21SU9+/sW1lUj+TICBOKUt1i?= =?us-ascii?Q?7bQZSzgt2ugQRsTUZVA4VuEarfJE9xE25UZcbWUOenjVvzNfs+quTNu2oKeP?= =?us-ascii?Q?99Moqcuhs1rNVmAtnnxT7vJow+MPCIV/r84MbPjX1Eiy9+AZ62nFkvOLtIHo?= =?us-ascii?Q?ml0zMBjdi9UeinAks4cP7Wi6KeVl4CAKGbJYFvs4q+SRGAP34bQxH7JnEuID?= =?us-ascii?Q?+jGecebJn6/9chc8iiD7wPjwrQjCaVhFmUznR6CgkV7sRBkcV79eEpxtcljp?= =?us-ascii?Q?/wm2xPhODQ8C3oNMwm0F18UlsD3z8w6yp9cuqZojDXoU2IcT3GdLyl6aF08J?= =?us-ascii?Q?X84+LWwhl/dO/2SsxLXGLHTMtYIUY6OjccfhT/rHvi76I+J0BdiGnToR5Uyf?= =?us-ascii?Q?RnQqr/c7bgSiH6L2YIecZpuZw1v2+HWjQ1D9IyqtYzwNO+VzJ/IZVhBXIh3z?= =?us-ascii?Q?aMNGF7uWBROy3dG4TnognwsmS1f4ZYP8tqPVaUN5v0a0AeiJzqToQT1OaSsj?= =?us-ascii?Q?4TMvuIAfvkkE+l8u52Wvh371oK0Yn4N5RRW1CmHMm06q7TL8o3ymVA3r5ruJ?= =?us-ascii?Q?gjgU1lalo3IP5NjViLkvH8lGZ3Jmamu5ZhwOFZNc3luT+zE8ih0hIF1NEY1d?= =?us-ascii?Q?pGjOrnY7ehnfDhJt1SIfIOfgbtKmEh1AnnkxovFaAehMlekbjjk3IaUpz00G?= =?us-ascii?Q?oEFH09svbgXKZvMdfpJZvBIg9WlTKmLfQA4JHzFfvNV8vs+Wc2jrAwdS98aT?= =?us-ascii?Q?R9UQUIYw2503dfJx1ZSCQNxrmXlNdz4ldt6IMlyay19y9FmdUBAoOiTzd0Wo?= =?us-ascii?Q?E8ctS44pYdNqv1iRfOpMSczQdmnZ/ZxB5d2B5MUHlqHNw5SVIfrDEFmWDZKN?= =?us-ascii?Q?zA=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: wmhb6bMWy4UjVdwokas8Xtmmy/+/FflrR4zTSWmwQSnBoMTiJH34yeH3nc3rxv6tkKJff1WtoI9IL4w03IgUtFXEl4KyKh/v8fgVP8ACnaUdQQhRNwg+cSvxBB8+gDuNOb5gtg8TBOipEDED8adiNQkIPJq3RehwoW6vaV90CyZ6fsN+BnxP7sAkwN7vIC57yYvwn1RcNASRCvWbi4Vm/RggmNVPNQWYA7GDasKiPLukASQHtL5sTMpsnVlIjVBc3uoco/vOvN1hboype8yATHcU7jesM7njkkcdFg5iSwEqO3BL0nx9eIZ88YqJi2cET1ZdlJ21cjgHmMJP5AknCwAIkxcJDuxUpST03jUR34zdLPC7hltfqyodf1FaWTHoe8Et1bVW92v3YUG16JgFAp/HmCSVAG0x7gN+YB+sqb28mvgv8JEt+HDbUAHxeOd54+u2q6lEiZG+3qDZMAWRazOVFj0bcMOnOhQaUMvur9Z7QVVQjEArwrebBVRXtOAFXrVk9Ydd6y6wJLJtKWk4H0pcLzJZ+CCEL9ws20CoXCy0w3ahQPfz1Z2CLrk2ASoajYT3+ukLyISw5Tb0/Q3elh3I+9uApZ1OQ6i6fW7U7Os= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c827b4ce-db38-4616-9e2d-08dc5f1bd736 X-MS-Exchange-CrossTenant-AuthSource: MW4PR10MB6608.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 20:20:36.0074 (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: J7vawzijZ78K2XqSb7atUzjmLbQn7oLRKwlNLhe6E8AJeA4Gv6eciHCL8Lz6pBzkJEOzsvm6ATxIRIqJ5LunZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6640 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-17_17,2024-04-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404170143 X-Proofpoint-ORIG-GUID: URwIXfkJD4gQRaMKbZpbIzuaxYOgDPwE X-Proofpoint-GUID: URwIXfkJD4gQRaMKbZpbIzuaxYOgDPwE X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H4,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 List-Id: This lets you examine CTF where the parent and child dicts are in entirely different sections, rather than in a CTF archive with members with different names. The linker doesn't emit ELF objects structured like this, but some third-party linkers may; it's also useful for objcopy-constructed files in some cases. (This is what the objdump --ctf-parent option used to do before commit 80b56fad5c99a8c9 in 2021. The new semantics of that option are much more useful, but that doesn't mean the old ones are never useful at all, so let's bring them back.) (I was specifically driven to add this by DTrace's obscure "ctypes" and "dtypes" options, which dump its internal, dynamically-generated dicts out to files for debugging purposes: there are two, one the parent of the other. Since they're in two separate files rather than a CTF archive and we have no tools that paste files together into archives, objdump wouldn't show them -- and even pasting them together into an ELF executable with objcopy didn't help, since objdump had no options that could be used to look in specific sections for the parent dict. With --ctf-parent-section, this sort of obscure use case becomes possible again. You'll never need it for the output of the normal linker.) binutils/ * doc/ctf.options.texi: Add --ctf-parent-section=. * objdump.c (dump_ctf): Implement it. (dump_bfd): Likewise. (main): Likewise. --- binutils/doc/ctf.options.texi | 10 +++++++ binutils/objdump.c | 56 ++++++++++++++++++++++++++++++----- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/binutils/doc/ctf.options.texi b/binutils/doc/ctf.options.texi index 2820946f2c0..0b04e9df426 100644 --- a/binutils/doc/ctf.options.texi +++ b/binutils/doc/ctf.options.texi @@ -22,3 +22,13 @@ function at link time. When looking at CTF archives that have been created by a linker that uses the name changer to rename the parent archive member, @option{--ctf-parent} can be used to specify the name used for the parent. + +@item --ctf-parent-section=@var{section} + +This option lets you pick a completely different section for the CTF +parent dictionary containing unambiguous types than for the child +dictionaries that contain the ambiguous remainder. The linker does +not emit ELF objects structured like this, but some third-party linkers +may. It's also convenient to inspect CTF written out as multiple raw +files to compose them with objcopy, which can put them in different +ELF sections but not in different members of a single CTF dict. diff --git a/binutils/objdump.c b/binutils/objdump.c index 6396174d50f..9db1b4915c9 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -108,6 +108,7 @@ static int dump_stab_section_info; /* --stabs */ static int dump_ctf_section_info; /* --ctf */ static char *dump_ctf_section_name; static char *dump_ctf_parent_name; /* --ctf-parent */ +static char *dump_ctf_parent_section_name; /* --ctf-parent-section */ static int dump_sframe_section_info; /* --sframe */ static char *dump_sframe_section_name; static int do_demangle; /* -C, --demangle */ @@ -485,6 +486,7 @@ enum option_values #ifdef ENABLE_LIBCTF OPTION_CTF, OPTION_CTF_PARENT, + OPTION_CTF_PARENT_SECTION, #endif OPTION_SFRAME, OPTION_VISUALIZE_JUMPS, @@ -500,6 +502,7 @@ static struct option long_options[]= #ifdef ENABLE_LIBCTF {"ctf", optional_argument, NULL, OPTION_CTF}, {"ctf-parent", required_argument, NULL, OPTION_CTF_PARENT}, + {"ctf-parent-section", required_argument, NULL, OPTION_CTF_PARENT_SECTION}, #endif {"debugging", no_argument, NULL, 'g'}, {"debugging-tags", no_argument, NULL, 'e'}, @@ -4854,11 +4857,14 @@ dump_ctf_archive_member (ctf_dict_t *ctf, const char *name, ctf_dict_t *parent, /* Dump the CTF debugging information. */ static void -dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name) +dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name, + const char *parent_sect_name) { - asection *sec; - ctf_archive_t *ctfa = NULL; - bfd_byte *ctfdata; + asection *sec, *psec = NULL; + ctf_archive_t *ctfa; + ctf_archive_t *ctfpa = NULL; + bfd_byte *ctfdata = NULL; + bfd_byte *ctfpdata = NULL; ctf_sect_t ctfsect; ctf_dict_t *parent; ctf_dict_t *fp; @@ -4878,7 +4884,8 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name) } /* Load the CTF file and dump it. Preload the parent dict, since it will - need to be imported into every child in turn. */ + need to be imported into every child in turn. The parent dict may come + from a different section entirely. */ ctfsect = make_ctfsect (sect_name, ctfdata, bfd_section_size (sec)); if ((ctfa = ctf_bfdopen_ctfsect (abfd, &ctfsect, &err)) == NULL) @@ -4890,13 +4897,36 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name) return; } - if ((parent = ctf_dict_open (ctfa, parent_name, &err)) == NULL) + if (parent_sect_name) { + psec = read_section (abfd, parent_sect_name, &ctfpdata); + if (sec == NULL) { + my_bfd_nonfatal (bfd_get_filename (abfd)); + free (ctfdata); + return; + } + + ctfsect = make_ctfsect (parent_sect_name, ctfpdata, bfd_section_size (psec)); + if ((ctfpa = ctf_bfdopen_ctfsect (abfd, &ctfsect, &err)) == NULL) + { + dump_ctf_errs (NULL); + non_fatal (_("CTF open failure: %s"), ctf_errmsg (err)); + my_bfd_nonfatal (bfd_get_filename (abfd)); + free (ctfdata); + free (ctfpdata); + return; + } + } + else + ctfpa = ctfa; + + if ((parent = ctf_dict_open (ctfpa, parent_name, &err)) == NULL) { dump_ctf_errs (NULL); non_fatal (_("CTF open failure: %s"), ctf_errmsg (err)); my_bfd_nonfatal (bfd_get_filename (abfd)); ctf_close (ctfa); free (ctfdata); + free (ctfpdata); return; } @@ -4913,11 +4943,16 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name) ctf_dict_close (parent); ctf_close (ctfa); free (ctfdata); + if (parent_sect_name) { + ctf_close (ctfpa); + free (ctfpdata); + } } #else static void dump_ctf (bfd *abfd ATTRIBUTE_UNUSED, const char *sect_name ATTRIBUTE_UNUSED, - const char *parent_name ATTRIBUTE_UNUSED) {} + const char *parent_name ATTRIBUTE_UNUSED, + const char *parent_sect_name ATTRIBUTE_UNUSED) {} #endif static void @@ -5733,7 +5768,8 @@ dump_bfd (bfd *abfd, bool is_mainfile) if (is_mainfile || process_links) { if (dump_ctf_section_info) - dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name); + dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name, + dump_ctf_parent_section_name); if (dump_sframe_section_info) dump_section_sframe (abfd, dump_sframe_section_name); if (dump_stab_section_info) @@ -6243,6 +6279,9 @@ main (int argc, char **argv) case OPTION_CTF_PARENT: dump_ctf_parent_name = xstrdup (optarg); break; + case OPTION_CTF_PARENT_SECTION: + dump_ctf_parent_section_name = xstrdup (optarg); + break; #endif case OPTION_SFRAME: dump_sframe_section_info = true; @@ -6337,6 +6376,7 @@ main (int argc, char **argv) free (dump_ctf_section_name); free (dump_ctf_parent_name); free ((void *) source_comment); + free (dump_ctf_parent_section_name); return exit_status; } -- 2.44.0.273.ge0bd14271f