hgcc, etc

Robert Connolly cendres at videotron.ca
Tue Feb 17 10:10:09 PST 2004

This patch replaces hgcc.sh by hardcoding -pie and -fstack-protector-all. I 
have tested it on glibc and gcc and it builds both perfectly. There are a ton 
of failures from binutils testsuite. I'm almost sure the errors are in the 
teststuite itself, not with binutils apps. This patch will build anything 
not-static with -pie. -fstack-protector-all should/is filtered from -DIN_GCC, 
-D_KERNEL_, nostartfiles, etc because it offers no benifit guarding a lib, 
and only manages to contaminate the libs.

On my end this all looks pretty good and I'm ready to freeze this toolchain 
now that it seems to work pretty well. This patch is for x86, I can help PPC 
users to get this working for them too, or any other elf platform.

gcc-3.3.3 is the first gcc, as far as I can tell. that can build without 
textrel, so I definetly want to use it over 3.3.2. Still need a good 
glibc-2.3.3 tarball. ncurses-5.4 has a long list of bugfixes that might be 
good to add too.

While iptables is being worked on I'll try to start organizing the first book 
with the toolchain stuff, and it can be added to after. It wouldn't be too 
difficult to add Pam/cracklib at this stage unless anyone objects, or thinks 
it should stay in blfs. Shadow can take advantage of this.

Is iptables a blfs thing or will it be in the base? I feel iptables should be 
installed with nettools. If iptables is blfs, so should nettools. If they're 
both in the base thats fine with me, but I sorta feel networking should get 
its own chapter, which can deal with iptables, openssl, ipsec, snort, etc.

----- gcc-3.3.3-auto-pie-ssp-x86-1.patch --------

diff -Naur gcc-3.3.3.pie-ssp/gcc/config/i386/linux.h gcc-3.3.3.auto-pie-ssp/
--- gcc-3.3.3.pie-ssp/gcc/config/i386/linux.h	2003-11-14 06:46:12.000000000 
+++ gcc-3.3.3.auto-pie-ssp/gcc/config/i386/linux.h	2004-02-17 
05:55:48.000000000 +0000
@@ -94,11 +94,15 @@
 #ifdef USE_GNULIBC_1
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT} \
+%{!static:%{!no-pie:-D__PIC__ -DPIC}}"
 #undef CC1_SPEC
-#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
+#define CC1_SPEC "%(cc1_cpu) %{profile:-p} %{!no-pie:%{!static: -fPIC}} \
+%{!D__KERNEL__: %{!DIN_GCC: %{!nostartfiles: %{!nodefaultlibs: %{!nostdlib: \
+%{!nostdinc: %{!fno-stack-protector: -fstack-protector -fforce-addr \
+%{!fno-stack-protector-all: -fstack-protector-all} } } } } } } }"
 /* Provide a LINK_SPEC appropriate for Linux.  Here we provide support
    for the special GCC options -static and -shared, which allow us to
diff -Naur gcc-3.3.3.pie-ssp/gcc/config/linux.h gcc-3.3.3.auto-pie-ssp/gcc/
--- gcc-3.3.3.pie-ssp/gcc/config/linux.h	2004-02-17 05:38:34.000000000 +0000
+++ gcc-3.3.3.auto-pie-ssp/gcc/config/linux.h	2004-02-17 05:47:06.000000000 
@@ -56,12 +56,11 @@
 #if defined HAVE_LD_PIE
-  "%{!shared: \
-     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
-		       %{!p:%{profile:gcrt1.o%s} \
-			 %{!profile:%{pie:Scrt1.o%s}%{!pie:crt1.o%s}}}}} \
-   crti.o%s %{static:crtbeginT.o%s}\
-   %{!static:%{!shared:%{!pie:crtbegin.o%s}} %{shared|pie:crtbeginS.o%s}}"
+  "%{!shared: %{pg: gcrt1.o%s} %{!pg: %{p: gcrt1.o%s} \
+%{!p: %{profile: gcrt1.o%s} %{!profile: %{!static: %{!no-pie: Scrt1.o%s}} \
+%{static:crt1.o%s} %{!static: %{no-pie: crt1.o%s}}} }}} crti.o%s \
+%{static:crtbeginT.o%s} %{!static:%{!shared:%{no-pie:crtbegin.o%s}}} \
   "%{!shared: \
@@ -81,7 +80,8 @@
 #define ENDFILE_SPEC \
-  "%{!shared:%{!pie:crtend.o%s}} %{shared|pie:crtendS.o%s} crtn.o%s"
+  "%{static:crtend.o%s} %{!static:%{no-pie:crtend.o%s}} \
+%{!static:%{!no-pie:crtendS.o%s}} crtn.o%s"
 /* This is for -profile to use -lc_p instead of -lc.  */
 #ifndef CC1_SPEC
diff -Naur gcc-3.3.3.pie-ssp/gcc/gcc.c gcc-3.3.3.auto-pie-ssp/gcc/gcc.c
--- gcc-3.3.3.pie-ssp/gcc/gcc.c	2004-02-17 05:38:34.000000000 +0000
+++ gcc-3.3.3.auto-pie-ssp/gcc/gcc.c	2004-02-17 05:57:28.000000000 +0000
@@ -641,7 +641,8 @@
 #ifndef LINK_PIE_SPEC
 #ifdef HAVE_LD_PIE
-#define LINK_PIE_SPEC "%{pie:-pie} "
+#define LINK_PIE_SPEC "%{!no-pie: %{!static: %{!shared: %{!Bshareable: \
+%{!i: %{!r: -pie -z combreloc -z now} } } } } } "
 #define LINK_PIE_SPEC "%{pie:} "
diff -Naur gcc-3.3.3.pie-ssp/gcc/version.c gcc-3.3.3.auto-pie-ssp/gcc/
--- gcc-3.3.3.pie-ssp/gcc/version.c	2004-02-17 05:38:30.000000000 +0000
+++ gcc-3.3.3.auto-pie-ssp/gcc/version.c	2004-02-17 05:40:16.000000000 +0000
@@ -6,7 +6,7 @@
    please modify this string to indicate that, e.g. by putting your
    organization's name in parentheses at the end of the string.  */
-const char version_string[] = "3.3.3 (ssp)";
+const char version_string[] = "3.3.3 (pie - ssp)";
 /* This is the location of the online document giving instructions for
    reporting bugs.  If you distribute a modified version of GCC,

More information about the hlfs-dev mailing list