This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] libssp, fortify and TARGET_LIBC_PROVIDES_SSP


Hello,

If e.g. newlib is used TARGET_LIBC_PROVIDES_SSP expands to false.
Therefore, libssp is used. But the include path of libssp isn't added
automatically:

gcc -fstack-protector -O2 -D_FORTIFY_SOURCE=2 -v test.c

does not fortify source code. Only if the include path is specified
manually:

gcc -fstack-protector -O2 -D_FORTIFY_SOURCE=2 -v
-I$PREFIX/lib/gcc/spu/4.4.0/include/ssp test.c

Is there any reason why we don't include libssp path by default if libc
does not provide SSP functionality?

If not the attached patch might solve the problem. Tested against i386
where no libssp is needed (GLIBC 2.5) and a system with newlib 1.15
where libssp is mandatory.

cheers,
Stefan
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 141105)
+++ gcc/configure.ac	(working copy)
@@ -3515,7 +3515,11 @@
 if test x$gcc_cv_libc_provides_ssp = xyes; then
   AC_DEFINE(TARGET_LIBC_PROVIDES_SSP, 1,
 	    [Define if your target C library provides stack protector support])
+  LIBSSP_INCLUDE_DIR=""
+else
+  LIBSSP_INCLUDE_DIR="-DLIBSSP_INCLUDE_DIR=\\\"\$(libsubdir)/include/ssp\\\""
 fi
+AC_SUBST(LIBSSP_INCLUDE_DIR)
 
 # Check if TFmode long double should be used by default or not.
 # Some glibc targets used DFmode long double, but with glibc 2.4
Index: gcc/cppdefault.c
===================================================================
--- gcc/cppdefault.c	(revision 141105)
+++ gcc/cppdefault.c	(working copy)
@@ -46,6 +46,9 @@
 = INCLUDE_DEFAULTS;
 #else
 = {
+#ifdef LIBSSP_INCLUDE_DIR 
+    { LIBSSP_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
+#endif
 #ifdef GPLUSPLUS_INCLUDE_DIR
     /* Pick up GNU C++ generic include files.  */
     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 },
@@ -109,6 +112,14 @@
 const size_t cpp_GCC_INCLUDE_DIR_len = 0;
 #endif
 
+#ifdef LIBSSP_INCLUDE_DIR
+const char cpp_LIBSSP_INCLUDE_DIR[] = LIBSSP_INCLUDE_DIR;
+const size_t cpp_LIBSSP_INCLUDE_DIR_len = sizeof LIBSSP_INCLUDE_DIR - 1;
+#else
+const char cpp_LIBSSP_INCLUDE_DIR[] = "";
+const size_t cpp_LIBSSP_INCLUDE_DIR_len = 0;
+#endif
+
 /* The configured prefix.  */
 const char cpp_PREFIX[] = PREFIX;
 const size_t cpp_PREFIX_len = sizeof PREFIX - 1;
Index: gcc/cppdefault.h
===================================================================
--- gcc/cppdefault.h	(revision 141105)
+++ gcc/cppdefault.h	(working copy)
@@ -51,6 +51,8 @@
 extern const struct default_include cpp_include_defaults[];
 extern const char cpp_GCC_INCLUDE_DIR[];
 extern const size_t cpp_GCC_INCLUDE_DIR_len;
+extern const char cpp_LIBSSP_INCLUDE_DIR[];
+extern const size_t cpp_LIBSSP_INCLUDE_DIR_len;
 
 /* The configure-time prefix, i.e., the value supplied as the argument
    to --prefix=.  */
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 141105)
+++ gcc/Makefile.in	(working copy)
@@ -3483,7 +3483,8 @@
   -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
   -DPREFIX=\"$(prefix)/\" \
   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
-  @TARGET_SYSTEM_ROOT_DEFINE@
+  @TARGET_SYSTEM_ROOT_DEFINE@ \
+  @LIBSSP_INCLUDE_DIR@
 
 cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
 	cppdefault.h Makefile

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]