[PATCH] libio: Properly link in libio functions in static binaries

Florian Weimer fweimer@redhat.com
Mon Aug 25 13:22:47 GMT 2025


* H. J. Lu:

> On Mon, Aug 25, 2025 at 6:09 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> >> Hmm.  The --strip-unneeded option says this:
>> >>
>> >>        --strip-unneeded
>> >>            Remove all symbols that are not needed for relocation processing in
>> >>            addition to debugging symbols and sections stripped by
>> >>            --strip-debug.
>> >>
>> >> I think it's a user error to use this on libc.a.  What's the benefit of
>> >
>> > Why can't --strip-unneeded be used on libc.a? If a symbol isn't used for
>> > relocation processing, it is unused.
>>
>> It's only unused from the individual .o file that the strip command
>> processes.  It's not unused from a global perspective.  We'll add more
>
> An undefined entry in the symbol table without relocation is unneeded
> for "relocation processing".
>
>> references like these once we improve support for static linking.
>>
>> Developers should run --strip-unneeded on the output file, not the input
>
> The key word is "relocation processing".   Most of the outputs don't need
> relocation processing.

Fair point.  But that doesn't explain we need to support running
--strip-unneeded.  The .symtab references are a surprisingly clean way
to pull in other objects as needed.  I just don't see a good reason to
break that, and switch to runtime relocations instead.

Thanks,
Florian



More information about the Libc-alpha mailing list