| Message ID | 20260820192345.935-2-oleg.tolmatcev@gmail.com |
|---|---|
| State | New |
| Headers |
Return-Path: <binutils-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A99F84B9DB50 for <patchwork@sourceware.org>; Thu, 20 Aug 2026 19:29:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A99F84B9DB50 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=LH5ikrgy X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 52F444B9DB5C for <binutils@sourceware.org>; Thu, 20 Aug 2026 19:29:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 52F444B9DB5C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 52F444B9DB5C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787254146; cv=none; b=ZVZxsIivB2IBOdfjQk8dpVC8mmpKGyoezAIdiNObds7qKmDi6gv9OU5sfNYLoQhZimpqArAgoSbqVA8Pbu0W3n9Wt2cVE3PeE61J8FHNfd2HZ3g9dX1LwIaCrHkJA2a408tqCFg3+MsdQLZTtpmQEeJpTUCBtEBOnlU9vWvluD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787254146; c=relaxed/simple; bh=QtUBkVemxyHIvJXIS3gFANXvnm90mY+d2cCRIXZ+xbs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dZErojfUM7h3HnAiAzf6W5LnuXQ3Cv4nnnUPAR5jYZ0xDwDR+vk263zaQetGqXLytTaxOb9XZIh9aGhaBeU88UusWPvtw+/F0zrmWfheJyxBeuANgiznqbJhrPvXFrFCcGTpSHqnU/+t1YOU+T683X0rENVan7x33L0uPhqo3kI= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=LH5ikrgy DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52F444B9DB5C Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-499b02fc590so1519115e9.2 for <binutils@sourceware.org>; Thu, 20 Aug 2026 12:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787254145; x=1787858945; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=cXIka/QPIIPiFuQlKSXC8FvuIj+bEvoSLo4/R1lDCh0=; b=LH5ikrgy0DEAPk7E/87Fxj0XEruBE/AzWgnOVhpzTDk+pgAJbXbQ8fOq1EUWQnrfoz SsIPax28WVUeynsk3a2TRAjbnDZGOWNploOKsHqUnPEB+citLN8H8zrxMSbMUe6TD17C R9eQ94TmpW/matCezNbsebnbD4tljpx36KM+hSGDyxF8R828jBKK6NGkzSlyC28Lgceu iHk7D+eES0K0rHIt8JWw4ymlQ184RRZ9RKWZgKdpqAFIT0RZU9/vgP1M36KLswKYC4uB CpG+XET+1bC/UDhsEdsXNKrjV0xYVdUKpUCGQcYlutNh9Q0jwh3tk6y3aYNSAEjVul0I XZTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787254145; x=1787858945; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cXIka/QPIIPiFuQlKSXC8FvuIj+bEvoSLo4/R1lDCh0=; b=QY7Cos+LWX+z2IZZM5KSzju4d2WzsOwwmiY3zqdayjSgyNXDYmmrzFOZoT+4Rpie3Q 2FWVf6Gwu3p1FbC31fivQYEWhlaYyBFzYOWSLB+dW5ERWKCsk8l8H65t5P3Bxo8UXL3O lsay8YKpNRVipbyapEKi8YN85NB6pm0moMOxkRy2BT5qob0trb6jQEGQML6KSGrFbs9G +AmwsYr6O00PIisAnZZ0EuRgiZ+O2XmHv4u8mrY/7RTXy3xqj0UUyWoUG9e09raimc6Z zXCUiUsGcOfFFrmI6kk+WEZQIFCAo3iWUN7yjCW1VBr8RgVrbxZholXJEjSEt95RJvrQ 7SLA== X-Gm-Message-State: AOJu0Ywdn/PeRxcVk5SNOEw/3ViXbePNcj5uejAGUNqIBhPPgr3YiAwX 7h0e9bwJgvR2jhQnrKsmi2Uz8oKVlqRhBOhJ6AfCsJ/WF0XRXpjrnorU5A5ngw== X-Gm-Gg: AR+sD11EP/xLUO5KHun7aD6dG8vfEzytZOp7JHBu/VDHCIO8/kJb3OX10arbdZhqGAF CIY8Fv+eH5r2nNrNiv1xETEZKwBbX32sAL8LyFJT9PvHHFJG+dcXZr665Yn+SQ4j+8haNV2N34D OyG9/uCunwz2IsCczzuCS4YeExp988zobg6GNRp3x15nIHERs/zRNq141R6w5fixhKx2riU6Liw M9RiXzE0NYhMvh0K479X1eKVvWglytsXmr3CRIRr8EsHRlr2Wcs0DYkZaACjie2MIkIN3JSIW3J uQjq8OyTwnvgqrW2T1Zx50j37+7HNuaPQkUzN1lACfzJL4x17PqxGoB8fjqWENUZEcUSr+ZYpRu cr5eaiEkF2yQR4HaQSwPzVnp+WxPTHfzARxajHvK+Zf/JCJ219vrGP8ROd7nssuOLZHhskMKzsx y7MQufuulNNuX4e71dcT3lifzc/QsOCSBjArOJW8yimrjHu913tK+Fu669JsdBQC3ebPrFMEn/o Z5oWaMQ0XxKnZmeWvQneLmYLhe2YcCLRDji0ATD9pBsnXgu04DWO8nKB/Q= X-Received: by 2002:a05:600c:314f:b0:499:a07d:a482 with SMTP id 5b1f17b1804b1-499b8454b37mr20454245e9.10.1787254144995; Thu, 20 Aug 2026 12:29:04 -0700 (PDT) Received: from Mein-PC (p200300ed8f249a004c41707296444ab9.dip0.t-ipconnect.de. [2003:ed:8f24:9a00:4c41:7072:9644:4ab9]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499b90e747esm4318415e9.4.2026.08.20.12.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2026 12:29:04 -0700 (PDT) From: Oleg Tolmatcev <oleg.tolmatcev@gmail.com> To: binutils@sourceware.org Cc: Oleg Tolmatcev <oleg.tolmatcev@gmail.com> Subject: [PATCH] bfd: release the PE COMDAT hash once all sections are made Date: Thu, 20 Aug 2026 21:23:46 +0200 Message-ID: <20260820192345.935-2-oleg.tolmatcev@gmail.com> X-Mailer: git-send-email 2.55.0.windows.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 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, RCVD_IN_PBL, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
bfd: release the PE COMDAT hash once all sections are made
|
|
Checks
| Context | Check | Description |
|---|---|---|
| linaro-tcwg-bot/tcwg_binutils_build--master-arm | success | Build passed |
| linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 | success | Build passed |
| linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 | success | Test passed |
| linaro-tcwg-bot/tcwg_binutils_check--master-arm | success | Test passed |
Commit Message
Oleg Tolmatcev
Aug. 20, 2026, 7:23 p.m. UTC
styp_to_sec_flags builds pe_data (abfd)->comdat_hash, one entry plus a
strdup'd symbol name per input section. Nothing frees it during a link,
so it survives to exit.
Free it once the section table has been built. This is safe because
styp_to_sec_flags recreates the hash whenever it finds it NULL.
This significantly reduces peak memory usage.
bfd/
* coffgen.c (coff_real_object_p): Free the COMDAT hash after
the section table has been built.
Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
---
bfd/coffgen.c | 7 +++++++
1 file changed, 7 insertions(+)
In one of my tests this reduces peak memory usage by 12%: 773 MB out of 6532 MB.
Comments
On 20.08.2026 21:23, Oleg Tolmatcev wrote: > styp_to_sec_flags builds pe_data (abfd)->comdat_hash, one entry plus a > strdup'd symbol name per input section. Nothing frees it during a link, > so it survives to exit. > > Free it once the section table has been built. This is safe because > styp_to_sec_flags recreates the hash whenever it finds it NULL. > > This significantly reduces peak memory usage. This is the positive side. How much extra overhead does recreating the hash impose? How often might it need recreating in the worst case? Looks like the answer is zero / never (make_a_section_from_file() is called solely from coff_real_object_p(), and is the sole caller of bfd_coff_styp_to_sec_flags_hook()), but your description suggests otherwise. May I suggest to replace the paragraph with "Free it once the section table has been built. This is safe because styp_to_sec_flags() would recreate the hash whenever it finds it NULL. That's not presently necessary, though." ? If that's okay with you, I can replace the piece of text while committing. Jan
пт, 21 авг. 2026 г. в 13:51, Jan Beulich <jbeulich@suse.com>: > > On 20.08.2026 21:23, Oleg Tolmatcev wrote: > > styp_to_sec_flags builds pe_data (abfd)->comdat_hash, one entry plus a > > strdup'd symbol name per input section. Nothing frees it during a link, > > so it survives to exit. > > > > Free it once the section table has been built. This is safe because > > styp_to_sec_flags recreates the hash whenever it finds it NULL. > > > > This significantly reduces peak memory usage. > > This is the positive side. How much extra overhead does recreating the > hash impose? How often might it need recreating in the worst case? Looks > like the answer is zero / never (make_a_section_from_file() is called > solely from coff_real_object_p(), and is the sole caller of > bfd_coff_styp_to_sec_flags_hook()), but your description suggests > otherwise. May I suggest to replace the paragraph with > > "Free it once the section table has been built. This is safe because > styp_to_sec_flags() would recreate the hash whenever it finds it NULL. > That's not presently necessary, though." > > ? If that's okay with you, I can replace the piece of text while > committing. > > Jan I am of course okay with that too. Thank you. Oleg
diff --git a/bfd/coffgen.c b/bfd/coffgen.c index f3060642a5d..92b867bd187 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -368,6 +368,13 @@ coff_real_object_p (bfd *abfd, } _bfd_coff_free_symbols (abfd); + + if (obj_pe (abfd) && pe_data (abfd)->comdat_hash != NULL) + { + htab_delete (pe_data (abfd)->comdat_hash); + pe_data (abfd)->comdat_hash = NULL; + } + return coff_object_cleanup; fail: