RFC: GAS: Add option to generate unused section symbols
H.J. Lu
hjl.tools@gmail.com
Fri Mar 4 16:05:16 GMT 2022
On Fri, Mar 4, 2022 at 7:54 AM Nick Clifton via Binutils
<binutils@sourceware.org> wrote:
>
> 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
I ran into this problem in the Linux kernel build. I believe the proper
solution is to change the Linux kernel not to include the .o files which
are empty and unused. It isn't so hard to do.
> 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
--
H.J.
More information about the Binutils
mailing list