From patchwork Fri Dec 13 04:27:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 102947 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 1335B3858C52 for ; Fri, 13 Dec 2024 04:28:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1335B3858C52 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Oh7pJzUG X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id C2A433858D38 for ; Fri, 13 Dec 2024 04:27:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2A433858D38 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 C2A433858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::434 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734064044; cv=none; b=ZR9BuBKkOrL5tYp/j9VYGXPuiCVMpu4quuM+uHagePJAKji2acqgWXU47pSA75a4Af3PVJAxCj5j1QwsDzJTsLG7iJFDuURekS1ABcN9dMWSFU+vW21FN37nWmcJKD74dsoK4s0BzOkkgdJJ61QyJUu3QD7CdOdjPs0yXVUtXMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734064044; c=relaxed/simple; bh=uOMFIm/yP48dhFTe1zy+OiVelIt+H8dARAc9sVjX0qg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=EvlFEOqRKIZ2WOL3ZGxmOwsqDNXJa0n8F/AFPo47yCl52Ewujiq0ITSpwgwwE6h/GqCjV7cyNoWv1JT80RJjk03cGIA0bK1gR9frRCrVDVexOZfPrIr+lEJgJa82OWz7XQF2LiVARMzeh3+8SInSlBIUM1TT2l5pGWEw7b3gfus= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2A433858D38 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-728e729562fso1092844b3a.0 for ; Thu, 12 Dec 2024 20:27:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734064043; x=1734668843; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=MrkB9RE6eb6DdPaU5+yWmWE3yWX5drGUyGnFo1LBoI4=; b=Oh7pJzUGaXr53/x9iLdBeG+FsGqelBZ7lXUJXiWs3edqsVGd8q6HrwAepkkhWxoXqM 75wDO2MVgiktUcipsCkIJokpjUx5J7IUOGZ6HFhFGn2ljZssBkX3Y9vCrUnvZ62B2Yuv unnsmlKpe6CgbowApU7rlP83EJXFdEhjhdPBsTG+nYWWUWXpI9nzcg0NeHFVR/SystqE G/gU/jV9WK4/etvpm84ru0CanP3wBVUuuZFZnk8IOzvMAXZ8Sq0CpcWefdA1wrZjuzfb g26TgbWDhGtG5IfwXZY5coM9vhheEr4hIpAfkmRVZbW5ixJBpnldimBz/m8bDk/Mqpxo 8foQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734064043; x=1734668843; 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=MrkB9RE6eb6DdPaU5+yWmWE3yWX5drGUyGnFo1LBoI4=; b=bY5u/BTENNJI5VVUkGSX5WzXQxMkB3i6Z0Quvt9KDCdaMIk97v4R0gyAW3L8/FPtr0 WD9TP+KmwgGhz7iwDYZ86pmSN32aTYSV9iuM14Kktv29SJnN+a8zRmx0tGUBZf3xZetH azd/MoGvTK6rvvUA7rMtzlov9CZqHnRObuRuJWg0c6YBCoHvNOAHqtmjNpMXk9pOsp7n ULhhHwzsJkQTzGaFzoGiT0E/zQgGN6JkqffpO6vq6xcJbK1WwFeUXvBHFkADbNKGbtb9 H9q176KoYFa9t5wn1YSq63p7d2MVT0659POsPDW899W6DMvyTZuAsNvxVnce7YBfmWvW 4Bqg== X-Gm-Message-State: AOJu0Yx9axPT7Un6zVAyWAUpmKfXtPOmcsEfb+7ShZafznMob8zVse5N Y8kAAgaGYVyUWCkec7K/1zPvQXKRziAB3mKE6RFdAj5fStZmMtPDv7LL5g== X-Gm-Gg: ASbGncunXlzkMtbi5d9ixnskT1Az5B46592nXzA4pdAUulS8hTJV/45r8uBem7UAAaO LsBkriYv4htDnEA6eg5Ls4EUKp/44DI29KX1P/xCP7sjY2CXTw95uMJmuA53cNdygDpAlvMv2Q2 zjY+O18vdXQz4IFdgb638RGrKHRUMyRres2IaASIBYC1ETPLlm3aGPWWMuhVgtZnfCVCR3BApjF IBEbYwecMbaXi6xQMylNO1aNv8am9bHB5Bv0fJ6KQTzazkrXAKinFzU/pj5IPLeQtZ51/JkBUX0 XQOJFAiWZEbduaXxi6A+ceIJPpU= X-Google-Smtp-Source: AGHT+IHu/u3xcnIWw6bect9GkdpTwnrJINJ1UhJ3v/9+7uiqWbg5TzSLfdseJoHvHBOduB5jxwYW8g== X-Received: by 2002:a05:6a00:228b:b0:725:ef4b:de30 with SMTP id d2e1a72fcca58-7290c1a8691mr1803957b3a.14.1734064043315; Thu, 12 Dec 2024 20:27:23 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd45b78c7fsm7315976a12.15.2024.12.12.20.27.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 20:27:22 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 42C671140638; Fri, 13 Dec 2024 14:57:20 +1030 (ACDT) Date: Fri, 13 Dec 2024 14:57:20 +1030 From: Alan Modra To: binutils@sourceware.org Subject: objdump: Delete close optimisation Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3032.9 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org In commit cd6581da62c3, Nick made an optimisation that was reasonable at the time, but then pr22032 came along and commit 7c0ed39626e3 made bfd_close_all_done free memory. So Nick's optimisation is now ineffective, and the comment wrong. * objdump.c (display_file): Delete last_file param. Update caller. Call bfd_close always. diff --git a/binutils/objdump.c b/binutils/objdump.c index f409d679831..5e68324f9c5 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -5932,7 +5932,7 @@ display_any_bfd (bfd *file, int level) } static void -display_file (char *filename, char *target, bool last_file) +display_file (char *filename, char *target) { bfd *file; @@ -5951,18 +5951,7 @@ display_file (char *filename, char *target, bool last_file) display_any_bfd (file, 0); - /* This is an optimization to improve the speed of objdump, especially when - dumping a file with lots of associated debug informatiom. Calling - bfd_close on such a file can take a non-trivial amount of time as there - are lots of lists to walk and buffers to free. This is only really - necessary however if we are about to load another file and we need the - memory back. Otherwise, if we are about to exit, then we can save (a lot - of) time by only doing a quick close, and allowing the OS to reclaim the - memory for us. */ - if (! last_file) - bfd_close (file); - else - bfd_close_all_done (file); + bfd_close (file); } int @@ -6362,11 +6351,11 @@ main (int argc, char **argv) else { if (optind == argc) - display_file ("a.out", target, true); + display_file ("a.out", target); else for (; optind < argc;) { - display_file (argv[optind], target, optind == argc - 1); + display_file (argv[optind], target); optind++; } }