From patchwork Wed Nov 3 13:37:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jose E. Marchesi" X-Patchwork-Id: 46987 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 63B883858C60 for ; Wed, 3 Nov 2021 13:48:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63B883858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1635947329; bh=AKMawJn8e8wGvHHwjDKTLaG8Vw90TZSZ9+hvJN6WxJY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=dyZMajiKa3vGYaVYyN1aJBdKz3CaPZKzAhR1iKlYmHe/Rbrbi2DPn6wyPIyNiv0Iw vGSjkIDXDd+p4gCz0Y0IBriH6tyjCysYvPZthV8hMbunDakDBZ9LF0XA4HLcFx+i2W kRRT2fL4ME4Nu+P3ayqEBkzHe+lfpNb05NHwjOvg= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id E811F385800B for ; Wed, 3 Nov 2021 13:37:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E811F385800B Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1A3D93MW009506 for ; Wed, 3 Nov 2021 13:37:46 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c3n8p1su8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 03 Nov 2021 13:37:45 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1A3DUKHd126380 for ; Wed, 3 Nov 2021 13:37:44 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2104.outbound.protection.outlook.com [104.47.58.104]) by userp3020.oracle.com with ESMTP id 3c1khvj7th-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 03 Nov 2021 13:37:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H+ERirLXSC6mvUMXzPiR4tOUGMkjqN1Z8vEaxso+LfvvZDSl0znpTSRW9GBt3w4r1nsz+8H959hbF3oMMR+AdssTMl1AKFFhwBo+LXUEBU3Se6/okPKIysfMUt17HVc+HcYwCoaYbrMtMMYGsQKHJGLO9cLpWbti2Rcz0lnHRZzUbFhJWXmo7J/igaZGnJ8so6HVtMjkY+HwipGm48Ji7F+jJwL83Gjrk4YTKlh3AkUO+WnKt0WWJ95ensj8jctENeZnbeGj2UE0jqKrznEu3puURevGzjnvJfHoQzqMrWDZ2N5bT9yCIEbaSN51P0tAPf8C9rrl+RLggJ7xeRwdwA== 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=AKMawJn8e8wGvHHwjDKTLaG8Vw90TZSZ9+hvJN6WxJY=; b=NJxkDL/lubLjdJSXepWG+YQQjnhvzX7uUjTszzVLLovFh/kcuTk5g97mxLyGwhozss/bIGMEsVCpITloOOaUUz7DREe6J1VxnzJR5D7C0KqWU2mXwFN2aIql0zbuE2lwJAHj8Nz3kc0CUlW0+VGYKaMH5O3J+ysFMBnXNu6zJoP+az0yaO/KDpVqMSxUBN30TlhjlmgxqfDk944wjTLKdwZ2o5b1L5Xwk7xlTOdOYxEPCz5LYkBsBTa6PMSMr/+EyFw0kh51Hxfy1ljov3nkWvS/ppt/kgaOeDHZNP4r+U0bb/AE+BsaixNq8bG+5XNtZaSgtIlEKNrh9Mp7yXQ5BQ== 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 BYAPR10MB2888.namprd10.prod.outlook.com (2603:10b6:a03:88::32) by SJ0PR10MB4576.namprd10.prod.outlook.com (2603:10b6:a03:2ae::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Wed, 3 Nov 2021 13:37:42 +0000 Received: from BYAPR10MB2888.namprd10.prod.outlook.com ([fe80::48bf:86b4:32e1:6574]) by BYAPR10MB2888.namprd10.prod.outlook.com ([fe80::48bf:86b4:32e1:6574%4]) with mapi id 15.20.4649.019; Wed, 3 Nov 2021 13:37:42 +0000 To: libabigail@sourceware.org Subject: [PATCH] ctf: make libabigail::ctf_reader::read_corpus reentrant Date: Wed, 3 Nov 2021 14:37:35 +0100 Message-Id: <20211103133735.31664-1-jose.marchesi@oracle.com> X-Mailer: git-send-email 2.11.0 X-ClientProxiedBy: LNXP265CA0047.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::35) To BYAPR10MB2888.namprd10.prod.outlook.com (2603:10b6:a03:88::32) MIME-Version: 1.0 Received: from termi.localdomain (141.143.193.71) by LNXP265CA0047.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 3 Nov 2021 13:37:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53d6ad90-3e76-49d8-ee83-08d99ecf1c1b X-MS-TrafficTypeDiagnostic: SJ0PR10MB4576: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1186; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n3XeRnl1L1cG0oK6w29c/EQbXuUb4PwDvv12NAl+FvRCt1WAvfLyIWGDHS1lni/flZ1vv3i4nbldOUPpT6M6p851rUMVGd1gLO5PaBuB+4T67We/KOvVQDbxH7HAF1R+qNfx3GtnxzjULAbu8Psqm+KDOdxnp3V6P68EZeP93GGu9KQWHDeFD0o+TdcJTS/u6rVGfHpMxkywnUU+b4i3YE1ArsaZtkcIdw1GfY3DWDFNrJvWpI//KQGou+n8xQMAxidhaI3LJ6NPzfmE2J2RrdGzUwJGtXCJHSicVXd9kixImw8yFY2Y7Zx1q2MtvEjqwtx3SaBBy75g2I6IVTU9wvlRLCI6r/XRcJpfoP0u1+73JCyYuYGU+zG1eAqZxT8gm0tm0Nx4RFvZFqQwmaFJI5RvD6LGJG6A+jPB5B35zA+3DU92z9kjEzxGvKqTYl8TVJMh8pvnMrkFOtQQ3viWBs/43Z3Yg3ylRzsvM0kpDsEeFsyKYkIZAjk8mpIHTManjKYEZFC5ydFP0SKYY6J1ZaLieqdpBk4ujkWNfMRPGoBGoqEGZPho1uXSDi43obd0seeKUX57naz2nEdGpF4sF5yk6QDXvJz94721OMeyZaAixkKvhvDy2DcKIQ5DQWRs7vcD98Hk17rLCU5uyljsRM6i0KNCDT6fc/gFo19bsu+X3oTMCDd6TXYxLHc7dX2UEeMWpAc29pFpOT/RsbIVUQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2888.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(36756003)(508600001)(6666004)(6486002)(956004)(6512007)(316002)(2906002)(2616005)(1076003)(86362001)(26005)(38350700002)(8676002)(8936002)(38100700002)(5660300002)(52116002)(6506007)(66946007)(66556008)(6916009)(186003)(66476007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ptctXk66jJxPCY7UbXvz11m4gdX7dOVjfDrMBNmhqcARFZnZ+TjdP15upZlxvJmpH4efPgYwrXGXnRo4GCixlLvLgBGjuw4RQn7PEx9FdLgVQXTQegWnZwJHomDYPT2rSsatGfAgtof2Utp9FgDFQbug4Q6m7PmJ5ycgD8yJHMrE/FdtJrdgZXtkscHiZg7LJmRyp9fSFKbpZ7EKbJx9RlyJoeulZ8uPdRdhl+r3RujH8f5c80GjgYMQhcBuhItpijWuijKSCZPsm1R3rEvNYyBy8MewGDkjxrBrccQBKj/ugkoQBwxZADIrSV8QXkYrSsNyAljTF0ZZf+WFC0kbBfXfOrQk0qnLxMaF7WtfxCoTuoHn3EkQc8+UxL5PwsokunuFasLD1bB3VF75sFLanOk2kYcRTNPe6BKoBbweibpUBINWFj/5bUADQjJQDhQPVqCquP8P4zxAYBvKt03A43xgwQZcF2nvuBUMFYO8JD9bhbeaXLtWRtlmg/bn07iu5Zkvsf1KQV0XbP981CdUYWFHxlDovfQ822PpStF7M44JQsXchuiCkpUqa9Y9uHWMhaBTWRGEhFN2oXQCMtgxUfH3H+xseGMXpAa/V9T97vLEsxr/5LBlDsoBUNUi84UK7tOfDEkGIICXxOn7mtbUlDtHV5hr8VvC+QfkIZvLxyA5gvnuQyuodlUBFgErU0GlkleU1mk/ndcZHuV5ELyqtUOCr+F7ym5faV4v91ECIbTJ6l00fAX+mz+B7ijMDPRYakedzF25mm0WUNNv6Sjteq5jjZTIodkSdbMHksdphIO7X2/Gv85YZL8BWmjjwy3dbzFQ9TR9oUDQk3IxQRBA3KtDnSeQOQwumCLtXpF03BjHcVMGHq7A3PArtiPjJZTqI5A+qIN+KjuJ87nU9h/2Pw7GzNOzoZytRtAo2TzViqSrQkTxFvr/6K8pEy8n+As4tGwHoPL3LimmzGT1biMb0h5tyaUFszvaPoTnVPmDgsAXsqPJE5bjbBX0XybEWbWTmZg2s7yhKNjBsYRELzFb2T/5adpnNn7oI9bigv3wvZZWvpUHo+mK31PDyqeZWIGkioS9Hq1DpZtUXa+DAuNal9+iuIf9pKJnh/C3h9gRMUKELlWIWLbBNn7Zcw/7ElL21JBuIb47abpPujZhJep+0QFo+bS58xE/SN0K1nPgUAt2dH3g6h9pcNuQrkoxvZt9FV7nZaswm+y4f6Yfp1YVeVsI8KC5U8o5Je6TgZSSCjVAUJX2O1c5LLpW0xdGEpp6F2dygw9M0fCOjjZjD+zy8wCdqjYdlfgleNWhc4fquvGS8q4IxbSo5TDZyGNK+2bwa81zMnfH1Xl4AWUAIHLB+oE+mjlUFoACGnRN5r5wVd7zqmYr4mo563wMVCHn3AIQQXpucUaV83124ju+gADyXDJ5DHx2HIge0fIHqlT0EAHySsgHN7omhwfaHAVzPWGxfbuOB6mlpHUR8j9Vf+Mlul+LPN3Fe97MFd3g/8YhIkXfOHmFBk312X0LNb/3OmEJjc5E6MLe+hjIK7TWIHEAL+hynTQ7oO37Umkbi98VR3clWqhqM5XkpPQgUoGvI8xs8FLHRmM5ruIfoyuzFsxAWJjAD1mhSPLCUFhvM5Ra2RhOytG84A+kFm3tZPQzIVz07hLM7+tiKilbe+Kyg/jJtw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53d6ad90-3e76-49d8-ee83-08d99ecf1c1b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2888.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2021 13:37:41.9085 (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: fUhekRoPB+jylvHuTNhGPhGa9wyZzUeXktz4qJMH61GoKQtL+Dq4o81qRrdUesGeMPT1ZwFXyKFaYWR9+aL3RBZk2xSjwa4WgpSSkaQmrc0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4576 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10156 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111030078 X-Proofpoint-ORIG-GUID: ehrHsFW2-TR03FxGBVDKVjhBFnkdLkFK X-Proofpoint-GUID: ehrHsFW2-TR03FxGBVDKVjhBFnkdLkFK X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Jose E. Marchesi via Libabigail" From: "Jose E. Marchesi" Reply-To: "Jose E. Marchesi" Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" The libctf call ctf_open is not reentrant. This is because it uses bfd_open (and other BFD calls) internally in order to fetch the different bits of CTF from the ELF file. This is unfortunate, as it makes libabigail::ctf_reader::read_corpus non-reentrant. We detected this problem thanks to one of the libabigail test driver, that exercises tests in parallel using threads. Fortunately libctf provides an alternate way to decode CTF data, that involves the user to provide the raw contents of the relevant ELF sections (.ctf, the symtab, the string table) to ctf_arc_bufopen call. This patch changes the CTF reader in libabigail to use this mechanism. libelf is used in order to extract the contents of these sections. * src/abg-ctf-reader.cc (class read_context): New attributes elf_handler, elf_fd, ctf_sect, symtab_sec and strtab_sect. (read_context): Do not read the CTF archive here. (slurp_elf_info): Adjust to use attributes instead of locals, and fetch the raw ELF section contents for libctf. (close_elf_handler): New function. (fill_ctf_section): Likewise. (read_corpus): Call open_elf_handler, close_elf_handler and build the CTF archive using ctf_arc_bufopen instead of ctf_open. Signed-by: Jose E. Marchesi --- src/abg-ctf-reader.cc | 135 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 104 insertions(+), 31 deletions(-) diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc index 1c41ea02..e9340c23 100644 --- a/src/abg-ctf-reader.cc +++ b/src/abg-ctf-reader.cc @@ -58,9 +58,20 @@ public: /// is used to reuse already generated types. unordered_map types_map; + /// libelf handler for the ELF file from which we read the CTF data, + /// and the corresponding file descriptor. + Elf *elf_handler; + int elf_fd; + /// The symtab read from the ELF file. symtab_reader::symtab_sptr symtab; + /// Raw contents of several sections from the ELF file. These are + /// used by libctf. + ctf_sect_t ctf_sect; + ctf_sect_t symtab_sect; + ctf_sect_t strtab_sect; + /// Associate a given CTF type ID with a given libabigail IR type. void add_type(ctf_id_t ctf_type, type_base_sptr type) { @@ -93,15 +104,12 @@ public: /// @param elf_path the path to the ELF file. read_context(string elf_path, ir::environment *env) { - int err; - types_map.clear(); filename = elf_path; ir_env = env; - ctfa = ctf_open(filename.c_str(), NULL /* BFD target */, &err); - - if (ctfa == NULL) - fprintf(stderr, "cannot open %s: %s\n", filename.c_str(), ctf_errmsg(err)); + elf_handler = NULL; + elf_fd = -1; + ctfa = NULL; } /// Destructor of the @ref read_context type. @@ -939,50 +947,107 @@ process_ctf_archive(read_context *ctxt, corpus_sptr corp) } -/// Slurp certain information from the ELF file described by a given -/// read context and install it in a libabigail corpus. -/// -/// @param ctxt the read context -/// @param corp the libabigail corpus in which to install the info. +/// Open the ELF file described by the given read context. /// -/// @return 0 if there is an error. +/// @param ctxt the read context. +/// @return 0 if the ELF file can't be opened. /// @return 1 otherwise. static int -slurp_elf_info(read_context *ctxt, corpus_sptr corp) +open_elf_handler (read_context *ctxt) { /* libelf requires to negotiate/set the version of ELF. */ if (elf_version(EV_CURRENT) == EV_NONE) return 0; /* Open an ELF handler. */ - int elf_fd = open(ctxt->filename.c_str(), O_RDONLY); - if (elf_fd == -1) + ctxt->elf_fd = open(ctxt->filename.c_str(), O_RDONLY); + if (ctxt->elf_fd == -1) return 0; - Elf *elf_handler = elf_begin(elf_fd, ELF_C_READ, NULL); - if (elf_handler == NULL) + ctxt->elf_handler = elf_begin(ctxt->elf_fd, ELF_C_READ, NULL); + if (ctxt->elf_handler == NULL) { fprintf(stderr, "cannot open %s: %s\n", ctxt->filename.c_str(), elf_errmsg(elf_errno())); - close(elf_fd); + close(ctxt->elf_fd); return 0; } + return 1; +} + +/// Close the ELF file described by the given read context. +/// +/// @param ctxt the read context. + +static void +close_elf_handler (read_context *ctxt) +{ + /* Finish the ELF handler and close the associated file. */ + elf_end(ctxt->elf_handler); + close(ctxt->elf_fd); +} + +/// Fill a CTF section description with the information in a given ELF +/// section. +/// +/// @param ctxt the read context. +/// @param elf_section the ELF section from which to get. +/// @param ctf_section the CTF section to fill with the raw data. + +static void +fill_ctf_section(read_context *ctxt, Elf_Scn *elf_section, ctf_sect_t *ctf_section) +{ + GElf_Shdr section_header_mem, *section_header; + Elf_Data *section_data; + + section_header = gelf_getshdr(elf_section, §ion_header_mem); + section_data = elf_getdata(elf_section, 0); + + ABG_ASSERT (section_header != NULL); + ABG_ASSERT (section_data != NULL); + + ctf_section->cts_name = ""; /* This is not actually used by libctf. */ + ctf_section->cts_data = (char *) section_data->d_buf; + ctf_section->cts_size = section_data->d_size; + ctf_section->cts_entsize = section_header->sh_entsize; +} + +/// Slurp certain information from the ELF file described by a given +/// read context and install it in a libabigail corpus. +/// +/// @param ctxt the read context +/// @param corp the libabigail corpus in which to install the info. +/// +/// @return 0 if there is an error. +/// @return 1 otherwise. + +static int +slurp_elf_info(read_context *ctxt, corpus_sptr corp) +{ /* Set the ELF architecture. */ GElf_Ehdr eh_mem; - GElf_Ehdr *ehdr = gelf_getehdr(elf_handler, &eh_mem); + GElf_Ehdr *ehdr = gelf_getehdr(ctxt->elf_handler, &eh_mem); corp->set_architecture_name(elf_helpers::e_machine_to_string(ehdr->e_machine)); /* Read the symtab from the ELF file and set it in the corpus. */ ctxt->symtab = - symtab_reader::symtab::load(elf_handler, ctxt->ir_env, + symtab_reader::symtab::load(ctxt->elf_handler, ctxt->ir_env, 0 /* No suppressions. */); corp->set_symtab(ctxt->symtab); - /* Finish the ELF handler and close the associated file. */ - elf_end(elf_handler); - close(elf_fd); + /* Get the raw ELF section contents for libctf. */ + Elf_Scn *ctf_scn = elf_helpers::find_section(ctxt->elf_handler, ".ctf", SHT_PROGBITS); + Elf_Scn *symtab_scn = elf_helpers::find_symbol_table_section(ctxt->elf_handler); + Elf_Scn *strtab_scn = elf_helpers::find_section(ctxt->elf_handler, SHT_STRTAB); + + if (ctf_scn == NULL || symtab_scn == NULL || strtab_scn == NULL) + return 0; + + fill_ctf_section(ctxt, ctf_scn, &ctxt->ctf_sect); + fill_ctf_section(ctxt, symtab_scn, &ctxt->symtab_sect); + fill_ctf_section(ctxt, strtab_scn, &ctxt->strtab_sect); return 1; } @@ -1012,19 +1077,27 @@ read_corpus(read_context *ctxt) corpus_sptr corp = std::make_shared(ctxt->ir_env, ctxt->filename); + /* Open the ELF file. */ + if (!open_elf_handler(ctxt)) + return corp; + /* Set some properties of the corpus first. */ corp->set_origin(corpus::CTF_ORIGIN); if (!slurp_elf_info(ctxt, corp)) return corp; - /* Get out now if no CTF debug info is found. */ - if (ctxt->ctfa == NULL) - return corp; - - /* Process the CTF archive in the read context, if any. Information - about the types, variables, functions, etc contained in the - archive are added to the given corpus. */ - process_ctf_archive(ctxt, corp); + /* Build the cfta from the contents of the relevant ELF sections, + and process the CTF archive in the read context, if any. + Information about the types, variables, functions, etc contained + in the archive are added to the given corpus. */ + int errp; + ctxt->ctfa = ctf_arc_bufopen(&ctxt->ctf_sect, &ctxt->symtab_sect, + &ctxt->strtab_sect, &errp); + if (ctxt->ctfa != NULL) + process_ctf_archive(ctxt, corp); + + /* Cleanup and return. */ + close_elf_handler(ctxt); return corp; }