[PATCH] New option --print-gc-sections
Alan Modra
amodra@bigpond.net.au
Mon Apr 3 07:50:00 GMT 2006
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
More information about the Binutils
mailing list