Gentoo Archives: gentoo-commits

From: Magnus Granberg <zorry@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-gccpatchset:master commit in: gcc-4.7.0/piepatch/
Date: Tue, 02 Oct 2012 16:13:40
Message-Id: 1349194372.252205a3612155769c1c4b6b6db687c044e9f558.zorry@gentoo
1 commit: 252205a3612155769c1c4b6b6db687c044e9f558
2 Author: Magnus Granberg <zorry <AT> gentoo <DOT> org>
3 AuthorDate: Tue Oct 2 16:12:52 2012 +0000
4 Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 2 16:12:52 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-gccpatchset.git;a=commit;h=252205a3
7
8 Add configure.ac patches
9
10 ---
11 gcc-4.7.0/piepatch/01_all_gcc47_configure.ac.patch | 139 ++++++++++++++++++++
12 gcc-4.7.0/piepatch/01_all_gcc47_configure.patch | 2 +-
13 gcc-4.7.0/piepatch/README.Changelog | 10 ++
14 gcc-4.7.0/piepatch/README.history | 3 +
15 4 files changed, 153 insertions(+), 1 deletions(-)
16
17 diff --git a/gcc-4.7.0/piepatch/01_all_gcc47_configure.ac.patch b/gcc-4.7.0/piepatch/01_all_gcc47_configure.ac.patch
18 new file mode 100644
19 index 0000000..ed49cd9
20 --- /dev/null
21 +++ b/gcc-4.7.0/piepatch/01_all_gcc47_configure.ac.patch
22 @@ -0,0 +1,139 @@
23 +2011-04-27 Magnus Granberg <zorry@g.o>
24 +
25 + * configure.ac Add --enable-esp. Add -fno-stack-protector
26 + to stage1_cflags.
27 + * gcc/configure.ac Add --enable-esp and check if SSP works.
28 + Define ENABLE_ESP ENABLE_ESP_SSP.
29 + Check if we support crtbeginP and define ENABLE_CRTBEGINP.
30 +
31 +--- a/configure.ac 2011-11-29 22:36:43.000000000 +0100
32 ++++ b/configure.ac 2011-12-07 23:29:26.125712475 +0100
33 +@@ -419,6 +419,25 @@ if test "${ENABLE_LIBADA}" != "yes" ; th
34 + noconfigdirs="$noconfigdirs gnattools"
35 + fi
36 +
37 ++# Check whether --enable-esp was given and target have the support.
38 ++AC_ARG_ENABLE([esp],
39 ++[AS_HELP_STRING([--enable-esp],
40 ++ [Enable Stack protector, Position independent executable as
41 ++ default if we have suppot for it when compiling
42 ++ and link with -z relro and -z now as default.
43 ++ Linux targets supported i*86, x86_64, x86_x32, powerpc, powerpc64, ia64 and arm.])],
44 ++[
45 ++ case $target in
46 ++ i?86*-*-linux* | x86_??*-*-linux* | powerpc-*-linux* | powerpc64-*-linux* | arm*-*-linux* | ia64-*-linux*)
47 ++ enable_espf=yes
48 ++ ;;
49 ++ *)
50 ++ AC_MSG_WARN([*** --enable-esp is not supported on this $target target.])
51 ++ ;;
52 ++ esac
53 ++])
54 ++AC_SUBST([enable_esp])
55 ++
56 + AC_ARG_ENABLE(libssp,
57 + [AS_HELP_STRING([--enable-libssp], [build libssp directory])],
58 + ENABLE_LIBSSP=$enableval,
59 +@@ -3211,6 +3230,11 @@ if test "$GCC" = yes -a "$ENABLE_BUILD_W
60 + CFLAGS="$saved_CFLAGS"
61 + fi
62 +
63 ++# Disable -fstack-protector on stage1
64 ++if test x$enable_esp = xyes; then
65 ++ stage1_cflags="$stage1_cflags -fno-stack-protector"
66 ++fi
67 ++
68 + AC_SUBST(stage1_cflags)
69 +
70 + # Enable --enable-checking in stage1 of the compiler.
71 +--- a/gcc/configure.ac 2011-11-18 11:52:32.000000000 +0100
72 ++++ b/gcc/configure.ac 2012-10-02 17:39:15.649526241 +0200
73 +@@ -5130,6 +5237,88 @@ if test x"${LINKER_HASH_STYLE}" != x; th
74 + [The linker hash style])
75 + fi
76 +
77 ++# --------------
78 ++# Esp checks
79 ++# --------------
80 ++
81 ++# Check whether --enable-esp was given and target have the support.
82 ++AC_ARG_ENABLE([esp],
83 ++[AS_HELP_STRING([--enable-esp],
84 ++ [Enable Stack protector, Position independent executable and
85 ++ Fortify_sources as default if we have suppot for it when compiling
86 ++ and link -z now as default.
87 ++ Linux targets supported i*86, x86_64, x86_x32, powerpc, powerpc64, ia64 and arm])],
88 ++ set_enable_espf=$enableval,
89 ++ set_enable_espf=no)
90 ++if test $set_enable_esp = yes ; then
91 ++ AC_MSG_CHECKING(if $target support esp)
92 ++if test $set_enable_esp = yes ; then
93 ++ case "$target" in
94 ++ i?86*-*-linux* | x86_??*-*-linux* | powerpc-*-linux* | powerpc64-*-linux* | arm*-*-linux* | ia64-*-linux*)
95 ++ enable_esp=yes
96 ++ AC_DEFINE(ENABLE_ESP, 1,
97 ++ [Define if your target support esp and you have enable it.])
98 ++ ;;
99 ++ *)
100 ++ enable_esp=no
101 ++ ;;
102 ++ esac
103 ++else
104 ++ enable_esp=no
105 ++fi
106 ++AC_MSG_RESULT($enable_esp)
107 ++fi
108 ++AC_SUBST([enable_esp])
109 ++if test $enable_esp = yes ; then
110 ++
111 ++ AC_MSG_CHECKING(if we can default to use -fstack-protector-all)
112 ++ ssp_link_test=no
113 ++ if test x$gcc_cv_libc_provides_ssp = xyes && test x$set_have_as_tls = xyes; then
114 ++ if $EGREP '^ *#[ ]*define[ ]+__UCLIBC__[ ]+1' \
115 ++ $target_header_dir/features.h > /dev/null; then
116 ++ if test -f $target_header_dir/bits/uClibc_config.h && \
117 ++ $EGREP '^ *#[ ]*define[ ]+__UCLIBC_SUBLEVEL__[ ]+([3-9][2-9]|[4-9][0-9])' \
118 ++ $target_header_dir/bits/uClibc_config.h > /dev/null && \
119 ++ $EGREP '^ *#[ ]*define[ ]+__UCLIBC_HAS_TLS__[ ]+1' \
120 ++ $target_header_dir/bits/uClibc_config.h > /dev/null; then
121 ++ ssp_link_test=yes
122 ++ fi
123 ++ else
124 ++ ssp_link_test=yes
125 ++ fi
126 ++ fi
127 ++ if test x$ssp_link_test=xyes ; then
128 ++ saved_CFLAGS="$CFLAGS"
129 ++ CFLAGS="$CFLAGS -O2 -fstack-protector-all -Werror"
130 ++ AC_TRY_LINK(,,
131 ++ [AC_MSG_RESULT([yes]); enable_esp_ssp=yes],
132 ++ [AC_MSG_RESULT([no]); enable_esp_ssp=no])
133 ++ CFLAGS="$saved_CFLAGS"
134 ++ else
135 ++ [AC_MSG_RESULT([no]); enable_esp_ssp=no]
136 ++ fi
137 ++ if test $enable_esp_ssp = yes ; then
138 ++ AC_DEFINE(ENABLE_ESP_SSP, 1,
139 ++ [Define if your compiler will default to use -fstack-protector-all.])
140 ++ fi
141 ++ AC_MSG_CHECKING(checking for crtbeginP.o support)
142 ++ if test x$enable_esp = xyes ; then
143 ++ case "$target" in
144 ++ ia64*-*-linux*)
145 ++ enable_crtbeginP=no ;;
146 ++ *-*-linux*)
147 ++ if test x$gcc_cv_ld_pie = xyes && test x$lt_cv_prog_compiler_static_works = xyes; then
148 ++ enable_crtbeginP=yes
149 ++ AC_DEFINE(ENABLE_CRTBEGINP, 1,
150 ++ [Define if your compiler will support crtbeginP.])
151 ++ fi
152 ++ ;;
153 ++ *) enable_crtbeginP=no ;;
154 ++ esac
155 ++ fi
156 ++ AC_MSG_RESULT($enable_crtbeginP)
157 ++fi
158 ++
159 + # Configure the subdirectories
160 + # AC_CONFIG_SUBDIRS($subdirs)
161 +
162
163 diff --git a/gcc-4.7.0/piepatch/01_all_gcc47_configure.patch b/gcc-4.7.0/piepatch/01_all_gcc47_configure.patch
164 index 3823f1b..1a48f49 100644
165 --- a/gcc-4.7.0/piepatch/01_all_gcc47_configure.patch
166 +++ b/gcc-4.7.0/piepatch/01_all_gcc47_configure.patch
167 @@ -125,7 +125,7 @@
168 +$as_echo_n "checking if $target support esp... " >&6; }
169 +if test $set_enable_esp = yes ; then
170 + case "$target" in
171 -+ i?86*-*-linux* | x86_??*-*-linux* | powerpc-*-linux* | powerpc64-*-linux* | arm*-*-linux* | ia64-*-linux* | mips*-*-linux*)
172 ++ i?86*-*-linux* | x86_??*-*-linux* | powerpc-*-linux* | powerpc64-*-linux* | arm*-*-linux* | ia64-*-linux*)
173 + enable_esp=yes
174 +
175 +$as_echo "#define ENABLE_ESP 1" >>confdefs.h
176
177 diff --git a/gcc-4.7.0/piepatch/README.Changelog b/gcc-4.7.0/piepatch/README.Changelog
178 index b6252ed..009e128 100644
179 --- a/gcc-4.7.0/piepatch/README.Changelog
180 +++ b/gcc-4.7.0/piepatch/README.Changelog
181 @@ -1,3 +1,13 @@
182 +0.5.4 Magnus Granberg <zorry@g.o>
183 +
184 + #436924
185 + * configure.ac Add --enable-esp. Add -fno-stack-protector
186 + to stage1_cflags.
187 + * gcc/configure.ac Add --enable-esp and check if SSP works.
188 + Define ENABLE_ESP ENABLE_ESP_SSP.
189 + Check if we support crtbeginP and define ENABLE_CRTBEGINP.
190 + * gcc/configure Fix a typo
191 +
192 0.5.3 Magnus Granberg <zorry@g.o>
193
194 * gcc/configure Clean up the checks and added
195
196 diff --git a/gcc-4.7.0/piepatch/README.history b/gcc-4.7.0/piepatch/README.history
197 index 537cc48..82b2ee3 100644
198 --- a/gcc-4.7.0/piepatch/README.history
199 +++ b/gcc-4.7.0/piepatch/README.history
200 @@ -1,3 +1,6 @@
201 +0.5.4 02 Oct 2012
202 + U 01_all_gcc47_configure.patch
203 + + 01_all_gcc47_configure.ac.patch
204 0.5.3 06 Apr 2012
205 U 01_all_gcc47_configure.patch
206 + 02_all_gcc47_config.in.patch