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 497BF385841A for ; Fri, 5 Nov 2021 12:44:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 497BF385841A Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1A5CVStN020729 for ; Fri, 5 Nov 2021 12:44:12 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3c4t7q2669-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 05 Nov 2021 12:44:10 +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 1A5CeSBK163035 for ; Fri, 5 Nov 2021 12:43:58 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by userp3020.oracle.com with ESMTP id 3c4t616bqx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 05 Nov 2021 12:43:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PSiE+y+cOBQdhI6Gjr3YNyKkvxA6DgzNU/l5S2gmnJmI1/QMF4TPN1LLOyM75seJi/J9kRXCmsUGXh7xS0I2nhnrtyDdAkKrcCYpGLvemBQHBxH5hQnjFombrr7yk5feqpxa5VM2GW1KEbAMsPwVZAIuoIJy5EUBR9kbdvh6VP0Q2hGrIzLfzgyDL7RqOb4dgODVftXlyTWOar4n9Aaf4HoCXC/9mLpq/MBqdNHlY8NZRBVOvoKp2sXldyp1aZCtUnEZxES8J06I+3udf6Qvbg/4Bv9PBhzXNAdiWSMmHZ7yZSSn2cW8rKgtORGdrLBnim1lK9mOg7dfPwAIveL64g== 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=iDX+Hizdxp5oaKxJqTY3vjbxThhp4AJIFtcn11YKnuc=; b=ZOQi5dK897BpL94iJqHa1mHUjeObvIw2E/R0Gb+7/xkVeObCi/qRzJIx0wW3uVuNLSQ+CT+CsGzWyAKE6ANeDBYKAJmlf4/WAgvxPxqhTi9hB3TYWuJghA54f3WfAV/xukUK6KqHHnUHV/UV6dhCcu0teD2Zwmo8fplan+/Hw0fgvz886jCdarLryFj1PrLpttkA7BJ8lz8LiFeyRbvcDwbfRx1wQhtsPgZLFiO0Ua4hhE6NAWnyC7VNlOyf6+FwFuc+8fbwVVl4W7kjfBziVKz1K2OnGDOtxEkNc3dP29HRLEsYQdQSZAyE5bkIomtS0QqmItr9p2NhB1RiMDLZXw== 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 SJ0PR10MB4622.namprd10.prod.outlook.com (2603:10b6:a03:2d6::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Fri, 5 Nov 2021 12:43:56 +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.023; Fri, 5 Nov 2021 12:43:56 +0000 From: "Jose E. Marchesi" To: "Jose E. Marchesi via Libabigail" Subject: Re: [PATCH V2] ctf: make libabigail::ctf_reader::read_corpus reentrant References: <20211103135820.6233-1-jose.marchesi@oracle.com> Date: Fri, 05 Nov 2021 13:43:50 +0100 In-Reply-To: <20211103135820.6233-1-jose.marchesi@oracle.com> (Jose E. Marchesi via Libabigail's message of "Wed, 3 Nov 2021 14:58:20 +0100") Message-ID: <871r3uai2h.fsf@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: text/plain X-ClientProxiedBy: AS8PR05CA0015.eurprd05.prod.outlook.com (2603:10a6:20b:311::20) To BYAPR10MB2888.namprd10.prod.outlook.com (2603:10b6:a03:88::32) MIME-Version: 1.0 Received: from termi.oracle.com (141.143.193.72) by AS8PR05CA0015.eurprd05.prod.outlook.com (2603:10a6:20b:311::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 12:43:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 136b365a-1217-4ff5-f1f9-08d9a059ee47 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4622: 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: brDUbBxRT220ILTF2m40k2PBNw0OQ6Dg8Htme53VJm16iYeqoVkwYoykCDAukjSmkM/VQLsrH9cOu6BbUQPceoQlEbxomcOdYg6m1cgUBc+7xY23Z7lChYGobUegPQc6/dEeV5byhYAIl/GXIs4p69/HrWcjBDHbzY11tEsnIYJMYX0i4pSEuHD7mvyaYob3EZ11PPfvd1NZjjAca/N7OBoQarvn01ZzLjap6hPg7YZyPoPtSS+I9R10dJrrl9FoNrQOSgu0nHEQZHkJSDnnghARVzD1WjC//8QtN5P/Je6li3S8iCbKrrF1ZoHf3huN4a86MJaU+nZMEOCJAnFLy4diKCX2EAxWvTVadnpS/kslDAJI+w7AyN9YIAKI0tYrGFVYCizbfsNs7SQyk43Otzxgev06nuU41RQ3+ANzEnP4b/8dnoTgPZTAfna/YmapAecv5Eun72LpIm7HQOJNaZ5Y0UMFLOkQCF80+ZWMZuGJ6+LYQKFcVK15HTaDC8+xbxlcKkcJrW6f1EMaIE+GawIasFD7H++7zm27K680PzVYgICeQ+JkiGiWJ7RpbxRufBYENclAnAOMqUeF2QBd8E9RZq6jtLiAfEsOm+Ez4vukut5OStzp62i9+2KeOjhV8aqKhL4zMRw0hcNl25yezOPaKYk63IGRQFmmDQEsV8F4zjFSBZne3St6ScH63BnasiupqYfxuflQXWfaOhNjcw== 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)(6666004)(38100700002)(186003)(8676002)(7696005)(8936002)(52116002)(6916009)(86362001)(26005)(36756003)(83380400001)(38350700002)(5660300002)(316002)(508600001)(6486002)(66476007)(66556008)(2906002)(956004)(66946007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?tzG8oQ5OUimTeg8S5QIvfymz26Jjt5GjC53b8YOFXjkMAlIgKHo5uWBaSyMG?= =?us-ascii?Q?pY3e6FN7OzOEpY1+zISPDmTZk56ZGyrURFbKRD13hj3jZU+xY0Z8xyOz/yKb?= =?us-ascii?Q?I6jgOZ8bXZ+AGlInkhJxbY3lVunPDC6xYAdsCCFOoV9GCdh3WhuOTzqH0NyH?= =?us-ascii?Q?p5IGexGNXxBUETRRJxlpsOILT9k6vPlZKc+6kCJTvJJUGMhY+V5bzY9TJy7i?= =?us-ascii?Q?77aXgIQ7HeFNXRjhpBVhrlAIlmHYS1ocdO6HQCuOCvNzIkMYAyxqkMOOgi5E?= =?us-ascii?Q?K6ypd0HXYjWhAi8nIBTnIF5vaTvqv6V+ESXsJeyYQdpPM1G77FIE6JBaySyN?= =?us-ascii?Q?OV5hZ0SvZZ7w9njQLmslvnwHVnKr/Vf5U3nlNgEiCOjjEVjLSOEUvpTsH2sV?= =?us-ascii?Q?m3LMnhexUxB/DlaLBM7lDG8obLIVgvxuugzC0YD3PcnB1nWiR3xf2jhOZf6U?= =?us-ascii?Q?mn9mRps8xuP4TvH2VcAjl4ZgG3zbEMaLaHyJR3GUG1kxPwEvdSqTmGHBIR8j?= =?us-ascii?Q?23Ix2Ds4uRY9ZWZb0LQC718hegaFxWbfCi03bJC5NsBAEuMtkRb7JJ7zh481?= =?us-ascii?Q?BsO3pFk8UrGMvEdI++DtUIeoAb8ooaeux7h7oadmhgDBuEn+ya/dBgyPjEzZ?= =?us-ascii?Q?l9sekWDKUCiEfm7MQle8WeiT4ue+0HxwVL4Tipe+rE+KvdRNeCMJ9aPJe4Qf?= =?us-ascii?Q?uQX+gOBwJDbeutjxMmN9/48I8c4c+f4w310iVINS7XZgQnYSIQmakMYlr0kj?= =?us-ascii?Q?0i+OjXg8eZQsoYNi5Ptp1SJc8qpkhksqaWVVsxJaQ/VeaX7+bMoC0aUilEsV?= =?us-ascii?Q?V5gGqKi/Ep+hT6CWp1cmLbNdbIr4UrsT8NxHmFLx0Ag2PI8ELE1F+YxYpL/K?= =?us-ascii?Q?NRauQ7WFJe7SHP7Caj+ydK/F58dDCXdrRHuHWgtkeOVY9no3HiZOcaSNWtIe?= =?us-ascii?Q?UIPVgap/veE4qQhwVjRvbmat+DEnp6vla4qs7EdkYQfu203/T8i5Kw8uYpQ8?= =?us-ascii?Q?PQur1S3CxVjtc3tpILQqOywEyvy109taLkgb+CYH1Am51qd4ZpKKC3ssd7ZZ?= =?us-ascii?Q?BQOYJZT+avQG+tKlxvoky5aVWP09m70RMwSPy7PoQlfrxgZy9l2o74JQJWcf?= =?us-ascii?Q?SY4zT3FxwipvT84DYo4CdznUIOf/I/8oOQ5tv1t01ww+VIMJgzPjt0MZC0l8?= =?us-ascii?Q?NWiwrsA1Z5d3lGtnFzCE0CcfGLBtTIpoqqyBJ6/dqqD1p9Ws4C7+1/DSRkqL?= =?us-ascii?Q?ETO3okDqh7aUTn0qDhIeOQbX95TaHNSsNUsgUbQ0zqOjQVNfFCYqGGbdCu7V?= =?us-ascii?Q?cPxVk+l9rp71UB8wsyJ6GiPaYG9IUxVpBmvDcFoHksB58vmgZx2Ixu9pJbu8?= =?us-ascii?Q?Hstgy/OOVhl4M5brEJvB/spOiFX9wdx7QHZo/qFrn5UUgIP6S9da2aLgtYKS?= =?us-ascii?Q?9xWG89ZMTmde7PfTEER/8yZLsL7bs43w8xO78sNp2OCrRdI2wZ715NvgDe5G?= =?us-ascii?Q?jx9IbDT4FKPyXXfUz8ZQlpL6v2+LELXLidsejB+oSdS2KxNSUX6ugc5VBgo3?= =?us-ascii?Q?MqsK1nBxW591MIqUhOW1EFM8MFKtivJ4cdr/IruW3yFfuHXnKu43yugnycDT?= =?us-ascii?Q?F4q09u/k5qrSoFJH9WRgQmIJwU3XCZ3KBsYrdtA0mtm2EtQay5kKBuMt1XFj?= =?us-ascii?Q?MMjraw=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 136b365a-1217-4ff5-f1f9-08d9a059ee47 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2888.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 12:43:56.4229 (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: DkdhAz3TOPJ6GG1ODUM/a9MpdroE1LvjFwo+lF5OYU9IVm4TpOn4GrF8+UwbDU80B6Lbjh8z4OBiqEh6e0NSdufcCpxBeHrpYGdISB0FQGM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4622 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10158 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111050074 X-Proofpoint-GUID: qWAm7XeJsJ_0F36iSKShqp8_r_wbTKhm X-Proofpoint-ORIG-GUID: qWAm7XeJsJ_0F36iSKShqp8_r_wbTKhm X-Spam-Status: No, score=-12.0 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_H4, RCVD_IN_MSPIKE_WL, 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-List-Received-Date: Fri, 05 Nov 2021 12:44:16 -0000 ping > [Changes from V1: > - Make sure that the string table passed to libctf is the one related > to the symbol table.] > > 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 | 143 +++++++++++++++++++++++++++++++++++++++----------- > 1 file changed, 112 insertions(+), 31 deletions(-) > > diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc > index 1c41ea02..d107fac8 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,115 @@ 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. The .ctf section > + and the symtab are straightforward enough. */ > + 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); > + > + if (ctf_scn == NULL || symtab_scn == NULL) > + return 0; > + > + /* The string table that libctf expects is the one related to the > + symbol table by virtue of sh_link. */ > + GElf_Shdr symtab_shdr_mem, *symtab_shdr = gelf_getshdr(symtab_scn, &symtab_shdr_mem); > + Elf_Scn *strtab_scn = elf_getscn(ctxt->elf_handler, symtab_shdr->sh_link); > + > + if (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 +1085,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; > }