From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id E84E63858D3C for ; Sun, 27 Aug 2023 04:43:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E84E63858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68a4bcf8a97so1376378b3a.1 for ; Sat, 26 Aug 2023 21:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693111425; x=1693716225; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=qYlJ18YkKq172cfPGdcC3lSDTiyYriIqHwqfrprBtDo=; b=g2lK8QrSRs3ADVfBt5LyEFLeBui7oCkWmHwnh5u1Gp6WiWZEfFWXZytuPEdltanKLS HfQILO1hZcJG51Bz3t+hkNrP+asV6/l4ywaGrToqP8lLOY41AdF5m7LLDU581ZGTh9+M bmV+jojiYr841fXvyxRl+V+QrjG0cKqwY3wdpCSgatrBrjOUu3ZMuqm/lbLr6KTJrEk7 sekLY3wlY4cjk6AP9EgMF9mQnaUi78+UzUCwde7kdSkYyzyB4RyckXRcuGIH/CYxzxEL APg6XZvf/5HA3lwouxk20be26CE+8m2zsB44rEMdeq+3DiUkGovvnoefpM9AshUCSmwy rXGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693111425; x=1693716225; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qYlJ18YkKq172cfPGdcC3lSDTiyYriIqHwqfrprBtDo=; b=d3GaSQpmyEI0nsdpiE5uHC2OZmybQXjVmxQn+EbmAaZfNpbryzG0YvlAt4uvQ+juwD Rlpp6pnuqkfcCvHfsRqs06O/m3jGbGCtH5Sj6t2pO3sHl9D049brNIq0bEb5BmOFh7vg bBTXz9IA7URJKY+3IV0QiEDPQZ/B7vTqHfB9U5dYchnW/oexZQDxCsk5iYn9ez2All6V FQDhJ+RlWlHLCsz12x4stIivXFDckx/yUIKgmCr5KdSGL46vnKf2sWuuJOb+MD8MLgZQ ZoNG6lb7D061NLtR3cG16Ze1jU+xT41/wBi1VWE9cXy0ImQev2RbrE1wWy664JlNgMjG 61jg== X-Gm-Message-State: AOJu0Ywzma6LJwKmViIEKawjGQd4OEl0WO1VZzBkhsidbwp1Kv9/BTy6 fXIRCphuLkesEG/QSQ1GAiRLD3YR0w0pGA== X-Google-Smtp-Source: AGHT+IHeHaTklC2KqRo+vVc0NAuUE4y7gGXvnm76lXBqFFjGWu+rxtOiIXxiY7bat59Qo/gu26aW4Q== X-Received: by 2002:a05:6a21:788d:b0:14c:c393:6af with SMTP id bf13-20020a056a21788d00b0014cc39306afmr3035489pzc.0.1693111425401; Sat, 26 Aug 2023 21:43:45 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:bd86:4b0c:f073:c134]) by smtp.gmail.com with ESMTPSA id n10-20020a170902e54a00b001b8baa83639sm4561946plf.200.2023.08.26.21.43.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Aug 2023 21:43:45 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 7AC4811423CD; Sun, 27 Aug 2023 14:13:42 +0930 (ACST) Date: Sun, 27 Aug 2023 14:13:42 +0930 From: Alan Modra To: binutils@sourceware.org Subject: Confusion in coff_object_cleanup Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3033.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: A bfd_cleanup function needs to run when only tdata is correct for the bfd. The xvec may have changed during bfd_check_format and thus the flavour may be incorrect. The format won't have changed but checking is superfluous. (In contrast to _bfd_free_cached_info or _close_and_cleanup where we do need to check things.) Not getting this correct leaked comdat_hash. Also, pe_ILF_cleanup ought to call coff_object_cleanup as do all PE files. * coffgen.c (coff_object_cleanup): Don't check bfd flavour or format. * peicode.h (pe_ILF_cleanup): Call coff_object_cleanup. diff --git a/bfd/coffgen.c b/bfd/coffgen.c index bf9633a2b33..91667267cbc 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -284,18 +284,15 @@ make_a_section_from_file (bfd *abfd, void coff_object_cleanup (bfd *abfd) { - if (bfd_family_coff (abfd) && bfd_get_format (abfd) == bfd_object) + struct coff_tdata *td = coff_data (abfd); + if (td != NULL) { - struct coff_tdata *td = coff_data (abfd); - if (td != NULL) - { - if (td->section_by_index) - htab_delete (td->section_by_index); - if (td->section_by_target_index) - htab_delete (td->section_by_target_index); - if (obj_pe (abfd) && pe_data (abfd)->comdat_hash) - htab_delete (pe_data (abfd)->comdat_hash); - } + if (td->section_by_index) + htab_delete (td->section_by_index); + if (td->section_by_target_index) + htab_delete (td->section_by_target_index); + if (obj_pe (abfd) && pe_data (abfd)->comdat_hash) + htab_delete (pe_data (abfd)->comdat_hash); } } diff --git a/bfd/peicode.h b/bfd/peicode.h index 5ac6b0dc53f..e1d06606575 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -1180,6 +1180,8 @@ pe_ILF_build_a_bfd (bfd * abfd, static void pe_ILF_cleanup (bfd *abfd) { + coff_object_cleanup (abfd); + struct bfd_in_memory *bim = abfd->iostream; free (bim->buffer); free (bim); -- Alan Modra Australia Development Lab, IBM