From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23856 invoked by alias); 3 Apr 2006 07:50:23 -0000 Received: (qmail 23847 invoked by uid 22791); 3 Apr 2006 07:50:23 -0000 X-Spam-Check-By: sourceware.org Received: from CPE-144-136-172-108.sa.bigpond.net.au (HELO grove.modra.org) (144.136.172.108) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 03 Apr 2006 07:50:20 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id 56D1E1DD477; Mon, 3 Apr 2006 17:20:17 +0930 (CST) Date: Mon, 03 Apr 2006 07:50:00 -0000 From: Alan Modra To: Eric Botcazou Cc: binutils@gcc.gnu.org, Arnaud Charlet Subject: Re: [PATCH] New option --print-gc-sections Message-ID: <20060403075017.GB9418@bubble.grove.modra.org> Mail-Followup-To: Eric Botcazou , binutils@gcc.gnu.org, Arnaud Charlet References: <200603281131.41402.ebotcazou@adacore.com> <20060329124950.GD22754@bubble.grove.modra.org> <200604030839.41118.ebotcazou@adacore.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200604030839.41118.ebotcazou@adacore.com> User-Agent: Mutt/1.4i X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00015.txt.bz2 On Mon, Apr 03, 2006 at 08:39:40AM +0200, Eric Botcazou wrote: > > Actually, you can already glean this from a link map. GC'd sections > > will be those that are shown with zero size. > > That doesn't seem to work. Silly me. I'd forgotten that discarded linkonce sections don't have a lang_input_section statement, and the link map is built by looking through the list of linker statements. No statement, no mention. I still like the idea of displaying discarded sections in the link map output though. I think it would be useful to do so whenever -Map or -M is given, so you wouldn't need a new ld option. You also shouldn't need any new hooks. At the end of lang_map, just iterate over input sections, looking for any that don't make it to the output bfd. LANG_FOR_EACH_INPUT_STATEMENT (file) { asection *s; if ((file->the_bfd->flags & (BFD_LINKER_CREATED | DYNAMIC)) != 0 || file->just_syms_flag) continue; for (s = file->the_bfd->sections; s != NULL; s = s->next) if (s->output_section == NULL || s->output_section->owner != output_bfd) { /* This section was excluded from the output for some reason. */ } } -- Alan Modra IBM OzLabs - Linux Technology Centre