On Tue, 7 Jan 2014, Andreas Schwab wrote:
Richard Biener
writes: The symbol is part of libc.so as well, given the name libc_nonshared.a is always linked statically - libc.so is a linker script:
/* GNU ld script Use the shared library, but some functions are only in the static library, so try that secondarily. */ OUTPUT_FORMAT(elf64-x86-64) GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )
I think this is a bug in the linker in the logic for --as-needed in connection with GROUP. Apparently the linker does not go back and search libc.so.6 again for the undefined symbol __stack_chk_fail referenced by libc_nonshared.a. If I either remote --as-needed or add -lc a second time the link succeeds.
That means a workaround is to change the order of libc.so.6 and
libc_nonshared.a in this group ...
Note it also means your testcase doesn't need libc.so which is
usually unlikely ;)
Note that
int main () {}
rguenther@murzim:~> gcc t.c -fstack-protector-all
works for me on 13.1.
Richard.
--
Richard Biener