This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] New option --print-gc-sections
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: binutils at gcc dot gnu dot org, Arnaud Charlet <charlet at adacore dot com>
- Date: Mon, 3 Apr 2006 17:20:17 +0930
- Subject: Re: [PATCH] New option --print-gc-sections
- References: <200603281131.41402.ebotcazou@adacore.com> <20060329124950.GD22754@bubble.grove.modra.org> <200604030839.41118.ebotcazou@adacore.com>
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