So it turns out that ld hanging on the backtrace is actually glibc bug https://sourceware.org/bugzilla/show_bug.cgi?id=16159 getting tickled. Setting the MALLOC_CHECK_ environment variable causes it not to hang, by not trying to emit the back trace and deadlocking on reacquiring the malloc lock:
$ MALLOC_CHECK_=2 gcc -o /tmp/conftest -fPIE -pie -static conftest.c
collect2: error: ld terminated with signal 6 [Aborted], core dumped
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elflink.c:13053
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elflink.c:13053
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elflink.c:13053
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elflink.c:13053
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/elflink.c:13053
So it turns out that ld hanging on the backtrace is actually glibc bug https:/ /sourceware. org/bugzilla/ show_bug. cgi?id= 16159 getting tickled. Setting the MALLOC_CHECK_ environment variable causes it not to hang, by not trying to emit the back trace and deadlocking on reacquiring the malloc lock:
$ MALLOC_CHECK_=2 gcc -o /tmp/conftest -fPIE -pie -static conftest.c elflink. c:13053 elflink. c:13053 elflink. c:13053 elflink. c:13053 elflink. c:13053
collect2: error: ld terminated with signal 6 [Aborted], core dumped
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.24 assertion fail ../../bfd/