https://sourceware.org/bugzilla/show_bug.cgi?id=28875
Bug ID: 28875 Summary: ld should warn or error out about creating copy relocs & direct external references for protected symbols Product: binutils Version: 2.38 Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: thiago at kde dot org Target Milestone: --- Related: #15228, #17711, #27973. For a library that has protected symbols: $ cat libb2.cpp __attribute__((visibility("protected"))) long internal_i = 0; __attribute__((visibility("protected"))) long internal_f() { return 2; } $ gcc -shared -fPIC -o libb.so libb2.cpp $ eu-readelf --dyn-syms libb.so| grep internal 5: 0000000000004028 8 OBJECT GLOBAL PROTECTED 22 internal_i 6: 00000000000010f9 11 FUNC GLOBAL PROTECTED 11 _Z10internal_fv The linker should produce a warning when creating copy relocations or position-dependent moves: $ cat main.cpp extern __attribute__((visibility("default"))) long internal_i; extern __attribute__((visibility("default"))) long internal_f(); int main() { internal_i = (long) &internal_f; } $ gcc main.cpp libb.so [no error] gold already does: $ gcc -fuse-ld=gold main.cpp libb.so /usr/bin/ld.gold: error: /tmp/ccg0cNpy.o: cannot make copy relocation for protected symbol 'internal_i', defined in libb.so collect2: error: ld returned 1 exit status -- You are receiving this mail because: You are on the CC list for the bug.