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