[PATCH] Add --generate-unused-section-symbols=[yes|no]

H.J. Lu hjl.tools@gmail.com
Mon Jan 4 00:51:22 GMT 2021


On Sun, Jan 3, 2021 at 3:33 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Sun, Dec 27, 2020 at 07:25:12PM -0800, H.J. Lu via Binutils wrote:
> > For ELF targets, section symbols are required only for relocations.
> > With -ffunction-sections -fdata-sections, there can be many unused
> > section symbols.  Sizes of libstdc++.a on Linux/x86-64 in GCC 11 are
> >
> > With unused section symbols   : 39411698 bytes
> > Without unused section symbols: 39227002 bytes
> >
> > The unused section symbols in libstdc++.a occupy more than 180 KB.
> >
> > Add --generate-unused-section-symbols=[yes|no] to assembler, linker and
> > objcopy.  For assembler and linker, it controls whether to generate
> > unused section symbols.  For objcopy, section symbols in relocatable
> > inputs are always kept and --generate-unused-section-symbols=[yes|no]
> > controls whether to generate unused section symbols in non-relocatable
> > outputs.  Default can be controlled by the configure option,
> > --enable-generate-section-symbols.  Default to no for Linux/x86 targets.
>
> Hi HJ,
> I'm inclined to think that removing unused section symbols is a good
> idea, but that --generate-unused-section-symbols and certainly the
> configure option --enable-generate-section-symbols is undesirable.
> I'd rather not see more configure options that change binutils default
> behaviour, making binutils bug reports more difficult to reproduce.
>

Removing unused section symbols means updating many binutils tests
as well as many assembler backends.  I can submit a patch to remove
unused section symbols and fix all tests on x86.  But I can't cover other
backends.

-- 
H.J.


More information about the Binutils mailing list