https://sourceware.org/bugzilla/show_bug.cgi?id=28876
Bug ID: 28876 Summary: gold should error out when creating a direct reference to protected function Product: binutils Version: 2.38 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: thiago at kde dot org CC: ian at airs dot com Target Milestone: --- Related to #28875 Given library: $ 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 gold already produces an error if it would need to create a copy relocation for the variable: $ 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 -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 However, it does not for the function address: $ cat main.cpp extern __attribute__((visibility("default"))) long internal_f(); int main() { return (long) &internal_f; } $ gcc -fuse-ld=gold main.cpp libb.so $ objdump --no-show -Cdr a.out| sed -n '/<main>:/,/^$/p' 00000000004005e6 <main>: 4005e6: push %rbp 4005e7: mov %rsp,%rbp 4005ea: mov $0x4004f0,%eax 4005ef: pop %rbp 4005f0: ret -- You are receiving this mail because: You are on the CC list for the bug.