[RESEND PATCH] Makeconfig: Set pie-ccflag to -fPIE by default
Fangrui Song
maskray@google.com
Thu Sep 15 21:45:13 GMT 2022
On 2022-09-05, Wilco Dijkstra wrote:
>Hi,
>
>>>> 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.
>
>The driver could just pass it or change -fPIE into a new -fstatic-PIE.
>
>> 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.
>
>Well ideally we'd have the same option that works in both compilers - it's likely easy to
>support in GCC.
>
>It would be great to also have something like -ffast-PIC that implies -fno-semantic-interposition
>since 99% of the time you don't need semantic interposition.
>
>Cheers,
>Wilco
In Clang, -fpic/-fPIC without -fno-semantic-interposition still allows
interprocedural optimizations of default visibility external linkage definitions.
It is unfortunate that GCC doesn't allow it and
--enable-default-semantic-interposition is rejected (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100937)
So if such an option -ffast-PIC is made, it will only benefit GCC.
I have a long write-up in https://maskray.me/blog/2021-05-09-fno-semantic-interposition#in-action
More information about the Libc-alpha
mailing list