[PATCH] ELF: Don't generate unused section symbols
H.J. Lu
hjl.tools@gmail.com
Mon Jan 4 18:43:20 GMT 2021
On Sun, Jan 3, 2021 at 4:51 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> 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.
Here is the patch.
Tested on Linux/x86. Other ELF backends need:
1. Mark used section symbols in assembler backend.
2. Remove unused section symbols from expected assembler and linker
outputs.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ELF-Don-t-generate-unused-section-symbols.patch
Type: text/x-patch
Size: 127325 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20210104/563d6be6/attachment-0001.bin>
More information about the Binutils
mailing list