cvs commit: patches/gcc gcc-2.95.3-sspspecs-1.patch gcc-3.3-sspspecs-1.patch

jim at linuxfromscratch.org jim at linuxfromscratch.org
Mon Mar 15 11:10:11 PST 2004


jim         04/03/15 12:10:11

  Added:       gcc      gcc-2.95.3-sspspecs-1.patch
                        gcc-3.3-sspspecs-1.patch
  Log:
  Added: gcc-2.95.3-sspspecs-1.patch gcc-3.3-sspspecs-1.patch
  
  Revision  Changes    Path
  1.1                  patches/gcc/gcc-2.95.3-sspspecs-1.patch
  
  Index: gcc-2.95.3-sspspecs-1.patch
  ===================================================================
  Submitted By: Robert Connolly <cendres at videotron dot ca> (ashes)
  Date: 2004-03-15
  Initial Package Version: 2.95.3
  Origin: Based on gcc-3.3.2-pie-ssp.patch by Alexander Gabert
  Description: See description in the sspspecs.h hunk below the copyright.
  This patch will also work on gcc-3.x with fuzz
  
  diff -Naur gcc-2.95.3.orig/gcc/gcc.c gcc-2.95.3/gcc/gcc.c
  --- gcc-2.95.3.orig/gcc/gcc.c	2001-01-25 09:03:16.000000000 -0500
  +++ gcc-2.95.3/gcc/gcc.c	2004-03-15 10:42:40.000000000 -0500
  @@ -407,6 +407,7 @@
   
   /* config.h can define CC1_SPEC to provide extra args to cc1 and cc1plus
      or extra switch-translations.  */
  +#include "sspspecs.h"
   #ifndef CC1_SPEC
   #define CC1_SPEC ""
   #endif
  diff -Naur gcc-2.95.3.orig/gcc/sspspecs.h gcc-2.95.3/gcc/sspspecs.h
  --- gcc-2.95.3.orig/gcc/sspspecs.h	1969-12-31 19:00:00.000000000 -0500
  +++ gcc-2.95.3/gcc/sspspecs.h	2004-03-15 10:41:49.000000000 -0500
  @@ -0,0 +1,89 @@
  +/* Adds spec for RTL buffer overflow protection function
  +Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  +1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  +
  +This file is part of GCC.
  +
  +GCC is free software; you can redistribute it and/or modify it under
  +the terms of the GNU General Public License as published by the Free
  +Software Foundation; either version 2, or (at your option) any later
  +version.
  +
  +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  +for more details.
  +
  +You should have received a copy of the GNU General Public License
  +along with GCC; see the file COPYING.  If not, write to the Free
  +Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  +02111-1307, USA. */
  +
  +/* Based on http://dev.gentoo.org/~pappy/gentoo-projects/\
  +hardened-gcc/gentoo/distrib/3.3.2.2/noarch/gcc-3.3.2-pie-ssp.patch
  +thanks to Alexander Gabert and Hardened Gentoo. Modified for just
  +SSP, and for addition compatability with NetBSD. This patch adds
  +default specs for -fstack-protector-all with filters so libs should
  +build normaly. This patch does not have SSP functions, get those from
  +http://www.research.ibm.com/trl/projects/security/ssp/
  +Workgroup at hlfs-dev at linuxfromscratch.org
  +Website at http://www.linuxfromscratch.org/hlfs/ */
  +/* ashes */
  +
  +/* Hopefully this define will prevent this header from being looped.
  +	It gets endif'd at the bottom */
  +#ifndef SSP_SPEC_H
  +#define SSP_SPEC_H
  +
  +/* FreeBSD and OpenBSD targets are untested but should work.
  +	Please report error or success to the workgroup mailing list. */
  +#ifdef __FreeBSD__
  +#define SSP_KERNEL_EXCLUDE "D_KERNEL"
  +#endif
  +#ifdef __NetBSD__
  +#define SSP_KERNEL_EXCLUDE "D_KERNEL"
  +#endif
  +#ifdef __OpenBSD__
  +#define SSP_KERNEL_EXCLUDE "D_KERNEL"
  +#endif
  +#ifdef __linux__
  +#define SSP_KERNEL_EXCLUDE "D__KERNEL__"
  +#endif
  +
  +/* Fail if none of the above match. */
  +#ifndef SSP_KERNEL_EXCLUDE
  + #error "FAILED in sspspecs.h: Unknown target system - Hackme"
  +#endif
  +
  +/* Setup macro. */
  +#ifndef NSPEC
  +#define NSPEC(a,b) "%{!"a": "b"} "
  +#endif
  +
  +/* These are the exclusion flags wrapped in the above macro. */
  +#ifndef STD_SSP_EXCLUDE
  +#define STD_SSP_EXCLUDE(flag)			\
  +	NSPEC(SSP_KERNEL_EXCLUDE,				\
  +	NSPEC("DIN_GCC",					\
  +	NSPEC("DIN_LIBGCC",					\
  +	NSPEC("DIN_LIBGCC2",				\
  +	NSPEC("nostdlib",					\
  +	NSPEC("nodefaultlibs",				\
  +	NSPEC("fno-stack-protector",		\
  +	NSPEC("fno-stack-protector-all",	\
  +	flag								\
  +	))))))))
  +#endif
  +
  +/* -fforce-addr has been heavily tested by Gentoo and should be safe. */
  +#ifndef CC1_SSP
  +#define CC1_SSP	"-fstack-protector-all -fforce-addr"
  +#endif
  +
  +/* Setup our new spec string with exclusion flags, and prepend the original spec. */
  +static char cc1_spec_string[] = CC1_SPEC STD_SSP_EXCLUDE(CC1_SSP);
  +/* Redefine cc1 specs. */
  +#undef CC1_SPEC
  +#define CC1_SPEC (cc1_spec_string)
  +
  +#endif /* End of SSP_SPEC_H */
  
  
  
  1.1                  patches/gcc/gcc-3.3-sspspecs-1.patch
  
  Index: gcc-3.3-sspspecs-1.patch
  ===================================================================
  Submitted By: Robert Connolly <cendres at videotron dot ca> (ashes)
  Date: 2004-03-15
  Initial Package Version: 3.3
  Origin: Based on gcc-3.3.2-pie-ssp.patch by Alexander Gabert
  Description: See description in the sspspecs.h hunk below the copyright.
  This patch will also work on gcc-2.95.3 with fuzz
  
  diff -Naur gcc-3.3.3.orig/gcc/gcc.c gcc-3.3.3/gcc/gcc.c
  --- gcc-3.3.3.orig/gcc/gcc.c	2003-12-05 22:53:02.000000000 -0500
  +++ gcc-3.3.3/gcc/gcc.c	2004-03-15 11:49:16.000000000 -0500
  @@ -555,6 +555,7 @@
   
   /* config.h can define CC1_SPEC to provide extra args to cc1 and cc1plus
      or extra switch-translations.  */
  +#include "sspspecs.h"
   #ifndef CC1_SPEC
   #define CC1_SPEC ""
   #endif
  diff -Naur gcc-3.3.3.orig/gcc/sspspecs.h gcc-3.3.3/gcc/sspspecs.h
  --- gcc-3.3.3.orig/gcc/sspspecs.h	1969-12-31 19:00:00.000000000 -0500
  +++ gcc-3.3.3/gcc/sspspecs.h	2004-03-15 11:49:16.000000000 -0500
  @@ -0,0 +1,89 @@
  +/* Adds spec for RTL buffer overflow protection function
  +Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  +1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  +
  +This file is part of GCC.
  +
  +GCC is free software; you can redistribute it and/or modify it under
  +the terms of the GNU General Public License as published by the Free
  +Software Foundation; either version 2, or (at your option) any later
  +version.
  +
  +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  +WARRANTY; without even the implied warranty of MERCHANTABILITY or
  +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  +for more details.
  +
  +You should have received a copy of the GNU General Public License
  +along with GCC; see the file COPYING.  If not, write to the Free
  +Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  +02111-1307, USA. */
  +
  +/* Based on http://dev.gentoo.org/~pappy/gentoo-projects/\
  +hardened-gcc/gentoo/distrib/3.3.2.2/noarch/gcc-3.3.2-pie-ssp.patch
  +thanks to Alexander Gabert and Hardened Gentoo. Modified for just
  +SSP, and for addition compatability with NetBSD. This patch adds
  +default specs for -fstack-protector-all with filters so libs should
  +build normaly. This patch does not have SSP functions, get those from
  +http://www.research.ibm.com/trl/projects/security/ssp/
  +Workgroup at hlfs-dev at linuxfromscratch.org
  +Website at http://www.linuxfromscratch.org/hlfs/ */
  +/* ashes */
  +
  +/* Hopefully this define will prevent this header from being looped.
  +	It gets endif'd at the bottom */
  +#ifndef SSP_SPEC_H
  +#define SSP_SPEC_H
  +
  +/* FreeBSD and OpenBSD targets are untested but should work.
  +	Please report error or success to the workgroup mailing list. */
  +#ifdef __FreeBSD__
  +#define SSP_KERNEL_EXCLUDE "D_KERNEL"
  +#endif
  +#ifdef __NetBSD__
  +#define SSP_KERNEL_EXCLUDE "D_KERNEL"
  +#endif
  +#ifdef __OpenBSD__
  +#define SSP_KERNEL_EXCLUDE "D_KERNEL"
  +#endif
  +#ifdef __linux__
  +#define SSP_KERNEL_EXCLUDE "D__KERNEL__"
  +#endif
  +
  +/* Fail if none of the above match. */
  +#ifndef SSP_KERNEL_EXCLUDE
  + #error "FAILED in sspspecs.h: Unknown target system - Hackme"
  +#endif
  +
  +/* Setup macro. */
  +#ifndef NSPEC
  +#define NSPEC(a,b) "%{!"a": "b"} "
  +#endif
  +
  +/* These are the exclusion flags wrapped in the above macro. */
  +#ifndef STD_SSP_EXCLUDE
  +#define STD_SSP_EXCLUDE(flag)			\
  +	NSPEC(SSP_KERNEL_EXCLUDE,				\
  +	NSPEC("DIN_GCC",					\
  +	NSPEC("DIN_LIBGCC",					\
  +	NSPEC("DIN_LIBGCC2",				\
  +	NSPEC("nostdlib",					\
  +	NSPEC("nodefaultlibs",				\
  +	NSPEC("fno-stack-protector",		\
  +	NSPEC("fno-stack-protector-all",	\
  +	flag								\
  +	))))))))
  +#endif
  +
  +/* -fforce-addr has been heavily tested by Gentoo and should be safe. */
  +#ifndef CC1_SSP
  +#define CC1_SSP	"-fstack-protector-all -fforce-addr"
  +#endif
  +
  +/* Setup our new spec string with exclusion flags, and prepend the original spec. */
  +static char cc1_spec_string[] = CC1_SPEC STD_SSP_EXCLUDE(CC1_SSP);
  +/* Redefine cc1 specs. */
  +#undef CC1_SPEC
  +#define CC1_SPEC (cc1_spec_string)
  +
  +#endif /* End of SSP_SPEC_H */
  
  
  



More information about the patches mailing list