diff -Naur gcc-4.2-20080227.orig/gcc/Makefile.in gcc-4.2-20080227/gcc/Makefile.in --- gcc-4.2-20080227.orig/gcc/Makefile.in 2008-02-21 20:05:11.000000000 +0000 +++ gcc-4.2-20080227/gcc/Makefile.in 2008-10-21 06:44:08.000000000 +0000 @@ -560,7 +560,7 @@ 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) -fno-PIE # Additional options to use when compiling libgcc2.a. # Some targets override this to -isystem include @@ -573,7 +573,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 \ - $(INHIBIT_LIBC_CFLAGS) + $(INHIBIT_LIBC_CFLAGS) -fno-PIE # Additional sources to handle exceptions; overridden by targets as needed. LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \ diff -Naur gcc-4.2-20080227.orig/gcc/common.opt gcc-4.2-20080227/gcc/common.opt --- gcc-4.2-20080227.orig/gcc/common.opt 2008-01-27 18:36:59.000000000 +0000 +++ gcc-4.2-20080227/gcc/common.opt 2008-10-21 06:44:08.000000000 +0000 @@ -668,7 +668,7 @@ Generate position-independent code if possible (large mode) fPIE -Common Report Var(flag_pie,2) +Common Report Var(flag_pie,2) Init(2) Generate position-independent code for executables if possible (large mode) fpic diff -Naur gcc-4.2-20080227.orig/gcc/config/i386/linux.h gcc-4.2-20080227/gcc/config/i386/linux.h --- gcc-4.2-20080227.orig/gcc/config/i386/linux.h 2007-09-01 15:28:30.000000000 +0000 +++ gcc-4.2-20080227/gcc/config/i386/linux.h 2008-10-21 06:44:08.000000000 +0000 @@ -120,7 +120,8 @@ #undef ENDFILE_SPEC #define ENDFILE_SPEC \ "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ - %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" + %{shared|pie:crtendS.o%s;static|nopie|pg|p|profile:crtend.o%s;:crtendS.o%s} \ + crtn.o%s" /* A C statement (sans semicolon) to output to the stdio stream FILE the assembler definition of uninitialized global DECL named diff -Naur gcc-4.2-20080227.orig/gcc/config/i386/linux64.h gcc-4.2-20080227/gcc/config/i386/linux64.h --- gcc-4.2-20080227.orig/gcc/config/i386/linux64.h 2007-09-01 15:28:30.000000000 +0000 +++ gcc-4.2-20080227/gcc/config/i386/linux64.h 2008-10-21 06:46:31.000000000 +0000 @@ -65,7 +65,8 @@ #undef ENDFILE_SPEC #define ENDFILE_SPEC \ "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ - %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" + %{shared|pie:crtendS.o%s;static|nopie|pg|p|profile:crtend.o%s;:crtendS.o%s} \ + crtn.o%s" #define MULTILIB_DEFAULTS { "m64" } diff -Naur gcc-4.2-20080227.orig/gcc/config/linux.h gcc-4.2-20080227/gcc/config/linux.h --- gcc-4.2-20080227.orig/gcc/config/linux.h 2007-09-01 15:28:30.000000000 +0000 +++ gcc-4.2-20080227/gcc/config/linux.h 2008-10-21 06:44:08.000000000 +0000 @@ -40,8 +40,9 @@ #undef STARTFILE_SPEC #if defined HAVE_LD_PIE #define STARTFILE_SPEC \ - "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \ - crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" + "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;static|nopie:crt1.o%s;: \ + Scrt1.o%s}} crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s; \ + nopie|pg|p|profile:crtbegin.o%s;:crtbeginS.o%s}" #else #define STARTFILE_SPEC \ "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ diff -Naur gcc-4.2-20080227.orig/gcc/gcc.c gcc-4.2-20080227/gcc/gcc.c --- gcc-4.2-20080227.orig/gcc/gcc.c 2007-09-01 15:28:30.000000000 +0000 +++ gcc-4.2-20080227/gcc/gcc.c 2008-10-21 06:44:08.000000000 +0000 @@ -683,7 +683,13 @@ #ifndef LINK_PIE_SPEC #ifdef HAVE_LD_PIE -#define LINK_PIE_SPEC "%{pie:-pie} " +#define LINK_PIE_SPEC "%{pie:-pie}\ + %{shared|Bshareable:--warn-shared-textrel}\ + %{static|Bstatic|shared|Bshareable|i|r|pie|nopie:;:-pie --warn-shared-textrel}\ + %{!static:%{!Bstatic: %{norelro:-z norelro;:-z relro}\ + %{nocombreloc:-z nocombreloc;:-z combreloc}\ + %{nonow:-z lazy;:-z now} }}\ + %{!no-fatal-warnings:--fatal-warnings} " #else #define LINK_PIE_SPEC "%{pie:} " #endif @@ -797,6 +803,9 @@ /* NB: This is shared amongst all front-ends. */ static const char *cc1_options = "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\ + %{fpic|fPIC|fpie|static|D__KERNEL__:-fno-PIE}\ + %{shared|nostdlib|nostartfiles:-fno-PIE -fPIC}\ + %{static:%{pie:%e-static and -pie are incompatible}}\ %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}\