aboutsummaryrefslogtreecommitdiff
blob: 0a7c850318c41ade93f59e509dfce64572018641 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
2009-07-18	Magnus Granberg		<zorry@ume.nu>

		* gcc/gcc.c		include:				espf.h
		#ifdef EXTRA_SPECS:						Add ESPF_EXTRA_SPECS
		main():									Add do_self_spec espf_command_options_spec()

2010-04-10	Matthias Klose		<doko@ubuntu.com>, Kees Cook	<kees@outflux.net>,
			Anthony G. Basile	<basile@opensource.dyc.edu>

		LP #346126
		* gcc/gcc.c		*cpp_options			Add %(espf_cpp_options)
		
		* gcc/gcc.c		default_compilers[]		Add %(espf_options)
		*cpp_unique_options						Add %(espf_cpp_unique_options)

2010-04-10	Magnus Granberg		<zorry@gentoo.org>

		*gcc/gcc.c  Gentoo changes
		static const char *cc1_spec 	We set that in espf.h if ENABLE_ESPF.
		*cpp_unique_options				Remove espf_cpp_unique_options. (-D_FORTIFY_SOURCE=2)
		*cc1_options					Add espf_options_pie_check if ENABLE_ESPF.

--- gcc-4.5-20100128.orig/gcc/gcc.c	2010-01-21 10:29:30.000000000 -0500
+++ gcc-4.5-20100128/gcc/gcc.c	2010-01-29 23:29:16.000000000 -0500
@@ -84,6 +84,7 @@
 #include "gcc.h"
 #include "flags.h"
 #include "opts.h"
+#include "espf.h" /* for --enable-espf support */
 
 #ifdef HAVE_MMAP_FILE
 # include <sys/mman.h>
@@ -822,7 +823,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;
@@ -885,7 +888,7 @@
 static const char *cpp_options =
 "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
  %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*}\
- %{undef} %{save-temps*:-fpch-preprocess}";
+ %{undef} %{save-temps*:-fpch-preprocess} %(espf_cpp_options)";
 
 /* This contains cpp options which are not passed when the preprocessor
    output will be used by another program.  */
@@ -893,6 +896,9 @@
 
 /* NB: This is shared amongst all front-ends, except for Ada.  */
 static const char *cc1_options =
+#ifdef ENABLE_ESPF
+"%(espf_options_pie_check)"
+#endif
 "%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
  %1 %{!Q:-quiet} %{!dumpbase:-dumpbase %B} %{d*} %{m*} %{a*}\
  %{fcompare-debug-second:%:compare-debug-auxbase-opt(%b)} \
@@ -1075,15 +1081,15 @@
 	  %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
 		%(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
 		    cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
-			%(cc1_options)}\
+			%(cc1_options) %(espf_options)}\
 	  %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
-		cc1 %(cpp_unique_options) %(cc1_options)}}}\
+		cc1 %(cpp_unique_options) %(cc1_options) %(espf_options)}}}\
           %{!fsyntax-only:%(invoke_as)}} \
       %{combine:\
 	  %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
 		%(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i}}\
 	  %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
-		cc1 %(cpp_unique_options) %(cc1_options)}}\
+		cc1 %(cpp_unique_options) %(cc1_options) %(espf_options)}}\
                 %{!fsyntax-only:%(invoke_as)}}}}}}", 0, 1, 1},
   {"-",
    "%{!E:%e-E or -x required when input is from standard input}\
@@ -1106,7 +1112,7 @@
                     %W{o*:--output-pch=%*}%V}}}}}}", 0, 0, 0},
   {".i", "@cpp-output", 0, 1, 0},
   {"@cpp-output",
-   "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 1, 0},
+   "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %(espf_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 1, 0},
   {".s", "@assembler", 0, 1, 0},
   {"@assembler",
    "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 1, 0},
@@ -1699,18 +1705,23 @@
   INIT_STATIC_SPEC ("sysroot_hdrs_suffix_spec",	&sysroot_hdrs_suffix_spec),
 };
 
-#ifdef EXTRA_SPECS		/* additional specs needed */
+/* EXTRA_SPECS needs to be defined  */
+#ifndef EXTRA_SPECS
+#define EXTRA_SPECS
+#endif
+
+/* EXTRA_SPECS and ESPF_EXTRA_SPECS add additional specs */
 /* Structure to keep track of just the first two args of a spec_list.
-   That is all that the EXTRA_SPECS macro gives us.  */
+   That is all that the EXTRA_SPECS and ESPF_EXTRA_SPECS macro gives us.  */
 struct spec_list_1
 {
   const char *const name;
   const char *const ptr;
 };
 
-static const struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS };
+/* ESPF_EXTRA_SPECS before 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
 
 /* List of dynamically allocates specs that have been defined so far.  */
 
@@ -1798,7 +1809,6 @@
   if (verbose_flag)
     notice ("Using built-in specs.\n");
 
-#ifdef EXTRA_SPECS
   extra_specs = XCNEWVEC (struct spec_list, ARRAY_SIZE (extra_specs_1));
 
   for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--)
@@ -1811,7 +1821,6 @@
       sl->ptr_spec = &sl->ptr;
       next = sl;
     }
-#endif
 
   for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)
     {
@@ -7096,6 +7123,12 @@
     gcc_exec_prefix = concat (gcc_exec_prefix, spec_machine, dir_separator_str,
 			      spec_version, dir_separator_str, NULL);
 
+#ifdef ENABLE_ESPF
+  /* Process ESPF_COMMAND_OPTIONS_SPEC, adding any new options to the end
+     of the command line.  */
+  do_self_spec (espf_command_options_spec);
+#endif
+
   /* Now we have the specs.
      Set the `valid' bits for switches that match anything in any spec.  */