diff -Naur gcc-4.3-20081204.orig/gcc/Makefile.in gcc-4.3-20081204/gcc/Makefile.in --- gcc-4.3-20081204.orig/gcc/Makefile.in 2008-08-01 09:51:03.000000000 +0000 +++ gcc-4.3-20081204/gcc/Makefile.in 2008-12-16 19:22:27.000000000 +0000 @@ -563,7 +563,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 @@ -576,7 +576,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) -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.3-20081204.orig/gcc/common.opt gcc-4.3-20081204/gcc/common.opt --- gcc-4.3-20081204.orig/gcc/common.opt 2008-01-22 14:11:44.000000000 +0000 +++ gcc-4.3-20081204/gcc/common.opt 2008-12-16 19:20:44.000000000 +0000 @@ -766,7 +766,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.3-20081204.orig/gcc/config/i386/linux.h gcc-4.3-20081204/gcc/config/i386/linux.h --- gcc-4.3-20081204.orig/gcc/config/i386/linux.h 2007-11-28 01:04:27.000000000 +0000 +++ gcc-4.3-20081204/gcc/config/i386/linux.h 2008-12-16 19:21:33.000000000 +0000 @@ -123,7 +123,8 @@ %{mpc32:crtprec32.o%s} \ %{mpc64:crtprec64.o%s} \ %{mpc80:crtprec80.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.3-20081204.orig/gcc/config/i386/linux64.h gcc-4.3-20081204/gcc/config/i386/linux64.h --- gcc-4.3-20081204.orig/gcc/config/i386/linux64.h 2007-08-02 10:49:31.000000000 +0000 +++ gcc-4.3-20081204/gcc/config/i386/linux64.h 2008-12-16 19:22:07.000000000 +0000 @@ -81,7 +81,8 @@ %{mpc32:crtprec32.o%s} \ %{mpc64:crtprec64.o%s} \ %{mpc80:crtprec80.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" #if TARGET_64BIT_DEFAULT #define MULTILIB_DEFAULTS { "m64" } diff -Naur gcc-4.3-20081204.orig/gcc/config/linux.h gcc-4.3-20081204/gcc/config/linux.h --- gcc-4.3-20081204.orig/gcc/config/linux.h 2007-08-02 10:49:31.000000000 +0000 +++ gcc-4.3-20081204/gcc/config/linux.h 2008-12-16 19:20:44.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.3-20081204.orig/gcc/gcc.c gcc-4.3-20081204/gcc/gcc.c --- gcc-4.3-20081204.orig/gcc/gcc.c 2008-03-02 22:55:19.000000000 +0000 +++ gcc-4.3-20081204/gcc/gcc.c 2008-12-16 19:20:44.000000000 +0000 @@ -703,7 +703,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 @@ -818,6 +824,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}\