From: Michael Tremer Date: Wed, 11 Jun 2008 08:48:23 +0000 (+0200) Subject: GCC has a Stack Smashing Protector, now. X-Git-Tag: v3.0-alpha1~978^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3383fd60725d5e334d7bea7768a47ee00e854db;p=ipfire-3.x.git GCC has a Stack Smashing Protector, now. --- diff --git a/lfs/gcc b/lfs/gcc index d9a5eedee..64e290635 100644 --- a/lfs/gcc +++ b/lfs/gcc @@ -25,7 +25,7 @@ include Config PKG_NAME = gcc -VER = 4.2.3 +VER = 4.2.4 THISAPP = $(PKG_NAME)-$(VER) DL_FILE = $(THISAPP).tar.bz2 @@ -48,8 +48,10 @@ endif ############################################################################### objects = $(DL_FILE) \ - $(THISAPP)-cross_search_paths-1.patch \ - $(THISAPP)-specs-1.patch + $(THISAPP)-fstack_protector-1.patch \ + $(THISAPP)-strncat_chk-1.patch \ + $(THISAPP)-fortify_source-2.patch \ + $(THISAPP)-fpie-2.patch install : $(TARGET) @@ -66,172 +68,107 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) -mkdir -v $(DIR_SRC)/gcc-build - + ifeq "$(STAGE)" "toolchain" -ifeq "$(firstword $(MAKEFILE_LIST))" "$(PKG_NAME)" - # - # Normal build - # - ifeq "$(PASS)" "1" -ifeq "$(MACHINE)" "$(MACHINE_REAL)" - cd $(DIR_SRC)/gcc-build && CC="gcc -B/usr/bin/" ../$(THISAPP)/configure \ - --prefix=$(TOOLS_DIR) \ - --with-local-prefix=$(TOOLS_DIR) \ - --disable-nls \ - --enable-shared \ - --enable-languages=c - +ifeq "$(PIE)" "1" + ## Enable -fPIC by default + cd $(DIR_APP) && sed 's/^\(#define CC1_SPEC.*\)\("\)$$/\1 %{fno-pic|fpic|fPIC:;:-fPIC}\2/' \ + -i gcc/config/i386/linux.h +endif + cd $(DIR_SRC)/gcc-build && \ + ../$(THISAPP)/configure \ + --target=$(IFS_TARGET) \ + --prefix=$(TOOLS_DIR) \ + --enable-languages=c \ + --disable-shared \ + --disable-threads \ + --disable-multilib \ + --disable-libmudflap \ + --disable-libssp \ + --disable-libgomp \ + --disable-nls \ + --disable-werror cd $(DIR_SRC)/gcc-build && make -j $(PARALLELISM) cd $(DIR_SRC)/gcc-build && make install - ln -vs gcc $(TOOLS_DIR)/bin/cc -else - # - # Cross build - # - cd $(DIR_APP) && sed -e "s,/tools,$(TOOLS_DIR),g" \ - < $(DIR_PATCHES)/$(THISAPP)-specs-1.patch | patch -Np1 - - cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-cross_search_paths-1.patch - - cd $(DIR_APP) && cp -v gcc/cppdefault.c{,.orig} - cd $(DIR_APP) && sed -e '/#define STANDARD_INCLUDE_DIR/s@"/usr/include"@0@g' \ - gcc/cppdefault.c.orig > gcc/cppdefault.c - - cd $(DIR_APP) && cp -v gcc/Makefile.in{,.orig} - cd $(DIR_APP) && sed -e 's@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 $(TOOLS_DIR)/include@g' \ - gcc/Makefile.in.orig > gcc/Makefile.in - - cd $(DIR_SRC)/gcc-build && ../$(THISAPP)/configure \ - --prefix=$(TOOLS_DIR) \ - --build=${IFS_HOST} \ - --host=${IFS_TARGET} \ - --target=${IFS_TARGET} \ - --with-local-prefix=$(TOOLS_DIR) \ - --enable-long-long \ - --enable-c99 \ - --enable-shared \ - --enable-threads=posix \ - --enable-__cxa_atexit \ - --disable-nls \ - --enable-languages=c,c++ \ - --disable-libstdcxx-pch - - cd $(DIR_SRC)/gcc-build && make -j $(PARALLELISM) AS_FOR_TARGET=$(AS) \ - LD_FOR_TARGET=$(LD) - cd $(DIR_SRC)/gcc-build && make install -endif + + ln -fvs gcc $(TOOLS_DIR)/bin/cc + ln -sfv libgcc.a $$($(IFS_TARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/') endif ifeq "$(PASS)" "2" - cd $(DIR_APP) && cp -v gcc/Makefile.in{,.orig} - cd $(DIR_APP) && sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in - cd $(DIR_APP) && cp -v gcc/Makefile.in{,.tmp} - cd $(DIR_APP) && sed 's/^XCFLAGS =$$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \ - > gcc/Makefile.in - + cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-strncat_chk-1.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fortify_source-2.patch +ifeq "$(SSP)" "1" + cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fstack_protector-1.patch +endif +ifeq "$(PIE)" "1" + cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fpie-2.patch +endif + cd $(DIR_APP) && sed 's@\./fixinc\.sh@-c true@' -i gcc/Makefile.in + cd $(DIR_APP) && sed 's/^XCFLAGS =$$/& -fomit-frame-pointer/' -i gcc/Makefile.in cd $(DIR_APP) && \ for file in $$(find gcc/config -name linux64.h -o -name linux.h); do \ cp -uv $$file{,.orig}; \ - sed -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \ - -e 's@/usr@$(TOOLS_DIR)@g' $$file.orig > $$file; \ + sed -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \ + -e 's@/usr@$(TOOLS_DIR)@g' $$file.orig > $$file; \ echo -e "\n#undef STANDARD_INCLUDE_DIR\n#define STANDARD_INCLUDE_DIR 0" >> $$file; \ touch $$file.orig; \ done - - cd $(DIR_SRC)/gcc-build && ../$(THISAPP)/configure \ - --prefix=$(TOOLS_DIR) \ - --with-local-prefix=$(TOOLS_DIR) \ - --enable-clocale=gnu \ - --enable-shared \ - --enable-threads=posix \ - --enable-__cxa_atexit \ - --enable-languages=c,c++ \ - --disable-libstdcxx-pch \ - --disable-bootstrap - + + cd $(DIR_SRC)/gcc-build && \ + CC="$(IFS_TARGET)-gcc -B$(TOOLS_DIR)/lib/" \ + AR=$(IFS_TARGET)-ar \ + RANLIB=$(IFS_TARGET)-ranlib \ + ../$(THISAPP)/configure \ + --prefix=$(TOOLS_DIR) \ + --with-local-prefix=$(TOOLS_DIR) \ + --enable-clocale=gnu \ + --enable-shared \ + --enable-threads=posix \ + --enable-__cxa_atexit \ + --enable-languages=c,c++ \ + --disable-libstdcxx-pch \ + --disable-bootstrap \ + --disable-werror \ + --disable-nls \ + --disable-libgomp + ## Libgomp was disabled here because it doesn't want to compile ## cd $(DIR_SRC)/gcc-build && make -j $(PARALLELISM) cd $(DIR_SRC)/gcc-build && make install endif -else - # - # Cross build - # - - cd $(DIR_APP) && sed -e "s,/tools,$(TOOLS_DIR),g" \ - < $(DIR_PATCHES)/$(THISAPP)-specs-1.patch | patch -Np1 - - cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-cross_search_paths-1.patch - - echo -e "\n#undef STARTFILE_PREFIX_SPEC\n#define STARTFILE_PREFIX_SPEC \"$(TOOLS_DIR)/lib/\"" \ - >> $(DIR_APP)/gcc/config/linux.h - - cd $(DIR_APP) && cp -v gcc/Makefile.in{,.orig} - cd $(DIR_APP) && sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 $(TOOLS_DIR)/include@g" \ - gcc/Makefile.in.orig > gcc/Makefile.in - -ifeq "$(PASS)" "1" - cd $(DIR_SRC)/gcc-build && ../$(THISAPP)/configure \ - --prefix=$(CTOOLS_DIR) \ - --host=${IFS_HOST} \ - --target=${IFS_TARGET} \ - --disable-multilib \ - --with-local-prefix=$(TOOLS_DIR) \ - --disable-nls \ - --disable-shared \ - --disable-threads \ - --enable-languages=c - - cd $(DIR_SRC)/gcc-build && make all-gcc -j $(PARALLELISM) - cd $(DIR_SRC)/gcc-build && make install-gcc endif -ifeq "$(PASS)" "2" - cd $(DIR_APP) && cp -v configure{,.orig} - cd $(DIR_APP) && sed -e '/FLAGS_FOR_TARGET.*\/lib\//s@-B[^ ]*/lib/@@g' configure.orig > \ - configure - - cd $(DIR_SRC)/gcc-build && ../$(THISAPP)/configure \ - --prefix=$(CTOOLS_DIR) \ - --target=${IFS_TARGET} \ - --host=${IFS_HOST} \ - --disable-multilib \ - --with-local-prefix=$(TOOLS_DIR) \ - --disable-nls \ - --enable-shared \ - --enable-languages=c,c++ \ - --enable-__cxa_atexit \ - --enable-c99 \ - --enable-long-long \ - --enable-threads=posix - - cd $(DIR_SRC)/gcc-build && make AS_FOR_TARGET="${IFS_TARGET}-as" \ - LD_FOR_TARGET="${IFS_TARGET}-ld" - cd $(DIR_SRC)/gcc-build && make install -endif +ifeq "$(STAGE)" "base" + cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-strncat_chk-1.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fortify_source-2.patch +ifeq "$(SSP)" "1" + cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fstack_protector-1.patch endif +ifeq "$(PIE)" "1" + cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fpie-2.patch endif - -ifeq "$(STAGE)" "base" cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in cd $(DIR_APP) && sed -i 's/^XCFLAGS =$$/& -fomit-frame-pointer/' gcc/Makefile.in cd $(DIR_APP) && sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in - + cd $(DIR_SRC)/gcc-build && ../$(THISAPP)/configure \ - --prefix=/usr \ - --libexecdir=/usr/lib \ - --enable-shared \ - --enable-threads=posix \ - --enable-__cxa_atexit \ - --enable-clocale=gnu \ - --enable-languages=c,c++ \ - --disable-bootstrap - + --prefix=/usr \ + --libexecdir=/usr/lib \ + --enable-shared \ + --enable-threads=posix \ + --enable-__cxa_atexit \ + --enable-clocale=gnu \ + --enable-languages=c,c++ \ + --disable-bootstrap \ + --disable-werror \ + --disable-libgomp + ## Libgomp was disabled here because it doesn't want to compile ## cd $(DIR_SRC)/gcc-build && make -j $(PARALLELISM) cd $(DIR_SRC)/gcc-build && make install - + ln -sfv ../usr/bin/cpp /lib - ln -sfv gcc /usr/bin/cc + ln -sfv gcc /usr/bin/cc endif @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build