https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100937
--- Comment #6 from Fangrui Song <i at maskray dot me> --- Then can you add a -fvisibility=protected variant which only applies to non-weak defined functions? Two issues need to be fixed: (1): https://sourceware.org/bugzilla/show_bug.cgi?id=27973 __attribute__((visibility("protected"))) void *foo () { return (void *)foo; } % gcc -fpic -shared -fuse-ld=bfd a.s /usr/bin/ld.bfd: /tmp/ccWPJCLw.o: relocation R_X86_64_PC32 against protected symbol `foo' can not be used when making a shared object /usr/bin/ld.bfd: final link failed: bad value collect2: error: ld returned 1 exit status (2): https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100593 [ELF] -fno-pic: Use GOT to take address of an external default visibility function Distributions want fast C++ non-vague-linkage functions can enable this option.