[PATCH] gold: Add -Bsymbolic-non-weak-functions

Fangrui Song i@maskray.me
Thu Jun 3 04:28:15 GMT 2021


:)

On Wed, May 26, 2021 at 9:21 PM Fangrui Song <i@maskray.me> wrote:
>
>
> On 2021-05-27, Alan Modra wrote:
> >On Wed, May 26, 2021 at 04:22:46PM -0700, Fangrui Song wrote:
> >> This will be a great addition to the ELF world. (My libLLVM.so
> >> libclang-cpp.so linked clang is more than 15% faster due to saved
> >> dynamic relocations)
> >
> >That is quite an impressive speedup, but couldn't you get exactly the
> >same effect or better by giving functions protected visibility?
>
> The existing -fvisibility=protected is coarse-grained. There isn't an
> option to exclude variables.
>
> Even if we introduce a -fvisibility-functions=protected, there is pointer
> equality issue for C++.
> https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic#pointer-equality-for-functions
> The address of an inline function may be different from the address seen from
> outside the shared object.
>
> (On x86, it is more unfortunate:
> https://maskray.me/blog/2021-01-09-copy-relocations-canonical-plt-entries-and-protected#protected-function-symbols-and-canonical-plt-entries )
>
>
> -Bsymbolic-non-weak-functions is safer.
> We only one thing from compilers https://gcc.gnu.org/PR100593
> [ELF] -fno-pic: Use GOT to take address of an external default visibility function
>
> For many distributions, -fno-pic is very uncommon. The canonical PLT entry problem can mostly be ignored.


More information about the Binutils mailing list