[RESEND PATCH] Makeconfig: Set pie-ccflag to -fPIE by default

Fangrui Song maskray@google.com
Mon Aug 29 19:57:03 GMT 2022


On 2022-08-29, H.J. Lu via Libc-alpha wrote:
>On Mon, Aug 29, 2022 at 8:27 AM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>>
>> Hi Florian,
>>
>> * Wilco Dijkstra via Libc-alpha:
>> >> However this leads to the question is why aren't all symbols marked as
>> >> hidden in the static PIE build? Ie. are there any symbols that must be
>> >> shared with a DSO loaded by a dl_open?
>> >
>> > The static main executable does not have a dynamic symbol table, so such
>> > sharing cannot happen (except through function pointers being passed
>> > around, but symbol visibility of course does not matter there).
>>
>> Right, so it should be safe then to mark all symbols as hidden.
>>
>> We could also teach GCC to never emit GOT indirections with -fPIE -static
>> (the only reason to use a GOT indirection is to avoid copy relocations in
>> dynamically linked binaries).
>>
>
>But -static isn't passed to cc1.

With Clang, -fPIE -fno-direct-access-external-data can be used.
See https://maskray.me/blog/2021-01-09-copy-relocations-canonical-plt-entries-and-protected

GCC's x86 port went with -mdirect-extern-access.


More information about the Libc-alpha mailing list