https://sourceware.org/bugzilla/show_bug.cgi?id=27871
Bug ID: 27871 Summary: ld: Add -Bsymbolic-global-functions variant which only applies to STB_GLOBAL STT_FUNC Product: binutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: i at maskray dot me Target Milestone: --- As a poor man's direct binding feature, -Bsymbolic-functions is incompatible with two things: (1) canonical PLT entries with -fno-pic code. This should be fixed on GCC's side https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100593 (2) some vague linkage function definitions. See below cat > ./a.cc <<eof inline void f() {} void *g() { return (void *)&f; } eof cat > ./a.sh <<eof gcc -fpic -fuse-ld=bfd -shared -Wl,-Bsymbolic-functions a.cc -o a.so gcc -fpie -fuse-ld=bfd b.cc ./a.so ./a.out eof cat > ./b.cc <<eof #include <stdio.h> inline void f() {} void *g(); int main() { printf("exe: %p\n", (void *)&f); printf("DSO: %p\n", g()); } eof On Mach-O, such symbols are placed into __LINKEDIT,__weak_binding so that dyld can coalesce the definitions across dylibs. For ELF, we can introduce -Bsymbolic-global-functions to exclude STB_WEAK function definitions, avoiding the pointer equality issue. For more context, see https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic#the-last-alliance-of-elf-and-men -- You are receiving this mail because: You are on the CC list for the bug.