diff -Naur gcc-4.1.2.orig/gcc/cppdefault.c gcc-4.1.2/gcc/cppdefault.c --- gcc-4.1.2.orig/gcc/cppdefault.c 2005-06-25 02:02:01.000000000 +0000 +++ gcc-4.1.2/gcc/cppdefault.c 2007-12-25 05:50:35.000000000 +0000 @@ -33,6 +33,15 @@ #define STANDARD_INCLUDE_COMPONENT 0 #endif +#if !defined(LIBSSP_INCLUDE_DIR) && defined(__UCLIBC__) +# ifdef GCC_INCLUDE_DIR +# define SSP_INCLUDE_SUBDIR "/ssp" +# define LIBSSP_INCLUDE_DIR GCC_INCLUDE_DIR SSP_INCLUDE_SUBDIR +# else +# error "GCC_INCLUDE_DIR is not defined" +# endif +#endif + #if defined (CROSS_COMPILE) && !defined (TARGET_SYSTEM_ROOT) # undef LOCAL_INCLUDE_DIR # undef SYSTEM_INCLUDE_DIR @@ -69,6 +78,10 @@ /* This is the dir for fixincludes and for gcc's private headers. */ { GCC_INCLUDE_DIR, "GCC", 0, 0, 0 }, #endif +#ifdef LIBSSP_INCLUDE_DIR + /* Include ssp/ for default -D_FORTIFY_SOURCE */ + { LIBSSP_INCLUDE_DIR, "GCC", 0, 0, 0 }, +#endif #ifdef CROSS_INCLUDE_DIR /* One place the target system's headers might be. */ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0 }, diff -Naur gcc-4.1.2.orig/gcc/gcc.c gcc-4.1.2/gcc/gcc.c --- gcc-4.1.2.orig/gcc/gcc.c 2006-11-07 14:26:21.000000000 +0000 +++ gcc-4.1.2/gcc/gcc.c 2007-12-25 05:30:21.000000000 +0000 @@ -724,12 +724,18 @@ # define SYSROOT_HEADERS_SUFFIX_SPEC "" #endif +#ifdef __UCLIBC__ +#define LINK_FORTIFY_SPEC "%{!U_FORTIFY_SOURCE:-lssp_nonshared -lssp}" +#else +#define LINK_FORTIFY_SPEC "" +#endif + static const char *asm_debug; static const char *cpp_spec = CPP_SPEC; static const char *cc1_spec = CC1_SPEC; static const char *cc1plus_spec = CC1PLUS_SPEC; static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC; -static const char *link_ssp_spec = LINK_SSP_SPEC; +static const char *link_ssp_spec = LINK_SSP_SPEC " " LINK_FORTIFY_SPEC; static const char *asm_spec = ASM_SPEC; static const char *asm_final_spec = ASM_FINAL_SPEC; static const char *link_spec = LINK_SPEC; @@ -765,6 +771,7 @@ file that happens to exist is up-to-date. */ static const char *cpp_unique_options = "%{C|CC:%{!E:%eGCC does not support -C or -CC without -E}}\ + %{!D_FORTIFY_SOURCE=*:-D_FORTIFY_SOURCE=2}\ %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I\ %{MD:-MD %{!o:%b.d}%{o*:%.d%*}}\ %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}}\ @@ -801,6 +808,7 @@ %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\ %{fsyntax-only:-o %j} %{-param*}\ %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants}\ + %{!O*:-O}\ %{coverage:-fprofile-arcs -ftest-coverage}"; static const char *asm_options = diff -Naur gcc-4.1.2.orig/libssp/Makefile.am gcc-4.1.2/libssp/Makefile.am --- gcc-4.1.2.orig/libssp/Makefile.am 2006-02-28 00:29:00.000000000 +0000 +++ gcc-4.1.2/libssp/Makefile.am 2007-12-24 19:39:07.000000000 +0000 @@ -7,6 +7,7 @@ AUTOMAKE_OPTIONS = 1.9.5 foreign ACLOCAL_AMFLAGS = -I .. -I ../config MAINT_CHARSET = latin1 +AM_CPPFLAGS= -U_FORTIFY_SOURCE # May be used by various substitution variables. gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) diff -Naur gcc-4.1.2.orig/libssp/Makefile.in gcc-4.1.2/libssp/Makefile.in --- gcc-4.1.2.orig/libssp/Makefile.in 2006-09-29 21:27:38.000000000 +0000 +++ gcc-4.1.2/libssp/Makefile.in 2007-12-24 19:39:07.000000000 +0000 @@ -214,6 +214,7 @@ AUTOMAKE_OPTIONS = 1.9.5 foreign ACLOCAL_AMFLAGS = -I .. -I ../config MAINT_CHARSET = latin1 +AM_CPPFLAGS = -U_FORTIFY_SOURCE # May be used by various substitution variables. gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) diff -Naur gcc-4.1.2.orig/libssp/ssp/stdio.h gcc-4.1.2/libssp/ssp/stdio.h --- gcc-4.1.2.orig/libssp/ssp/stdio.h 2005-08-17 03:26:45.000000000 +0000 +++ gcc-4.1.2/libssp/ssp/stdio.h 2007-12-24 19:40:51.000000000 +0000 @@ -33,6 +33,9 @@ however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ +#if defined(__need_FILE) || defined(__need__FILE) +#include_next +#else #ifndef _SSP_STDIO_H #define _SSP_STDIO_H 1 @@ -99,3 +102,4 @@ #endif /* __SSP_FORTIFY_LEVEL > 0 */ #endif /* _SSP_STDIO_H */ +#endif /* __need_FILE */