From: Michael Tremer Date: Mon, 5 Apr 2010 13:11:51 +0000 (+0200) Subject: toolchain: Forget to add gcc patches. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b52a68bb3b8daaab23c638eae81ae3ea4ad2d66;p=ipfire-3.x.git toolchain: Forget to add gcc patches. --- diff --git a/pkgs/toolchain/gcc-static/patches/gcc-4.4-optimize_linking.patch b/pkgs/toolchain/gcc-static/patches/gcc-4.4-optimize_linking.patch new file mode 100644 index 000000000..659586da3 --- /dev/null +++ b/pkgs/toolchain/gcc-static/patches/gcc-4.4-optimize_linking.patch @@ -0,0 +1,24 @@ +diff -Naur gcc-4.4-20100216.orig/gcc/config/i386/linux.h gcc-4.4-20100216/gcc/config/i386/linux.h +--- gcc-4.4-20100216.orig/gcc/config/i386/linux.h 2010-02-26 17:44:46.000000000 +0000 ++++ gcc-4.4-20100216/gcc/config/i386/linux.h 2010-02-26 17:46:55.000000000 +0000 +@@ -113,7 +113,7 @@ + { "dynamic_linker", LINUX_DYNAMIC_LINKER } + + #undef LINK_SPEC +-#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ ++#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} --hash-style=gnu -O1 \ + %{!shared: \ + %{!ibcs: \ + %{!static: \ +diff -Naur gcc-4.4-20100216.orig/gcc/config/i386/linux64.h gcc-4.4-20100216/gcc/config/i386/linux64.h +--- gcc-4.4-20100216.orig/gcc/config/i386/linux64.h 2010-02-26 17:44:46.000000000 +0000 ++++ gcc-4.4-20100216/gcc/config/i386/linux64.h 2010-02-26 17:47:47.000000000 +0000 +@@ -75,7 +75,7 @@ + #endif + + #undef LINK_SPEC +-#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} \ ++#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} --hash-style=gnu -O1 \ + %{shared:-shared} \ + %{!shared: \ + %{!static: \ diff --git a/pkgs/toolchain/gcc-static/patches/gcc-4.4.1-espf-1.patch b/pkgs/toolchain/gcc-static/patches/gcc-4.4.1-espf-1.patch new file mode 100644 index 000000000..e531e136b --- /dev/null +++ b/pkgs/toolchain/gcc-static/patches/gcc-4.4.1-espf-1.patch @@ -0,0 +1,504 @@ +diff -Nur gcc-4.4.0_vanilla/gcc/config.in gcc-4.4.0/gcc/config.in +--- gcc-4.4.0_vanilla/gcc/config.in 2009-04-21 11:08:08.000000000 +0200 ++++ gcc-4.4.0/gcc/config.in 2009-07-11 12:35:50.000000000 +0200 +@@ -65,6 +65,12 @@ + #endif + + ++/* Define to 1 to enable espf. */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_ESPF ++#endif ++ ++ + /* Define to 1 to enable fixed-point arithmetic extension to C. */ + #ifndef USED_FOR_TARGET + #undef ENABLE_FIXED_POINT +@@ -101,6 +107,12 @@ + #endif + + ++/* Define to 1 to enable libssp. */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_LIBSSP ++#endif ++ ++ + /* Define to 1 if translation of program messages to the user's native + language is requested. */ + #ifndef USED_FOR_TARGET +@@ -1465,6 +1477,12 @@ + #endif + + ++/* Define if your target C library provides fortify_sources level 2 support */ ++#ifndef USED_FOR_TARGET ++#undef TARGET_LIBC_PROVIDES_FORTIFY2 ++#endif ++ ++ + /* Define if your target C library provides stack protector support */ + #ifndef USED_FOR_TARGET + #undef TARGET_LIBC_PROVIDES_SSP +diff -Nur gcc-4.4.0_vanilla/gcc/configure gcc-4.4.0/gcc/configure +--- gcc-4.4.0_vanilla/gcc/configure 2009-03-24 18:46:03.000000000 +0100 ++++ gcc-4.4.0/gcc/configure 2009-07-11 12:35:57.000000000 +0200 +@@ -458,7 +458,7 @@ + # include + #endif" + +-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_libsubdir build_subdir host_subdir target_subdir GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT GNATBIND ac_ct_GNATBIND GNATMAKE ac_ct_GNATMAKE NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP EGREP loose_warn strict_warn warn_cflags nocommon_flag TREEBROWSER valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_decimal_float enable_fixed_point enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI datarootdir docdir htmldir SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file extra_opt_files USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS BUILD_LDFLAGS STMP_FIXINC STMP_FIXPROTO collect2 LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN OBJDUMP ac_ct_OBJDUMP ac_ct_AR STRIP ac_ct_STRIP lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 objdir enable_fast_install gcc_cv_as ORIGINAL_AS_FOR_TARGET gcc_cv_ld ORIGINAL_LD_FOR_TARGET gcc_cv_nm ORIGINAL_NM_FOR_TARGET gcc_cv_objdump gcc_cv_readelf libgcc_visibility GGC zlibdir zlibinc MAINT gcc_tooldir dollar slibdir subdirs srcdir all_compilers all_gtfiles all_lang_makefrags all_lang_makefiles all_languages all_selected_languages build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines build_file_translate check_languages cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs fortran_target_objs target_cpu_default GMPLIBS GMPINC PPLLIBS PPLINC CLOOGLIBS CLOOGINC LIBOBJS LTLIBOBJS' ++ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_libsubdir build_subdir host_subdir target_subdir GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT GNATBIND ac_ct_GNATBIND GNATMAKE ac_ct_GNATMAKE NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP EGREP loose_warn strict_warn warn_cflags nocommon_flag TREEBROWSER valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_decimal_float enable_fixed_point enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI datarootdir docdir htmldir SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file extra_opt_files USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS BUILD_LDFLAGS STMP_FIXINC STMP_FIXPROTO collect2 LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN OBJDUMP ac_ct_OBJDUMP ac_ct_AR STRIP ac_ct_STRIP lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 objdir enable_fast_install gcc_cv_as ORIGINAL_AS_FOR_TARGET gcc_cv_ld ORIGINAL_LD_FOR_TARGET gcc_cv_nm ORIGINAL_NM_FOR_TARGET gcc_cv_objdump gcc_cv_readelf libgcc_visibility enable_espf GGC zlibdir zlibinc MAINT gcc_tooldir dollar slibdir subdirs srcdir all_compilers all_gtfiles all_lang_makefrags all_lang_makefiles all_languages all_selected_languages build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines build_file_translate check_languages cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs fortran_target_objs target_cpu_default GMPLIBS GMPINC PPLLIBS PPLINC CLOOGLIBS CLOOGINC LIBOBJS LTLIBOBJS' + ac_subst_files='language_hooks' + ac_pwd=`pwd` + +@@ -1078,6 +1078,11 @@ + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) ++ --enable-espf ++ Enable Stack protector, Position independent executable and ++ Fortify_sources as default if we have suppot for it when compiling ++ and link with -z relro and -z now as default. ++ Linux targets supported i*86, x86_64 + --enable-maintainer-mode + enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer +@@ -24177,6 +24182,50 @@ + ;; + esac + ++echo "$as_me:$LINENO: checking linker -z now support" >&5 ++echo $ECHO_N "checking linker -z now support... $ECHO_C" >&6 ++if test "${gcc_cv_ld_now+set}" = set; then ++ echo $ECHO_N "(cached) $ECHO_C" >&6 ++else ++ gcc_cv_ld_now=no ++if test $in_tree_ld = yes ; then ++ if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \ ++ && test $in_tree_ld_is_elf = yes; then ++ gcc_cv_ld_now=yes ++ fi ++elif test x$gcc_cv_ld != x; then ++ # Check if linker supports -z now options ++ if $gcc_cv_ld --help 2>/dev/null | grep now > /dev/null; then ++ gcc_cv_ld_now=yes ++ fi ++fi ++ ++fi ++echo "$as_me:$LINENO: result: $gcc_cv_ld_now" >&5 ++echo "${ECHO_T}$gcc_cv_ld_now" >&6 ++ ++echo "$as_me:$LINENO: checking linker -z relro support" >&5 ++echo $ECHO_N "checking linker -z relro support... $ECHO_C" >&6 ++if test "${gcc_cv_ld_relro+set}" = set; then ++ echo $ECHO_N "(cached) $ECHO_C" >&6 ++else ++ gcc_cv_ld_relro=no ++if test $in_tree_ld = yes ; then ++ if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \ ++ && test $in_tree_ld_is_elf = yes; then ++ gcc_cv_ld_relro=yes ++ fi ++elif test x$gcc_cv_ld != x; then ++ # Check if linker supports -z relro and -z norelro options ++ if $gcc_cv_ld --help 2>/dev/null | grep relro > /dev/null; then ++ gcc_cv_ld_relro=yes ++ fi ++fi ++ ++fi ++echo "$as_me:$LINENO: result: $gcc_cv_ld_relro" >&5 ++echo "${ECHO_T}$gcc_cv_ld_relro" >&6 ++ + echo "$as_me:$LINENO: checking linker --sysroot support" >&5 + echo $ECHO_N "checking linker --sysroot support... $ECHO_C" >&6 + if test "${gcc_cv_ld_sysroot+set}" = set; then +@@ -24213,6 +24262,49 @@ + + fi + ++# Test for fortify_sources support level 2 in target C library. ++echo "$as_me:$LINENO: checking for FORTIFY_SOURCES level 2 in target C library" >&5 ++echo $ECHO_N "checking for FORTIFY_SOURCES level 2 in target C library... $ECHO_C" >&6 ++if test "${gcc_cv_libc_provides_fortify2+set}" = set; then ++ echo $ECHO_N "(cached) $ECHO_C" >&6 ++else ++ gcc_cv_libc_provides_fortify2=no ++ case "$target" in ++ *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu) ++ if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then ++ if test "x$with_sysroot" = x; then ++ glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-include" ++ elif test "x$with_build_sysroot" != "x"; then ++ glibc_header_dir="${with_build_sysroot}/usr/include" ++ elif test "x$with_sysroot" = xyes; then ++ glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-root/usr/include" ++ else ++ glibc_header_dir="${with_sysroot}/usr/include" ++ fi ++ else ++ glibc_header_dir=/usr/include ++ fi ++ # grep __USE_FORTIFY_LEVEL 2 in $glibc_header_dir/features.h ++ if test -f $glibc_header_dir/features.h \ ++ && grep '__USE_FORTIFY_LEVEL 2' $glibc_header_dir/features.h > /dev/null; then ++ gcc_cv_libc_provides_fortify2=yes ++ else ++ gcc_cv_libc_provides_fortify2=no ++ fi ++ ;; ++ *) gcc_cv_libc_provides_fortify2=no ;; ++ esac ++fi ++echo "$as_me:$LINENO: result: $gcc_cv_libc_provides_fortify2" >&5 ++echo "${ECHO_T}$gcc_cv_libc_provides_fortify2" >&6 ++if test x$gcc_cv_libc_provides_fortify2 = xyes; then ++ ++cat >>confdefs.h <<\_ACEOF ++#define TARGET_LIBC_PROVIDES_FORTIFY2 1 ++_ACEOF ++ ++fi ++ + # Test for stack protector support in target C library. + echo "$as_me:$LINENO: checking __stack_chk_fail in target C library" >&5 + echo $ECHO_N "checking __stack_chk_fail in target C library... $ECHO_C" >&6 +@@ -24375,6 +24467,42 @@ + + fi + ++if test x"$enable_libssp" = xyes; then ++ ++cat >>confdefs.h <<\_ACEOF ++#define ENABLE_LIBSSP 1 ++_ACEOF ++ ++fi ++ ++# Check whether --enable-espf was given and we have -z now and -z relro support. ++# Check whether --enable-espf or --disable-espf was given. ++if test "${enable_espf+set}" = set; then ++ enableval="$enable_espf" ++ ++ case $target in ++ i?86*-*-linux* | x86_64*-*-linux*) ++ if test x$gcc_cv_ld_relro = xyes && test x"$gcc_cv_ld_now" = xyes; then ++ enable_espf=yes ++ else ++ enable_espf=no ++ fi ++ ;; ++ *) ++ enable_espf=no ++ ;; ++ esac ++ ++fi; ++if test x$enable_espf = xyes; then ++ ++cat >>confdefs.h <<\_ACEOF ++#define ENABLE_ESPF 1 ++_ACEOF ++ ++fi ++ ++ + # Check if TFmode long double should be used by default or not. + # Some glibc targets used DFmode long double, but with glibc 2.4 + # and later they can use TFmode. +@@ -25581,6 +25709,7 @@ + s,@gcc_cv_objdump@,$gcc_cv_objdump,;t t + s,@gcc_cv_readelf@,$gcc_cv_readelf,;t t + s,@libgcc_visibility@,$libgcc_visibility,;t t ++s,@enable_espf@,$enable_espf,;t t + s,@GGC@,$GGC,;t t + s,@zlibdir@,$zlibdir,;t t + s,@zlibinc@,$zlibinc,;t t +diff -Nur gcc-4.4.0_vanilla/gcc/espf.h gcc-4.4.0/gcc/espf.h +--- gcc-4.4.0_vanilla/gcc/espf.h 1970-01-01 01:00:00.000000000 +0100 ++++ gcc-4.4.0/gcc/espf.h 2009-07-11 12:36:43.000000000 +0200 +@@ -0,0 +1,104 @@ ++#ifndef GCC_ESPF_H ++#define GCC_ESPF_H ++/* Version 0.2.20090614.1 (C) 2009 by Magnus Granberg */ ++/* Gentoo espf.h patch Version 20090614.1 (C) 2009 by Magnus Granberg */ ++ ++/* FIXME: ++ 1. Fix so that we can have -fPIE or -fpie options. ++*/ ++/* This file add's -fstack-protector-all, -Fpie|-fpie, -pie, -D_FORTIFY_SOURCES=2, -z relro, -z now, -Wformat ++ and -Wformat-security as default if the define's and the spec allow it. ++ ++ On Gentoo ++ Added a hack for gcc-specs-* in toolchain-funcs.eclass to support older hardened GCC patches and ++ we don't need to change the code on gcc-specs-*. ++ This will add some unsupported upstream commands options as -nopie and -z nonow. ++ -D__KERNEL__ is added so we don't have -fPIE|-fpie and -fstack-protector-all when building kernels. ++ ESPF_CC1_SPEC is added to CC1_SPEC. ++ -D_FORTIFY_SOURCES=2 is added with gentoo's patchset as default so no need to set it hear. ++ -Wformat* is added with gentoo's patchset as default so no need to set it hear. ++ -z relro is set by binutils as default so no need to set it hear. ++*/ ++ ++#ifdef ENABLE_ESPF ++ ++ /* Hack to support gcc-specs-* in toolchain-funcs.eclass */ ++ #define ESPF_CC1_SPEC "%{!fno-stack-protector: %{!fno-stack-protector-all: %{!nopie: %{!fstrict-overflow: }}}}" ++ ++ /* This will add -Wformat -Wformat-security -Wstack-protector in espf_cc1_options_warnings and -fstack-protector-all in ++ espf_cc1_options_ssp and incompatible pie commands in espf_cc1_options_pie_incompatible. ++ ESPF_CC1_OPTIONS_SPEC is added to CC1_OPTIONS_SPEC in gcc/gcc.c */ ++ #define ESPF_CC1_OPTIONS_SPEC "%(espf_cc1_options_ssp) %(espf_cc1_options_pie_incompatible)" ++ ++ /* This will add -z now if we don't have -z nonow or -z lazy ++ ESPF_LINK_SPEC is added to LINK_COMMAND_SPEC in gcc/gcc.c */ ++ #define ESPF_LINK_SPEC "%{!now:%{!lazy:%{!nonow:-z now}}}" ++ ++ /* This will add -fstack-protector-all if we don't have -D__KERNEL__ -nostdlib -nodefaultlibs -fno-stack-protector -fstack-protector ++ -fstack-protector-all and we have ENABLE_LIBSSP or TARGET_LIBC_PROVIDES_SSP defined. */ ++ #if defined (ENABLE_LIBSSP) || defined (TARGET_LIBC_PROVIDES_SSP) ++ #define ESPF_CC1_OPTIONS_SSP_SPEC \ ++ "%{!D__KERNEL__:%{!nostdlib:%{!nodefaultlibs: %{!fno-stack-protector: \ ++ %{!fstack-protector:%{!fstack-protector-all:-fstack-protector-all}}}}}}" ++ #else ++ #define ESPF_CC1_OPTIONS_SSP_SPEC "" ++ #endif ++ ++ /* If HAVE_LD_PIE not defined we will not add any -pie -fPIE commands and incompatible pie check */ ++ #ifdef HAVE_LD_PIE ++ ++ /* This will add -fPIE if we don't have -D__KERNEL__ -pie -fpic -fPIC -fpie -fPIE -fno-pic -fno-PIC -fno-pie -fno-PIE ++ -shared -static -nostdlib -nostartfiles -nopie ++ We use ESPF_COMPILER_COMMAND_SPEC to add -fPIE before do_spec (compiler_command_spec) is run in gcc/gcc.c main() */ ++ #define ESPF_COMPILER_COMMAND_SPEC "%(espf_compiler_command_pie)" ++ #define ESPF_COMPILER_COMMAND_PIE_SPEC \ ++ "%{!D__KERNEL__:%{!pie: %{!fpic:%{!fPIC:%{!fpie:%{!fPIE: %{!fno-pic:%{!fno-PIC:%{!fno-pie:%{!fno-PIE: \ ++ %{!shared: %{!static: %{!nostdlib: %{!nostartfiles:%{!nopie:-fPIE}} } }}}} }}}} }}}}" ++ ++ /* This adds some incompatible rules for -pie and -shared ++ We can't have -shared when -static -pie -fPIE -fpie -fno-PIC -fno-pic ++ and -pie when -static -pg -p -profile */ ++ #define ESPF_CC1_OPTIONS_PIE_INCOMPATIBLE_SPEC \ ++ "%{shared:%{static|pie|fPIE|fpie|fno-PIC|fno-pic:%e-shared and -static|pie|fPIE|fpie|fno-PIC|fno-pic are incompatible}} \ ++ %{pie:%{static|pg|p|profile:%e-pie and -static|pg|p|profile are incompatible}}" ++ ++ /* This will add -pie if we don't have -pie A -fno-pic -fno-PIC -fno-pie -fno-PIE -shared -static -r ++ -nostdlib -nostartfiles -nopie ++ We use ESPF_LINK_COMMAND_SPEC to add -pie before do_spec (link_command_spec) is run in gcc/gcc.c main() */ ++ #define ESPF_LINK_COMMAND_SPEC "%(espf_link_command_pie)" ++ #define ESPF_LINK_COMMAND_PIE_SPEC \ ++ "%{!pie:%{!A:%{!fno-pie:%{!fno-PIE:%{!fno-pic:%{!fno-PIC:%{!shared:%{!static:%{!r: \ ++ %{!nostdlib:%{!nostartfiles:%{!nopie:-pie}}}}}}}}}}}}" ++ #else ++ #define ESPF_COMPILER_COMMAND_SPEC "" ++ #define ESPF_CC1_OPTIONS_PIE_INCOMPATIBLE_SPEC "" ++ #define ESPF_LINK_COMMAND_SPEC "" ++ #endif ++ ++ /* We add extra spec name's to the EXTRA_SPECS list */ ++ #define ESPF_EXTRA_SPECS \ ++ { "espf_link", ESPF_LINK_SPEC }, \ ++ { "espf_link_command", ESPF_LINK_COMMAND_SPEC }, \ ++ { "espf_link_command_pie", ESPF_LINK_COMMAND_PIE_SPEC }, \ ++ { "espf_compiler_command", ESPF_COMPILER_COMMAND_SPEC }, \ ++ { "espf_compiler_command_pie", ESPF_COMPILER_COMMAND_PIE_SPEC }, \ ++ { "espf_cc1", ESPF_CC1_SPEC }, \ ++ { "espf_cc1_options", ESPF_CC1_OPTIONS_SPEC }, \ ++ { "espf_cc1_options_ssp", ESPF_CC1_OPTIONS_SSP_SPEC }, \ ++ { "espf_cc1_options_pie_incompatible", ESPF_CC1_OPTIONS_PIE_INCOMPATIBLE_SPEC } ++ ++ static const char *cc1_spec = CC1_SPEC ESPF_CC1_SPEC; ++ static const char *espf_compiler_command_spec = ESPF_COMPILER_COMMAND_SPEC; ++ static const char *espf_link_command_spec = ESPF_LINK_COMMAND_SPEC; ++ ++#else ++ ++ #define ESPF_CC1_OPTIONS_SPEC "" ++ #define ESPF_LINK_SPEC "" ++ #define ESPF_EXTRA_SPECS \ ++ { "espf_cc1_options", ESPF_CC1_OPTIONS_SPEC }, \ ++ { "espf_link", ESPF_LINK_SPEC } ++ ++#endif ++ ++#endif /* End GCC_ESPF_H */ +diff -Nur gcc-4.4.0_vanilla/gcc/gcc.c gcc-4.4.0/gcc/gcc.c +--- gcc-4.4.0_vanilla/gcc/gcc.c 2009-03-17 22:25:59.000000000 +0100 ++++ gcc-4.4.0/gcc/gcc.c 2009-07-11 12:36:43.000000000 +0200 +@@ -83,6 +83,7 @@ + #include "gcc.h" + #include "flags.h" + #include "opts.h" ++#include "espf.h" /* for espf support */ + + /* By default there is no special suffix for target executables. */ + /* FIXME: when autoconf is fixed, remove the host check - dj */ +@@ -726,7 +727,7 @@ + #ifndef LINK_COMMAND_SPEC + #define LINK_COMMAND_SPEC "\ + %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ +- %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ ++ %(linker) %l " LINK_PIE_SPEC " %(espf_link) %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\ + %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\ + %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\ + %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\ +@@ -758,7 +759,9 @@ + + static const char *asm_debug; + static const char *cpp_spec = CPP_SPEC; ++#ifndef ENABLE_ESPF + static const char *cc1_spec = CC1_SPEC; ++#endif + 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; +@@ -826,6 +829,7 @@ + /* NB: This is shared amongst all front-ends, except for Ada. */ + static const char *cc1_options = + "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ ++ %(espf_cc1_options)\ + %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\ + %{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}}\ + %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\ +@@ -1628,7 +1632,7 @@ + const char *const ptr; + }; + +-static const struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS }; ++static const struct spec_list_1 extra_specs_1[] = { ESPF_EXTRA_SPECS, EXTRA_SPECS }; + static struct spec_list *extra_specs = (struct spec_list *) 0; + #endif + +@@ -6782,6 +6786,12 @@ + + if (input_file_compiler) + { ++ ++#ifdef ENABLE_ESPF ++ /* We add -fpie or -fPIE as default if the spec allow it */ ++ do_self_spec (espf_compiler_command_spec); ++#endif ++ + /* Ok, we found an applicable compiler. Run its spec. */ + + if (input_file_compiler->spec[0] == '#') +@@ -6873,6 +6883,10 @@ + " to the linker.\n\n")); + fflush (stdout); + } ++#ifdef ENABLE_ESPF ++ /* We add -pie as default if the spec allow it */ ++ do_self_spec (espf_link_command_spec); ++#endif + value = do_spec (link_command_spec); + if (value < 0) + error_count = 1; +diff -Nur gcc-4.4.0_vanilla/gcc/Makefile.in gcc-4.4.0/gcc/Makefile.in +--- gcc-4.4.0_vanilla/gcc/Makefile.in 2009-03-25 13:00:32.000000000 +0100 ++++ gcc-4.4.0/gcc/Makefile.in 2009-07-11 12:36:10.000000000 +0200 +@@ -580,13 +580,23 @@ + INHIBIT_LIBC_CFLAGS = -Dinhibit_libc + endif + ++# Doesn't compile with PIE or SSP ++enable_espf = @enable_espf@ ++ifeq ($(enable_espf),yes) ++ESPF_NOPIE_CFLAGS = -fno-PIE ++ESPF_NOSSP_CFLAGS = -fno-stack-protector ++else ++ESPF_NOPIE_CFLAGS= ++ESPF_NOSSP_CFLAGS= ++endif ++ + # Options to use when compiling libgcc2.a. + # + LIBGCC2_DEBUG_CFLAGS = -g + LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(TARGET_LIBGCC2_CFLAGS) \ + $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) \ + -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \ +- $(INHIBIT_LIBC_CFLAGS) ++ $(INHIBIT_LIBC_CFLAGS) $(ESPF_NOSSP_CFLAGS) + + # Additional options to use when compiling libgcc2.a. + # Some targets override this to -isystem include +@@ -599,7 +609,7 @@ + CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ + -finhibit-size-directive -fno-inline-functions -fno-exceptions \ + -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \ +- $(INHIBIT_LIBC_CFLAGS) ++ $(INHIBIT_LIBC_CFLAGS) $(ESPF_NOSSP_CFLAGS) + + # Additional sources to handle exceptions; overridden by targets as needed. + LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \ +@@ -1719,7 +1729,7 @@ + echo LIBGCC_SYNC = '$(LIBGCC_SYNC)' >> tmp-libgcc.mvars + echo LIBGCC_SYNC_CFLAGS = '$(LIBGCC_SYNC_CFLAGS)' >> tmp-libgcc.mvars + echo CRTSTUFF_CFLAGS = '$(CRTSTUFF_CFLAGS)' >> tmp-libgcc.mvars +- echo CRTSTUFF_T_CFLAGS = '$(CRTSTUFF_T_CFLAGS)' >> tmp-libgcc.mvars ++ echo CRTSTUFF_T_CFLAGS = '$(CRTSTUFF_T_CFLAGS) $(ESPF_NOPIE_CFLAGS)' >> tmp-libgcc.mvars + echo CRTSTUFF_T_CFLAGS_S = '$(CRTSTUFF_T_CFLAGS_S)' >> tmp-libgcc.mvars + + mv tmp-libgcc.mvars libgcc.mvars +@@ -1754,12 +1764,14 @@ + $(T)crtbegin.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ + gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H) + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ ++ $(ESPF_NOPIE_CFLAGS) \ + -c $(srcdir)/crtstuff.c -DCRT_BEGIN \ + -o $(T)crtbegin$(objext) + + $(T)crtend.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ + gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H) + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ ++ $(ESPF_NOPIE_CFLAGS) \ + -c $(srcdir)/crtstuff.c -DCRT_END \ + -o $(T)crtend$(objext) + +@@ -1780,6 +1792,7 @@ + $(T)crtbeginT.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ + gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H) + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ ++ $(ESPF_NOPIE_CFLAGS) \ + -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O \ + -o $(T)crtbeginT$(objext) + +@@ -3057,7 +3070,7 @@ + output.h $(INSN_ATTR_H) $(SYSTEM_H) $(TOPLEV_H) $(TARGET_H) libfuncs.h \ + $(TARGET_DEF_H) $(FUNCTION_H) $(SCHED_INT_H) $(TM_P_H) $(EXPR_H) \ + langhooks.h $(GGC_H) $(OPTABS_H) $(REAL_H) tm-constrs.h $(GIMPLE_H) +- $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) \ ++ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(ESPF_NOSSP_CFLAGS)\ + $(out_file) $(OUTPUT_OPTION) + + # Build auxiliary files that support ecoff format. +diff -Nur gcc-4.4.0_vanilla/gcc/opts.c gcc-4.4.0/gcc/opts.c +--- gcc-4.4.0_vanilla/gcc/opts.c 2009-03-28 18:28:45.000000000 +0100 ++++ gcc-4.4.0/gcc/opts.c 2009-07-11 12:36:31.000000000 +0200 +@@ -897,7 +897,9 @@ + #endif + flag_regmove = opt2; + flag_strict_aliasing = opt2; ++#ifndef ENABLE_ESPF + flag_strict_overflow = opt2; ++#endif + flag_delete_null_pointer_checks = opt2; + flag_reorder_blocks = opt2; + flag_reorder_functions = opt2; +diff -Nur gcc-4.4.0_vanilla/gcc/varasm.c gcc-4.4.0/gcc/varasm.c +--- gcc-4.4.0_vanilla/gcc/varasm.c 2009-03-17 21:18:21.000000000 +0100 ++++ gcc-4.4.0/gcc/varasm.c 2009-07-11 12:36:25.000000000 +0200 +@@ -5607,7 +5607,11 @@ + bool is_local; + + is_local = targetm.binds_local_p (decl); +- if (!flag_shlib) ++ #ifdef ENABLE_ESPF ++ if (!flag_pic) ++ #else ++ if (!flag_shlib) ++ #endif + { + if (is_local) + kind = TLS_MODEL_LOCAL_EXEC;