Hello!
Currently a link-time test is done for checking whether -fstack-protector
works. In general, this is correct as using this compiler flag might
indeed involve link-time adjustments: in the case that the host's libc
doesn't provide the __stack_chk_fail etc. symbols, but they are instead
provided by GCC's own libssp.
However, in this specific case that glibc itself is being built, we know
that the glibc-provided programs will always be linked against the
then-built libc, so glibc-internal definitions of these SSP symbols will
be used (cf. csu/libc-start.c:__stack_chk_guard,
debug/stack_chk_fail*.c). So, I'd say that in fact this link-time test
is wrong, as we're no going to link against what we're testing here.
As for testing -fstack-protector being accepted by the compiler driver,
indeed a compile-time test is enough. (And there's no need to create a
temporary .c, and .o file, by the way.)
Testing: still the same content (especially have-ssp = yes) of
configure-generated files on x86_64-unknown-linux-gnu, GCC 4.3.2;
likewise (have-ssp = no) on hppa2.0-unknown-linux-gnu, GCC 4.4.1;
functionality now detected correctly when the target libc is not yet
present (have-ssp = no changed to yes) on arm-eglibc-linux-gnueabi, GCC
4.3.3.
2009-11-08 Thomas Schwinge <thomas@xxxxxxxxxxxxxxxx>
* configure.in (libc_cv_ssp): Make this a compile-time check. Avoid
creating temporary files.
Index: configure.in
===================================================================
--- configure.in (revision 9207)
+++ configure.in (working copy)
@@ -1741,18 +1741,13 @@
AC_SUBST(fno_unit_at_a_time)
AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
-cat > conftest.c <<EOF
-int foo;
-main () { return 0;}
-EOF
if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -Werror -fstack-protector
- -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
+ -o /dev/null -c -x c /dev/null 1>&AS_MESSAGE_LOG_FD])
then
libc_cv_ssp=yes
else
libc_cv_ssp=no
-fi
-rm -f conftest*])
+fi])
AC_SUBST(libc_cv_ssp)
AC_CACHE_CHECK(for -fgnu89-inline, libc_cv_gnu89_inline, [dnl
Regards,
Thomas
Attachment:
pgpB9jCiE8PXr.pgp
Description: PGP signature