diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | Makeconfig | 3 | ||||
-rw-r--r-- | Makerules | 2 | ||||
-rw-r--r-- | config.make.in | 1 | ||||
-rwxr-xr-x | configure | 35 | ||||
-rw-r--r-- | configure.in | 16 | ||||
-rw-r--r-- | time/ctime.c | 6 |
7 files changed, 67 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog index 95a405594e..cde0173851 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2012-05-16 Roland McGrath <roland@hack.frob.com> + + [BZ #10375] + * configure.in: Check for _FORTIFY_SOURCE being predefined. + (CPPUNDEFS): New substituted variable; add -U_FORTIFY_SOURCE if needed. + * configure: Regenerated. + * config.make.in (CPPUNDEFS): New substituted variable. + * Makeconfig (CPPFLAGS): Put $(CPPUNDEFS) at the beginning. + * Makerules ($(stdio_lim:h=st)): Use $(CPPUNDEFS). + * time/ctime.c: Don't #undef __OPTIMIZE__ and ctime. + 2012-05-16 H.J. Lu <hongjiu.lu@intel.com> * sysdeps/unix/sysv/linux/bits/mqueue.h: Include <bits/types.h>. diff --git a/Makeconfig b/Makeconfig index f68a752766..b81594f077 100644 --- a/Makeconfig +++ b/Makeconfig @@ -661,7 +661,8 @@ libio-include = -I$(..)libio # Note that we can't use -std=* in CPPFLAGS, because it overrides # the implicit -lang-asm and breaks cpp behavior for .S files--notably # it causes cpp to stop predefining __ASSEMBLER__. -CPPFLAGS = $(CPPFLAGS-config) $($(subdir)-CPPFLAGS) $(+includes) $(defines) \ +CPPFLAGS = $(CPPUNDEFS) $(CPPFLAGS-config) $($(subdir)-CPPFLAGS) \ + $(+includes) $(defines) \ -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \ $(CPPFLAGS-$(suffix $@)) \ $(foreach lib,$(libof-$(basename $(@F))) \ diff --git a/Makerules b/Makerules index f374700a3e..528077aa7d 100644 --- a/Makerules +++ b/Makerules @@ -1233,7 +1233,7 @@ $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \ echo '#define _LIBC 1'; \ echo '#include "$(..)misc/sys/uio.h"'; } | \ $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)' \ - $(+includes) -xc - -o $(@:st=hT) + $(CPPUNDEFS) $(+includes) -xc - -o $(@:st=hT) sed $(sed-remove-objpfx) $(sed-remove-dotdot) \ $(@:st=dT) > $(@:st=dt) mv -f $(@:st=dt) $(@:st=d) diff --git a/config.make.in b/config.make.in index 6c4d04ee33..4fa26081ff 100644 --- a/config.make.in +++ b/config.make.in @@ -104,6 +104,7 @@ CXX = @CXX@ BUILD_CC = @BUILD_CC@ CFLAGS = @CFLAGS@ CPPFLAGS-config = @CPPFLAGS@ +CPPUNDEFS = @CPPUNDEFS@ ASFLAGS-config = @ASFLAGS_config@ AR = @AR@ MAKEINFO = @MAKEINFO@ diff --git a/configure b/configure index e664260b06..c295277e40 100755 --- a/configure +++ b/configure @@ -632,6 +632,7 @@ libc_cv_localedir libc_cv_slibdir old_glibc_headers libc_cv_gcc_unwind_find_fde +CPPUNDEFS sizeof_long_double EGREP GREP @@ -7542,6 +7543,40 @@ _ACEOF sizeof_long_double=$ac_cv_sizeof_long_double +CPPUNDEFS= +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FORTIFY_SOURCE predefine" >&5 +$as_echo_n "checking for _FORTIFY_SOURCE predefine... " >&6; } +if ${libc_cv_predef_fortify_source+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + +#ifdef _FORTIFY_SOURCE +# error bogon +#endif + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libc_cv_predef_fortify_source=no +else + libc_cv_predef_fortify_source=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_predef_fortify_source" >&5 +$as_echo "$libc_cv_predef_fortify_source" >&6; } +if test $libc_cv_predef_fortify_source = yes; then + CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE" +fi + + ### End of automated tests. ### Now run sysdeps configure fragments. diff --git a/configure.in b/configure.in index ce4b7ad02b..0916e9ec5c 100644 --- a/configure.in +++ b/configure.in @@ -2036,6 +2036,22 @@ AC_CHECK_SIZEOF(long double, 0) sizeof_long_double=$ac_cv_sizeof_long_double AC_SUBST(sizeof_long_double) +CPPUNDEFS= +dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE. +dnl Since we are building the implementations of the fortified functions here, +dnl having the macro defined interacts very badly. +AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source, +[AC_TRY_COMPILE([], [ +#ifdef _FORTIFY_SOURCE +# error bogon +#endif], + [libc_cv_predef_fortify_source=no], + [libc_cv_predef_fortify_source=yes])]) +if test $libc_cv_predef_fortify_source = yes; then + CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE" +fi +AC_SUBST(CPPUNDEFS) + ### End of automated tests. ### Now run sysdeps configure fragments. diff --git a/time/ctime.c b/time/ctime.c index 28321af32b..ca2d3ea2ff 100644 --- a/time/ctime.c +++ b/time/ctime.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1991-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,12 +15,8 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#undef __OPTIMIZE__ /* Avoid inline `ctime' function. */ #include <time.h> -#undef ctime - - /* Return a string as returned by asctime which is the representation of *T in that form. */ char * |