seen when using ld.bfd 2.32 with clang 7 or 8, works with GCC: # Segfault https://bugs.llvm.org/show_bug.cgi?id=26580 echo ' extern int a; extern void bar (void); int main() { bar (); if (a != 30) __builtin_abort(); return 0; }' > x.c echo 'int a; __attribute__((visibility("protected"))) int a; void bar () { a = 30; } ' > bar.c # reported in https://bugs.llvm.org/show_bug.cgi?id=26580#c18 if [ $DEB_HOST_ARCH != "i386" ]; then clang-$VERSION -O3 -c -o x.o x.c clang-$VERSION -O3 -fpic -c -o bar.o bar.c clang-$VERSION -fuse-ld=bfd -shared -o libfoo.so bar.o clang-$VERSION -fuse-ld=bfd -o y x.o libfoo.so -Wl,-R,. # Still failing, commenting ./y || true fi /usr/bin/ld.bfd: bar.o: relocation R_X86_64_PC32 against protected symbol `a' can not be used when making a shared object /usr/bin/ld.bfd: final link failed: nonrepresentable section on output clang: error: linker command failed with exit code 1 (use -v to see invocation) The failing command is: clang-$VERSION -fuse-ld=bfd -shared -o libfoo.so bar.o
LLVM issue? https://bugs.llvm.org/show_bug.cgi?id=26580
This is a clang bug. *** This bug has been marked as a duplicate of bug 24151 ***