RFC: GAS: Add option to generate unused section symbols
Nick Clifton
nickc@redhat.com
Fri Mar 4 15:54:20 GMT 2022
Hi Guys,
With the 2.36 release of the binutils we stopped generating section
symbols if they were not needed by relocations. This helps to reduce
object file size and enhances compatibility with the LLVM compiler.
But I have received some bug reports about this feature, most notably
from kernel maintainers who have found that the new behaviour breaks
the recordmcount tool. So I am proposing the attached patch as a
solution.
The patch adds an option to the assembler: --keep-unused-section-symbols=[yes|no]
which is pretty much self describing. The patch itself is fairly
simple, although there is one area that might provoke comment: Since
the xvec structure in a BFD is accessed via a const pointer, its
contents cannot be changed. This makes sense most of the time, but
poses a problem for this patch since it wants to change the
keep_unused_section_symbols field. So I decided that the simplest way
to resolve this would be to allocate a new xvec structure, fill it in,
and then change the pointer in the bfd. This might be a bit wasteful
of memory, but I am not expecting this feature to be used very often
and I thought that it was better to preserve the const pointer
semantics.
Any comments ?
Cheers
Nick
bfd/ChangeLog
2022-03-04 Nick Clifton <nickc@redhat.com>
* targets.c (bfd_set_keep_unused_section_symbols): New function.
* bfd-in2.h: Rgenerate.
gas/ChangeLog
2022-03-04 Nick Clifton <nickc@redhat.com>
* as.c (keep_unused_sec_syms): New local variable.
(parse_args): Add --keep-unused-section-symbols=[yes|no].
(show_usage): Mention the new option.
(main): Call bfd_set_keep_unused_section_symbols if requested.
* doc/as.texi: Document the new option.
* NEWS: Mention the new feature.
* testsuite/gas/elf/unused-section-symbols.s: New source file.
* testsuite/gas/elf/unused-section-symbols.d: New test.
* testsuite/gas/elf/used-section-symbols.d: New test.
* testsuite/gas/elf/elf.exp: Run the new tests.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unused-sec-syms.patch
Type: text/x-patch
Size: 8282 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20220304/081a5677/attachment-0001.bin>
More information about the Binutils
mailing list