]> git.ipfire.org Git - people/amarx/ipfire-3.x.git/blob - gcc/patches/gcc-4.6.3-piepatches-20120408.patch
gcc: Fix a typo in the SSP patch.
[people/amarx/ipfire-3.x.git] / gcc / patches / gcc-4.6.3-piepatches-20120408.patch
1 git://git.overlays.gentoo.org/proj/hardened-gccpatchset.git
2
3 diff -Nur gcc-4.6.3.vanilla/configure gcc-4.6.3/configure
4 --- gcc-4.6.3.vanilla/configure 2011-12-18 11:03:44.000000000 +0100
5 +++ gcc-4.6.3/configure 2012-04-09 12:23:07.039817993 +0200
6 @@ -668,6 +668,7 @@
7 CFLAGS
8 CC
9 target_subdir
10 +enable_esp
11 host_subdir
12 build_subdir
13 build_libsubdir
14 @@ -1459,6 +1460,11 @@
15 --disable-libquadmath-support
16 disable libquadmath support for Fortran
17 --enable-libada build libada directory
18 + --enable-esp
19 + Enable Stack protector, Position independent executable as
20 + default if we have suppot for it when compiling
21 + and link with -z relro and -z now as default.
22 + Linux targets supported i*86, x86_64, powerpc, powerpc64, ia64 and arm.
23 --enable-libssp build libssp directory
24 --enable-build-with-cxx build with C++ compiler instead of C compiler
25 --disable-ppl-version-check
26 @@ -3039,6 +3045,25 @@
27 noconfigdirs="$noconfigdirs gnattools"
28 fi
29
30 +# Check whether --enable-esp was given and target have the support.
31 +# Check whether --enable-esp or --disable-esp was given.
32 +if test "${enable_esp+set}" = set; then
33 + enableval="$enable_esp"
34 +
35 + case $target in
36 + i?86*-*-linux* | x86_64*-*-linux* | powerpc-*-linux* | powerpc64-*-linux* | arm*-*-linux* | ia64-*-linux*)
37 + enable_esp=yes
38 + ;;
39 + *)
40 + { { echo "$as_me:$LINENO: error: *** --enable-esp is not supported on this $target target." >&5
41 +echo "$as_me: error: *** --enable-esp is not supported on this $target target." >&2;}
42 + { (exit 1); exit 1; }; }
43 + ;;
44 + esac
45 +
46 +fi;
47 +
48 +
49 # Check whether --enable-libssp was given.
50 if test "${enable_libssp+set}" = set; then :
51 enableval=$enable_libssp; ENABLE_LIBSSP=$enableval
52 @@ -14168,6 +14193,9 @@
53 *) stage1_cflags="-g -J" ;;
54 esac ;;
55 esac
56 +if test x$enable_esp = xyes; then
57 + stage1_cflags="$stage1_cflags -fno-stack-protector"
58 +fi
59
60 # This is aimed to mimic bootstrap with a non-GCC compiler to catch problems.
61 if test "$GCC" = yes -a "$ENABLE_BUILD_WITH_CXX" != yes; then
62 diff -Nur gcc-4.6.3.vanilla/gcc/config/gnu-user.h gcc-4.6.3/gcc/config/gnu-user.h
63 --- gcc-4.6.3.vanilla/gcc/config/gnu-user.h 2011-01-12 15:29:14.000000000 +0100
64 +++ gcc-4.6.3/gcc/config/gnu-user.h 2012-04-09 12:25:51.598251886 +0200
65 @@ -41,7 +41,11 @@
66 provides part of the support for getting C++ file-scope static
67 object constructed before entering `main'. */
68
69 -#if defined HAVE_LD_PIE
70 +#if defined (HAVE_LD_PIE) && defined (ENABLE_CRTBEGINP)
71 +#define GNU_USER_TARGET_STARTFILE_SPEC \
72 + "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} crti.o%s \
73 + %{static:%{pie:crtbeginP.o%s;:crtbeginT.o%s}} %{!static:%{shared|pie:crtbeginS.o%s;:crtbegin.o%s}}"
74 +#elif defined (HAVE_LD_PIE) && ! defined (ENABLE_CRTBEGINP)
75 #define GNU_USER_TARGET_STARTFILE_SPEC \
76 "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
77 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
78 diff -Nur gcc-4.6.3.vanilla/gcc/config/rs6000/linux64.h gcc-4.6.3/gcc/config/rs6000/linux64.h
79 --- gcc-4.6.3.vanilla/gcc/config/rs6000/linux64.h 2011-03-07 08:50:23.000000000 +0100
80 +++ gcc-4.6.3/gcc/config/rs6000/linux64.h 2012-04-09 12:25:39.139032665 +0200
81 @@ -193,7 +193,7 @@
82 #endif
83
84 #define ASM_SPEC32 "-a32 \
85 -%{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
86 +%{mrelocatable} %{mrelocatable-lib} %{fpic|fPIC|fpie|fPIE:-K PIC} \
87 %{memb} %{!memb: %{msdata=eabi: -memb}} \
88 %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
89 %{mcall-freebsd: -mbig} \
90 diff -Nur gcc-4.6.3.vanilla/gcc/config/rs6000/sysv4.h gcc-4.6.3/gcc/config/rs6000/sysv4.h
91 --- gcc-4.6.3.vanilla/gcc/config/rs6000/sysv4.h 2011-03-07 08:50:23.000000000 +0100
92 +++ gcc-4.6.3/gcc/config/rs6000/sysv4.h 2012-04-09 12:25:51.599251502 +0200
93 @@ -800,7 +800,12 @@
94 %{!mnewlib: %{pthread:-lpthread} %{shared:-lc} \
95 %{!shared: %{profile:-lc_p} %{!profile:-lc}}}"
96
97 -#ifdef HAVE_LD_PIE
98 +#if defined (HAVE_LD_PIE) && defined (ENABLE_CRTBEGINP)
99 +#define STARTFILE_LINUX_SPEC "\
100 +%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
101 +%{mnewlib:ecrti.o%s;:crti.o%s} \
102 +%{static:%{pie:crtbeginP.o%s;:crtbeginT.o%s}} %{!static:%{shared|pie:crtbeginS.o%s;:crtbegin.o%s}}"
103 +#elif defined (HAVE_LD_PIE) && ! defined (ENABLE_CRTBEGINP)
104 #define STARTFILE_LINUX_SPEC "\
105 %{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
106 %{mnewlib:ecrti.o%s;:crti.o%s} \
107 diff -Nur gcc-4.6.3.vanilla/gcc/config.in gcc-4.6.3/gcc/config.in
108 --- gcc-4.6.3.vanilla/gcc/config.in 2012-03-01 13:03:46.000000000 +0100
109 +++ gcc-4.6.3/gcc/config.in 2012-04-09 12:24:09.220535670 +0200
110 @@ -58,6 +58,12 @@
111 #endif
112
113
114 +/* Define to 1 to enable crtbeginP.o. */
115 +#ifndef USED_FOR_TARGET
116 +#undef ENABLE_CRTBEGINP
117 +#endif
118 +
119 +
120 /* Define to 1 to specify that we are using the BID decimal floating point
121 format instead of DPD */
122 #ifndef USED_FOR_TARGET
123 @@ -77,6 +83,18 @@
124 #endif
125
126
127 +/* Define to 1 to enable esp. */
128 +#ifndef USED_FOR_TARGET
129 +#undef ENABLE_ESP
130 +#endif
131 +
132 +
133 +/* Define to 1 to enable esp ssp. */
134 +#ifndef USED_FOR_TARGET
135 +#undef ENABLE_ESP_SSP
136 +#endif
137 +
138 +
139 /* Define to 1 to enable fixed-point arithmetic extension to C. */
140 #ifndef USED_FOR_TARGET
141 #undef ENABLE_FIXED_POINT
142 diff -Nur gcc-4.6.3.vanilla/gcc/configure gcc-4.6.3/gcc/configure
143 --- gcc-4.6.3.vanilla/gcc/configure 2011-11-20 22:24:07.000000000 +0100
144 +++ gcc-4.6.3/gcc/configure 2012-04-09 12:24:09.229532218 +0200
145 @@ -677,6 +677,8 @@
146 HOST_LIBS
147 GGC
148 libgcc_visibility
149 +enable_esp
150 +enable_crtbeginP
151 gcc_cv_readelf
152 gcc_cv_objdump
153 ORIGINAL_NM_FOR_TARGET
154 @@ -25606,6 +25608,50 @@
155 ;;
156 esac
157
158 +echo "$as_me:$LINENO: checking linker -z now support" >&5
159 +echo $ECHO_N "checking linker -z now support... $ECHO_C" >&6
160 +if test "${gcc_cv_ld_now+set}" = set; then
161 + echo $ECHO_N "(cached) $ECHO_C" >&6
162 +else
163 + gcc_cv_ld_now=no
164 +if test $in_tree_ld = yes ; then
165 + 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 \
166 + && test $in_tree_ld_is_elf = yes; then
167 + gcc_cv_ld_now=yes
168 + fi
169 +elif test x$gcc_cv_ld != x; then
170 + # Check if linker supports -z now options
171 + if $gcc_cv_ld --help 2>/dev/null | grep now > /dev/null; then
172 + gcc_cv_ld_now=yes
173 + fi
174 +fi
175 +
176 +fi
177 +echo "$as_me:$LINENO: result: $gcc_cv_ld_now" >&5
178 +echo "${ECHO_T}$gcc_cv_ld_now" >&6
179 +
180 +echo "$as_me:$LINENO: checking linker -z relro support" >&5
181 +echo $ECHO_N "checking linker -z relro support... $ECHO_C" >&6
182 +if test "${gcc_cv_ld_relro+set}" = set; then
183 + echo $ECHO_N "(cached) $ECHO_C" >&6
184 +else
185 + gcc_cv_ld_relro=no
186 +if test $in_tree_ld = yes ; then
187 + 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 \
188 + && test $in_tree_ld_is_elf = yes; then
189 + gcc_cv_ld_relro=yes
190 + fi
191 +elif test x$gcc_cv_ld != x; then
192 + # Check if linker supports -z relro and -z norelro options
193 + if $gcc_cv_ld --help 2>/dev/null | grep relro > /dev/null; then
194 + gcc_cv_ld_relro=yes
195 + fi
196 +fi
197 +
198 +fi
199 +echo "$as_me:$LINENO: result: $gcc_cv_ld_relro" >&5
200 +echo "${ECHO_T}$gcc_cv_ld_relro" >&6
201 +
202 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --build-id support" >&5
203 $as_echo_n "checking linker --build-id support... " >&6; }
204 if test "${gcc_cv_ld_buildid+set}" = set; then :
205 @@ -25790,6 +25836,113 @@
206
207 fi
208
209 +if test x$enable_esp = xyes ; then
210 +case $target in
211 + ia64*-*-linux*)
212 + if test x$gcc_cv_ld_now = xyes; then
213 + enable_esp_ld=yes
214 + else
215 + enable_esp_ld=no
216 + fi
217 + ;;
218 + *-*-linux*)
219 + if test x$gcc_cv_ld_relro = xyes && test x$gcc_cv_ld_now = xyes; then
220 + enable_esp_ld=yes
221 + else
222 + enable_esp_ld=no
223 + fi
224 + ;;
225 + *)
226 + enable_esp_ld=no
227 + ;;
228 + esac
229 +else
230 + enable_espf_ld=no
231 +fi
232 +if test x$enable_esp_ld = xyes; then
233 +
234 +cat >>confdefs.h <<\_ACEOF
235 +#define ENABLE_ESP 1
236 +_ACEOF
237 +
238 +fi
239 +
240 +if test x$enable_esp = xyes && test x$enable_esp_ld = xno; then
241 + { { echo "$as_me:$LINENO: error: *** --enable-esp is not supported. You don't have -z,relro or -z,now support in the linker." >&5
242 +echo "$as_me: error: *** --enable-esp is not supported. You don't have -z,relro or -z,now support in the linker." >&2;}
243 + { (exit 1); exit 1; }; }
244 +fi
245 +
246 +echo "$as_me:$LINENO: checking for crtbeginP.o support" >&5
247 +echo $ECHO_N "checking for crtbeginP.o support... $ECHO_C" >&6
248 +if test "${enable_crtbeginP+set}" = set; then
249 + echo $ECHO_N "(cached) $ECHO_C" >&6
250 +else
251 +
252 +if test x$enable_esp = xyes ; then
253 + case "$target" in
254 + ia64*-*-linux*)
255 + enable_crtbeginP=no ;;
256 + *-*-linux*)
257 + if test x$gcc_cv_ld_pie = xyes && test x$lt_cv_prog_compiler_static_works = xyes; then
258 + enable_crtbeginP=yes
259 + fi
260 + ;;
261 + *) enable_crtbeginP=no ;;
262 + esac
263 +fi
264 +
265 +fi
266 +echo "$as_me:$LINENO: result: $enable_crtbeginP" >&5
267 +echo "${ECHO_T}$enable_crtbeginP" >&6
268 +
269 +if test x$enable_crtbeginP = xyes; then
270 +
271 +cat >>confdefs.h <<\_ACEOF
272 +#define ENABLE_CRTBEGINP 1
273 +_ACEOF
274 +
275 +fi
276 +
277 +
278 +# Check if we have SSP support. if uClibc we need 0.9.32 or newer and TLS.
279 +echo "$as_me:$LINENO: checking for SSP support" >&5
280 +echo $ECHO_N "checking for SSP support... $ECHO_C" >&6
281 +if test "${enable_esp_SSP+set}" = set; then
282 + echo $ECHO_N "(cached) $ECHO_C" >&6
283 +else
284 + if test x$enable_esp = xyes && test x$gcc_cv_libc_provides_ssp = xyes \
285 + && test x$set_have_as_tls = xyes; then
286 + if $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC__[ ]+1' \
287 + $target_header_dir/features.h > /dev/null; then
288 + if test -f $target_header_dir/bits/uClibc_config.h && \
289 + $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC_SUBLEVEL__[ ]+([3-9][2-9]|[4-9][0-9])' \
290 + $target_header_dir/bits/uClibc_config.h > /dev/null && \
291 + $EGREP '^[ ]*#[ ]*define[ ]+__UCLIBC_HAS_TLS__[ ]+1' \
292 + $target_header_dir/bits/uClibc_config.h > /dev/null; then
293 + enable_esp_SSP=yes
294 + else
295 + enable_esp_SSP=no
296 + fi
297 + else
298 + enable_esp_SSP=yes
299 + fi
300 + else
301 + enable_esp_SSP=no
302 + fi
303 +fi
304 +echo "$as_me:$LINENO: result: $enable_esp_SSP" >&5
305 +echo "${ECHO_T}$enable_esp_SSP" >&6
306 +
307 +if test x$enable_esp_SSP = xyes; then
308 +
309 +cat >>confdefs.h <<\_ACEOF
310 +#define ENABLE_ESP_SSP 1
311 +_ACEOF
312 +
313 +fi
314 +
315 +
316 # Check if TFmode long double should be used by default or not.
317 # Some glibc targets used DFmode long double, but with glibc 2.4
318 # and later they can use TFmode.
319 diff -Nur gcc-4.6.3.vanilla/gcc/cp/lang-specs.h gcc-4.6.3/gcc/cp/lang-specs.h
320 --- gcc-4.6.3.vanilla/gcc/cp/lang-specs.h 2011-03-06 17:27:57.000000000 +0100
321 +++ gcc-4.6.3/gcc/cp/lang-specs.h 2012-04-09 12:25:11.222744541 +0200
322 @@ -47,7 +47,7 @@
323 %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}\
324 cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}\
325 %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
326 - %(cc1_options) %2\
327 + %(cc1_options) %(esp_options) %2\
328 %{!fsyntax-only:%{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\
329 %W{o*:--output-pch=%*}}%V}}}}",
330 CPLUSPLUS_CPP_SPEC, 0, 0},
331 @@ -58,7 +58,7 @@
332 %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}\
333 cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}\
334 %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
335 - %(cc1_options) %2\
336 + %(cc1_options) %(esp_options) %2\
337 %{!fsyntax-only:%(invoke_as)}}}}",
338 CPLUSPLUS_CPP_SPEC, 0, 0},
339 {".ii", "@c++-cpp-output", 0, 0, 0},
340 diff -Nur gcc-4.6.3.vanilla/gcc/doc/invoke.texi gcc-4.6.3/gcc/doc/invoke.texi
341 --- gcc-4.6.3.vanilla/gcc/doc/invoke.texi 2012-01-03 17:43:38.000000000 +0100
342 +++ gcc-4.6.3/gcc/doc/invoke.texi 2012-04-09 12:26:06.709453504 +0200
343 @@ -8185,6 +8185,11 @@
344 @opindex fstack-protector-all
345 Like @option{-fstack-protector} except that all functions are protected.
346
347 +NOTE: When --enable-esp this option is enabled by default
348 +for C, C++, ObjC, ObjC++, if neither @option{-fno-stack-protector}
349 +or @option{-nostdlib} or @option{-nodefaultlibs} or
350 +@option{-fstack-protector} are found.
351 +
352 @item -fsection-anchors
353 @opindex fsection-anchors
354 Try to reduce the number of symbolic address calculations by using
355 @@ -9090,6 +9095,12 @@
356 that were used to generate code (@option{-fpie}, @option{-fPIE},
357 or model suboptions) when you specify this option.
358
359 +NOTE: When --enable-esp this option is enabled by default
360 +for C, C++, ObjC, ObjC++, if neither @option{-fno-pie} or @option{-fno-PIE}
361 +or @option{-fno-pic} or @option{-fno-PIC} or @option{-nostdlib} or
362 +@option{-nostartfiles} or @option{-shared} or @option{-pg} or @option{-p}
363 +are found.
364 +
365 @item -rdynamic
366 @opindex rdynamic
367 Pass the flag @option{-export-dynamic} to the ELF linker, on targets
368 @@ -18099,6 +18110,11 @@
369 @code{__pie__} and @code{__PIE__}. The macros have the value 1
370 for @option{-fpie} and 2 for @option{-fPIE}.
371
372 +NOTE: When --enable-esp this option is enabled by default
373 +for C, C++, ObjC, ObjC++, if neither @option{-fno-pie} or @option{-fno-PIE}
374 +or @option{-fno-pic} or @option{-fno-PIC} or @option{-nostdlib} or
375 +@option{-nostartfiles} or @option{-shared} are found.
376 +
377 @item -fno-jump-tables
378 @opindex fno-jump-tables
379 Do not use jump tables for switch statements even where it would be
380 diff -Nur gcc-4.6.3.vanilla/gcc/esp.h gcc-4.6.3/gcc/esp.h
381 --- gcc-4.6.3.vanilla/gcc/esp.h 1970-01-01 01:00:00.000000000 +0100
382 +++ gcc-4.6.3/gcc/esp.h 2012-04-09 12:25:25.376313618 +0200
383 @@ -0,0 +1,145 @@
384 +/* License terms see GNU GENERAL PUBLIC LICENSE Version 3.
385 + * Version 20120403.2
386 + * Magnus Granberg (Zorry) <zorry@gentoo.org> */
387 +#ifndef GCC_ESP_H
388 +#define GCC_ESP_H
389 +
390 +/* This file will add -fstack-protector-all, -fPIE, -pie and -z now
391 + as default if the defines and the spec allow it.
392 + Added a hack for gcc-specs-* in toolchain-funcs.eclass and _filter-hardened in flag-o-matic.eclass
393 + to support older hardened GCC patches and we don't need to change the code on gcc-specs-* and _filter-hardened.
394 + This will add some unsupported upstream commands options as -nopie and -nonow.
395 + -D__KERNEL__ is added so we don't have -fPIE, -pie and -fstack-protector-all when building kernels.
396 + ESP_CC1_SPEC is added to CC1_SPEC.
397 + ESP_CC1_STRICT_OVERFLOW_SPEC is added so we don't disable the strict-overflow check.
398 + ESP_LINK_PIE_CHECK_SPEC check for -pie, -p, -pg, -profile and -static.
399 + ENABLE_CRTBEGINP add support for crtbeginP.o, build -static with -fPIE or -fpie.
400 +*/
401 +#ifdef ENABLE_ESP
402 +
403 + /* Hack to support gcc-specs-* in toolchain-funcs.eclass and _filter-hardened in flag-o-matic.eclass */
404 + #define ESP_CC1_SPEC " %(esp_cc1_ssp) %(esp_cc1_pie) %(esp_cc1_strict_overflow)"
405 + #if defined ( EFAULT_SSP ) || defined ( EFAULT_PIE_SSP )
406 + #define ESP_CC1_SSP_SPEC "%{!fno-stack-protector: %{!fno-stack-protector-all: }}"
407 + #else
408 + #define ESP_CC1_SSP_SPEC ""
409 + #endif
410 + #if defined ( EFAULT_PIE ) || defined ( EFAULT_PIE_SSP )
411 + #define ESP_CC1_PIE_SPEC "%{!nopie: }"
412 + #else
413 + #define ESP_CC1_PIE_SPEC ""
414 + #endif
415 + #define ESP_CC1_STRICT_OVERFLOW_SPEC "%{!fstrict-overflow:%{!fno-strict-overflow: -fno-strict-overflow}}"
416 +
417 + /* ESP_LINK_SPEC is added to LINK_PIE_SPEC if esp is enable
418 + -z now will be added if we don't have -vanilla spec. We do a -pie incompatible check
419 + Don't remove the specs in the end */
420 + #define ESP_LINK_SPEC "%(esp_link_now) %(esp_link_pie_check) "
421 + #define ESP_LINK_NOW_SPEC "%{!nonow:-z now}"
422 +
423 + /* We use ESP_COMMAND_OPTIONS_SPEC to add pie command-line options. */
424 + #define ESP_COMMAND_OPTIONS_SPEC "%{!D__KERNEL__:%{!nopie:%(esp_options_pie) %(esp_link_pie)}}"
425 +
426 + /* ESP_OPTIONS_SPEC is added to the compiler spec in gcc/gcc.c */
427 + #define ESP_OPTIONS_SPEC "%(esp_options_ssp)"
428 +
429 + /* ESP_CPP_OPTIONS_SPEC is added to the cpp_options spec in gcc/gcc.c
430 + For precompiling headers. */
431 + #define ESP_CPP_OPTIONS_SPEC "%(esp_options_ssp)"
432 +
433 + /* This will add -fstack-protector-all if we don't have -nostdlib -nodefaultlibs -fno-stack-protector -fstack-protector
434 + -fstack-protector-all and we have EFAULT_SSP or EFAULT_PIE_SSP defined. */
435 + #if ( defined ( EFAULT_SSP ) || defined ( EFAULT_PIE_SSP ) ) && defined ( ENABLE_ESP_SSP )
436 + #define ESP_OPTIONS_SSP_SPEC \
437 + "%{!D__KERNEL__:%{!nostdlib:%{!nodefaultlibs: %{!fno-stack-protector: \
438 + %{!fstack-protector:%{!fstack-protector-all:-fstack-protector-all}}}}}}"
439 + #else
440 + #define ESP_OPTIONS_SSP_SPEC ""
441 + #endif
442 +
443 + /* If EFAULT_PIE or EFAULT_PIE_SSP is defined we will add -fPIE -pie */
444 + #if defined ( EFAULT_PIE ) || defined ( EFAULT_PIE_SSP )
445 +
446 + /* This will add -fPIE if we don't have -pie -fpic -fPIC -fpie -fPIE -fno-pic -fno-PIC -fno-pie -fno-PIE -shared -static
447 + -nostdlib -nostartfiles. */
448 + /* With ENABLE_CRTBEGINP we don't need to check for -static */
449 + #ifdef ENABLE_CRTBEGINP
450 + #define ESP_OPTIONS_PIE_SPEC \
451 + "%{!pie: %{!fpic:%{!fPIC:%{!fpie:%{!fPIE: %{!fno-pic:%{!fno-PIC:%{!fno-pie:%{!fno-PIE: \
452 + %{!shared: %{!nostdlib: %{!nostartfiles:-fPIE}} } }}}} }}}} }"
453 + #else
454 + #define ESP_OPTIONS_PIE_SPEC \
455 + "%{!pie: %{!fpic:%{!fPIC:%{!fpie:%{!fPIE: %{!fno-pic:%{!fno-PIC:%{!fno-pie:%{!fno-PIE: \
456 + %{!shared: %{!static: %{!nostdlib: %{!nostartfiles:-fPIE}} } }}}} }}}} }}"
457 + #endif
458 +
459 + /* This will add -pie if we don't have -pie -A -fno-pic -fno-PIC -fno-pie -fno-PIE -shared -static -r -nostdlib
460 + -nostartfiles */
461 + /* With ENABLE_CRTBEGINP we don't need to check for -static
462 + and we add -pie only to get the start and endfiles. -pie will not go to the linker. */
463 + #ifdef ENABLE_CRTBEGINP
464 + #define ESP_LINK_PIE_SPEC \
465 + "%{!pie:%{!A:%{!fno-pie:%{!fno-PIE:%{!fno-pic:%{!fno-PIC:%{!shared:%{!r: \
466 + %{!nostdlib:%{!nostartfiles:-pie}}}}}}}}}}"
467 + #else
468 + #define ESP_LINK_PIE_SPEC \
469 + "%{!pie:%{!A:%{!fno-pie:%{!fno-PIE:%{!fno-pic:%{!fno-PIC:%{!shared:%{!static:%{!r: \
470 + %{!nostdlib:%{!nostartfiles:-pie}}}}}}}}}}}"
471 + #endif
472 +
473 + /* This will check if -pie is set when (-static) -pg -p -profile. If set it will make gcc print out
474 + "-pie and (static)|pg|p|profile are incompatible when linking" */
475 + /* With ENABLE_CRTBEGINP we don't need to check for -static */
476 + #ifdef ENABLE_CRTBEGINP
477 + #define ESP_LINK_PIE_CHECK_SPEC \
478 + "%{pie:%{pg|p|profile:%e-pie and -pg|p|profile are incompatible when linking}}"
479 + #else
480 + #define ESP_LINK_PIE_CHECK_SPEC \
481 + "%{pie:%{static|pg|p|profile:%e-pie and -static|pg|p|profile are incompatible when linking}}"
482 + #endif
483 +
484 + /* We don't pass -pie to the linker when -static. */
485 + #ifdef ENABLE_CRTBEGINP
486 + #define LINK_PIE_SPEC "%{!static:%{pie:-pie}} %(esp_link)"
487 + #else
488 + #define LINK_PIE_SPEC "%{pie:-pie} %(esp_link)"
489 + #endif
490 +
491 + #else
492 + #define ESP_OPTIONS_PIE_SPEC ""
493 + #define ESP_LINK_PIE_CHECK_SPEC ""
494 + #define ESP_LINK_PIE_SPEC ""
495 + #define LINK_PIE_SPEC "%{pie:-pie} %(esp_link)"
496 + #endif
497 +
498 + /* We add extra spec name's to the EXTRA_SPECS list */
499 + #define ESP_EXTRA_SPECS \
500 + { "esp_cc1", ESP_CC1_SPEC }, \
501 + { "esp_cc1_pie", ESP_CC1_PIE_SPEC }, \
502 + { "esp_cc1_ssp", ESP_CC1_SSP_SPEC }, \
503 + { "esp_cc1_strict_overflow", ESP_CC1_STRICT_OVERFLOW_SPEC }, \
504 + { "esp_link", ESP_LINK_SPEC }, \
505 + { "esp_link_now", ESP_LINK_NOW_SPEC }, \
506 + { "esp_link_pie", ESP_LINK_PIE_SPEC }, \
507 + { "esp_link_pie_check", ESP_LINK_PIE_CHECK_SPEC }, \
508 + { "esp_command_options", ESP_COMMAND_OPTIONS_SPEC }, \
509 + { "esp_cpp_options", ESP_CPP_OPTIONS_SPEC }, \
510 + { "esp_options", ESP_OPTIONS_SPEC }, \
511 + { "esp_options_pie", ESP_OPTIONS_PIE_SPEC }, \
512 + { "esp_options_ssp", ESP_OPTIONS_SSP_SPEC }
513 +
514 + static const char *esp_command_options_spec = ESP_COMMAND_OPTIONS_SPEC;
515 + static const char *cc1_spec = CC1_SPEC ESP_CC1_SPEC;
516 +
517 +#else /* If not ESP_ENABLE defined do this. */
518 +
519 + #define ESP_OPTIONS_SPEC ""
520 + #define ESP_CPP_OPTIONS_SPEC ""
521 +
522 + /* We add extra spec name's to the EXTRA_SPECS list */
523 + #define ESP_EXTRA_SPECS \
524 + { "esp_options", ESP_OPTIONS_SPEC }, \
525 + { "esp_cpp_options", ESP_CPP_OPTIONS_SPEC }
526 +
527 +#endif
528 +#endif /* End GCC_ESP_H */
529 diff -Nur gcc-4.6.3.vanilla/gcc/gcc.c gcc-4.6.3/gcc/gcc.c
530 --- gcc-4.6.3.vanilla/gcc/gcc.c 2011-02-23 03:04:43.000000000 +0100
531 +++ gcc-4.6.3/gcc/gcc.c 2012-04-09 12:25:11.222744541 +0200
532 @@ -44,6 +44,7 @@
533 #include "flags.h"
534 #include "opts.h"
535 #include "vec.h"
536 +#include "esp.h" /* for --enable-esp support */
537
538 /* By default there is no special suffix for target executables. */
539 /* FIXME: when autoconf is fixed, remove the host check - dj */
540 @@ -690,7 +691,9 @@
541
542 static const char *asm_debug;
543 static const char *cpp_spec = CPP_SPEC;
544 +#ifndef ENABLE_ESP
545 static const char *cc1_spec = CC1_SPEC;
546 +#endif
547 static const char *cc1plus_spec = CC1PLUS_SPEC;
548 static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC;
549 static const char *link_ssp_spec = LINK_SSP_SPEC;
550 @@ -751,7 +754,7 @@
551 static const char *cpp_options =
552 "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
553 %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*}\
554 - %{undef} %{save-temps*:-fpch-preprocess}";
555 + %{undef} %{save-temps*:-fpch-preprocess} %(esp_cpp_options)";
556
557 /* This contains cpp options which are not passed when the preprocessor
558 output will be used by another program. */
559 @@ -925,9 +928,9 @@
560 %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
561 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
562 cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
563 - %(cc1_options)}\
564 + %(cc1_options) %(esp_options)}\
565 %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
566 - cc1 %(cpp_unique_options) %(cc1_options)}}}\
567 + cc1 %(cpp_unique_options) %(cc1_options) %(esp_options)}}}\
568 %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 1},
569 {"-",
570 "%{!E:%e-E or -x required when input is from standard input}\
571 @@ -950,7 +953,7 @@
572 %W{o*:--output-pch=%*}}%V}}}}}}", 0, 0, 0},
573 {".i", "@cpp-output", 0, 0, 0},
574 {"@cpp-output",
575 - "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
576 + "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %(esp_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
577 {".s", "@assembler", 0, 0, 0},
578 {"@assembler",
579 "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0},
580 @@ -1203,18 +1206,23 @@
581 INIT_STATIC_SPEC ("sysroot_hdrs_suffix_spec", &sysroot_hdrs_suffix_spec),
582 };
583
584 -#ifdef EXTRA_SPECS /* additional specs needed */
585 +/* EXTRA_SPECS needs to be defined */
586 +#ifndef EXTRA_SPECS
587 +#define EXTRA_SPECS
588 +#endif
589 +
590 +/* EXTRA_SPECS and ESP_EXTRA_SPECS add additional specs */
591 /* Structure to keep track of just the first two args of a spec_list.
592 - That is all that the EXTRA_SPECS macro gives us. */
593 + That is all that the EXTRA_SPECS and ESP_EXTRA_SPECS macro gives us. */
594 struct spec_list_1
595 {
596 const char *const name;
597 const char *const ptr;
598 };
599
600 -static const struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS };
601 +/* ESP_EXTRA_SPECS before EXTRA_SPECS */
602 +static const struct spec_list_1 extra_specs_1[] = { ESP_EXTRA_SPECS, EXTRA_SPECS };
603 static struct spec_list *extra_specs = (struct spec_list *) 0;
604 -#endif
605
606 /* List of dynamically allocates specs that have been defined so far. */
607
608 @@ -1306,7 +1314,6 @@
609 if (verbose_flag)
610 fnotice (stderr, "Using built-in specs.\n");
611
612 -#ifdef EXTRA_SPECS
613 extra_specs = XCNEWVEC (struct spec_list, ARRAY_SIZE (extra_specs_1));
614
615 for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--)
616 @@ -1319,7 +1326,6 @@
617 sl->ptr_spec = &sl->ptr;
618 next = sl;
619 }
620 -#endif
621
622 for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)
623 {
624 @@ -6418,6 +6424,12 @@
625 gcc_exec_prefix = concat (gcc_exec_prefix, spec_machine, dir_separator_str,
626 spec_version, dir_separator_str, NULL);
627
628 +#ifdef ENABLE_ESP
629 + /* Process ESP_COMMAND_OPTIONS_SPEC, adding any new options to the end
630 + of the command line. */
631 + do_self_spec (esp_command_options_spec);
632 +#endif
633 +
634 /* Now we have the specs.
635 Set the `valid' bits for switches that match anything in any spec. */
636
637 diff -Nur gcc-4.6.3.vanilla/gcc/Makefile.in gcc-4.6.3/gcc/Makefile.in
638 --- gcc-4.6.3.vanilla/gcc/Makefile.in 2011-08-20 09:51:09.000000000 +0200
639 +++ gcc-4.6.3/gcc/Makefile.in 2012-04-09 12:23:38.285405919 +0200
640 @@ -642,6 +642,14 @@
641 INHIBIT_LIBC_CFLAGS = -Dinhibit_libc
642 endif
643
644 +# We don't want to compile the compiler with -fPIE.
645 +enable_esp = @enable_esp@
646 +ifeq ($(enable_esp),yes)
647 +ESP_NOPIE_CFLAGS = -fno-PIE
648 +else
649 +ESP_NOPIE_CFLAGS=
650 +endif
651 +
652 # Options to use when compiling libgcc2.a.
653 #
654 LIBGCC2_DEBUG_CFLAGS = -g
655 @@ -662,7 +670,7 @@
656 CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
657 -finhibit-size-directive -fno-inline -fno-exceptions \
658 -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
659 - -fno-stack-protector \
660 + -fno-stack-protector $(ESP_NOPIE_CFLAGS) \
661 $(INHIBIT_LIBC_CFLAGS)
662
663 # Additional sources to handle exceptions; overridden by targets as needed.
664 @@ -693,6 +701,12 @@
665 # The rules for compiling them should be in the t-* file for the machine.
666 EXTRA_PARTS = @extra_parts@
667
668 +# We add crtbeginP.o to the EXTRA_PARTS list if enable_crtbeginP = yes
669 +enable_crtbeginP = @enable_crtbeginP@
670 +ifeq ($(enable_crtbeginP),yes)
671 +EXTRA_PARTS += crtbeginP.o
672 +endif
673 +
674 # List of extra object files that should be compiled and linked with
675 # compiler proper (cc1, cc1obj, cc1plus).
676 EXTRA_OBJS = @extra_objs@
677 @@ -996,12 +1010,12 @@
678
679 # This is the variable actually used when we compile. If you change this,
680 # you probably want to update BUILD_CFLAGS in configure.ac
681 -ALL_CFLAGS = $(T_CFLAGS) $(CFLAGS-$@) \
682 +ALL_CFLAGS = $(ESP_NOPIE_CFLAGS) $(T_CFLAGS) $(CFLAGS-$@) \
683 $(CFLAGS) $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(WARN_CFLAGS) @DEFS@
684
685 # The C++ version.
686 -ALL_CXXFLAGS = $(T_CFLAGS) $(CXXFLAGS) $(INTERNAL_CFLAGS) \
687 - $(COVERAGE_FLAGS) $(WARN_CXXFLAGS) @DEFS@
688 +ALL_CXXFLAGS = $(ESP_NOPIE_CFLAGS) $(T_CFLAGS) $(CXXFLAGS) \
689 + $(INTERNAL_CFLAGS) $(COVERAGE_FLAGS) $(WARN_CXXFLAGS) @DEFS@
690
691 # Likewise. Put INCLUDES at the beginning: this way, if some autoconf macro
692 # puts -I options in CPPFLAGS, our include files in the srcdir will always
693 @@ -1920,9 +1934,10 @@
694 echo LIBGCC_SYNC = '$(LIBGCC_SYNC)' >> tmp-libgcc.mvars
695 echo LIBGCC_SYNC_CFLAGS = '$(LIBGCC_SYNC_CFLAGS)' >> tmp-libgcc.mvars
696 echo CRTSTUFF_CFLAGS = '$(CRTSTUFF_CFLAGS)' >> tmp-libgcc.mvars
697 - echo CRTSTUFF_T_CFLAGS = '$(CRTSTUFF_T_CFLAGS)' >> tmp-libgcc.mvars
698 + echo CRTSTUFF_T_CFLAGS = '$(CRTSTUFF_T_CFLAGS) $(ESP_NOPIE_CFLAGS)' >> tmp-libgcc.mvars
699 echo CRTSTUFF_T_CFLAGS_S = '$(CRTSTUFF_T_CFLAGS_S)' >> tmp-libgcc.mvars
700 echo TARGET_SYSTEM_ROOT = '$(TARGET_SYSTEM_ROOT)' >> tmp-libgcc.mvars
701 + echo enable_crtbeginP = '$(enable_crtbeginP)' >> tmp-libgcc.mvars
702
703 mv tmp-libgcc.mvars libgcc.mvars
704
705 @@ -1982,9 +1997,19 @@
706 $(T)crtbeginT.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \
707 gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H)
708 $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \
709 + $(ESP_NOPIE_CFLAGS) \
710 -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O \
711 -o $(T)crtbeginT$(objext)
712
713 +# This is a version of crtbegin for -static -fPIE links if esp is enable.
714 +ifeq ($(enable_crtbeginP),yes)
715 +$(T)crtbeginP.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \
716 + gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H)
717 + $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS_S) \
718 + -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O -DCRTSTUFFS_O \
719 + -o $(T)crtbeginP$(objext)
720 +endif
721 +
722 # Compile the start modules crt0.o and mcrt0.o that are linked with
723 # every program
724 $(T)crt0.o: s-crt0 ; @true
725 diff -Nur gcc-4.6.3.vanilla/gcc/objc/lang-specs.h gcc-4.6.3/gcc/objc/lang-specs.h
726 --- gcc-4.6.3.vanilla/gcc/objc/lang-specs.h 2011-03-06 17:27:57.000000000 +0100
727 +++ gcc-4.6.3/gcc/objc/lang-specs.h 2012-04-09 12:25:11.224743774 +0200
728 @@ -30,9 +30,9 @@
729 %{traditional|traditional-cpp:\
730 %eGNU Objective C no longer supports traditional compilation}\
731 %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\
732 - cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}\
733 + cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %(esp_options) %{print-objc-runtime-info} %{gen-decls}}\
734 %{!save-temps*:%{!no-integrated-cpp:\
735 - cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}}\
736 + cc1obj %(cpp_unique_options) %(cc1_options) %(esp_options) %{print-objc-runtime-info} %{gen-decls}}}\
737 %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
738 {"@objective-c-header",
739 "%{E|M|MM:cc1obj -E %{traditional|traditional-cpp:-traditional-cpp}\
740 @@ -41,18 +41,18 @@
741 %{traditional|traditional-cpp:\
742 %eGNU Objective C no longer supports traditional compilation}\
743 %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\
744 - cc1obj -fpreprocessed %b.mi %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
745 + cc1obj -fpreprocessed %b.mi %(cc1_options)%(esp_options) %{print-objc-runtime-info} %{gen-decls}\
746 -o %g.s %{!o*:--output-pch=%i.gch}\
747 %W{o*:--output-pch=%*}%V}\
748 %{!save-temps*:%{!no-integrated-cpp:\
749 - cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
750 + cc1obj %(cpp_unique_options) %(cc1_options) %(esp_options) %{print-objc-runtime-info} %{gen-decls}\
751 -o %g.s %{!o*:--output-pch=%i.gch}\
752 %W{o*:--output-pch=%*}%V}}}}}", 0, 0, 0},
753 {".mi", "@objective-c-cpp-output", 0, 0, 0},
754 {"@objective-c-cpp-output",
755 - "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
756 + "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(esp_options) %{print-objc-runtime-info} %{gen-decls}\
757 %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
758 {"@objc-cpp-output",
759 "%nobjc-cpp-output is deprecated; please use objective-c-cpp-output instead\n\
760 - %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
761 + %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(esp_options) %{print-objc-runtime-info} %{gen-decls}\
762 %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
763 diff -Nur gcc-4.6.3.vanilla/gcc/objcp/lang-specs.h gcc-4.6.3/gcc/objcp/lang-specs.h
764 --- gcc-4.6.3.vanilla/gcc/objcp/lang-specs.h 2011-03-06 17:27:57.000000000 +0100
765 +++ gcc-4.6.3/gcc/objcp/lang-specs.h 2012-04-09 12:25:11.223744157 +0200
766 @@ -36,7 +36,7 @@
767 %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\
768 cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\
769 %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
770 - %(cc1_options) %2\
771 + %(cc1_options) %(esp_options) %2\
772 -o %g.s %{!o*:--output-pch=%i.gch} %W{o*:--output-pch=%*}%V}}}",
773 CPLUSPLUS_CPP_SPEC, 0, 0},
774 {"@objective-c++",
775 @@ -46,16 +46,16 @@
776 %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\
777 cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\
778 %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
779 - %(cc1_options) %2\
780 + %(cc1_options) %(esp_options) %2\
781 %{!fsyntax-only:%(invoke_as)}}}}",
782 CPLUSPLUS_CPP_SPEC, 0, 0},
783 {".mii", "@objective-c++-cpp-output", 0, 0, 0},
784 {"@objective-c++-cpp-output",
785 "%{!M:%{!MM:%{!E:\
786 - cc1objplus -fpreprocessed %i %(cc1_options) %2\
787 + cc1objplus -fpreprocessed %i %(cc1_options) %(esp_options) %2\
788 %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
789 {"@objc++-cpp-output",
790 "%nobjc++-cpp-output is deprecated; please use objective-c++-cpp-output instead\n\
791 %{!M:%{!MM:%{!E:\
792 - cc1objplus -fpreprocessed %i %(cc1_options) %2\
793 + cc1objplus -fpreprocessed %i %(cc1_options) %(esp_options) %2\
794 %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
795 diff -Nur gcc-4.6.3.vanilla/gcc/varasm.c gcc-4.6.3/gcc/varasm.c
796 --- gcc-4.6.3.vanilla/gcc/varasm.c 2011-12-09 20:11:01.000000000 +0100
797 +++ gcc-4.6.3/gcc/varasm.c 2012-04-09 12:24:55.766675254 +0200
798 @@ -6028,7 +6028,11 @@
799 bool is_local;
800
801 is_local = targetm.binds_local_p (decl);
802 - if (!flag_shlib)
803 + #ifdef ENABLE_ESP
804 + if (!flag_pic)
805 + #else
806 + if (!flag_shlib)
807 + #endif
808 {
809 if (is_local)
810 kind = TLS_MODEL_LOCAL_EXEC;
811 diff -Nur gcc-4.6.3.vanilla/libgcc/Makefile.in gcc-4.6.3/libgcc/Makefile.in
812 --- gcc-4.6.3.vanilla/libgcc/Makefile.in 2011-01-26 05:19:58.000000000 +0100
813 +++ gcc-4.6.3/libgcc/Makefile.in 2012-04-09 12:23:38.286405535 +0200
814 @@ -298,6 +298,12 @@
815 gen-hide-list = echo > \$@
816 endif
817
818 +# We add crtbeginP.o to the EXTRA_PARTS list if enable_crtbeginP = yes
819 +enable_libgcc_crtbeginP = $(enable_crtbeginP)
820 +ifeq ($(enable_libgcc_crtbeginP),yes)
821 +EXTRA_PARTS += crtbeginP.o
822 +endif
823 +
824 ifneq ($(EXTRA_PARTS),)
825 extra-parts = libgcc-extra-parts
826 INSTALL_PARTS = $(EXTRA_PARTS)
827 @@ -849,6 +855,13 @@
828 crtbeginT.o: $(gcc_srcdir)/crtstuff.c
829 $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
830 -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O
831 +
832 +# This is a version of crtbegin for -static -fPIE links.
833 +ifeq ($(enable_libgcc_crtbeginP),yes)
834 +crtbeginP.o: $(gcc_srcdir)/crtstuff.c
835 + $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
836 + -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O -DCRTSTUFFS_O
837 +endif
838 endif
839
840 # Build extra startfiles in the libgcc directory.
841 diff -Nur gcc-4.6.3.vanilla/libmudflap/configure gcc-4.6.3/libmudflap/configure
842 --- gcc-4.6.3.vanilla/libmudflap/configure 2011-11-20 22:24:07.000000000 +0100
843 +++ gcc-4.6.3/libmudflap/configure 2012-04-09 12:23:07.050818345 +0200
844 @@ -652,6 +652,7 @@
845 MAINTAINER_MODE_FALSE
846 MAINTAINER_MODE_TRUE
847 am__untar
848 +enable_esp
849 am__tar
850 AMTAR
851 am__leading_dot
852 diff -Nur gcc-4.6.3.vanilla/Makefile.in gcc-4.6.3/Makefile.in
853 --- gcc-4.6.3.vanilla/Makefile.in 2012-01-02 12:02:10.000000000 +0100
854 +++ gcc-4.6.3/Makefile.in 2012-04-09 12:23:38.283406686 +0200
855 @@ -356,9 +356,17 @@
856 BUILD_PREFIX = @BUILD_PREFIX@
857 BUILD_PREFIX_1 = @BUILD_PREFIX_1@
858
859 +# Some stuff don't compile with SSP
860 +enable_esp = @enable_esp@
861 +ifeq ($(enable_esp),yes)
862 +ESP_NOSSP_CFLAGS = -fno-stack-protector
863 +else
864 +ESP_NOSSP_CFLAGS=
865 +endif
866 +
867 # Flags to pass to stage2 and later makes. They are defined
868 # here so that they can be overridden by Makefile fragments.
869 -BOOT_CFLAGS= -g -O2
870 +BOOT_CFLAGS= -g -O2 $(ESP_NOSSP_CFLAGS)
871 BOOT_LDFLAGS=
872 BOOT_ADAFLAGS=-gnatpg -gnata
873
874 @@ -403,9 +411,9 @@
875
876 CFLAGS = @CFLAGS@
877 LDFLAGS = @LDFLAGS@
878 -LIBCFLAGS = $(CFLAGS)
879 +LIBCFLAGS = $(CFLAGS) $(ESP_NOSSP_CFLAGS)
880 CXXFLAGS = @CXXFLAGS@
881 -LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
882 +LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates $(ESP_NOSSP_CFLAGS)
883 GOCFLAGS = $(CFLAGS)
884
885 TFLAGS =