patches/glibc/2.9/100-ssp-compat.patch
branchnewlib
changeset 1365 c4d124ed9f8e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/glibc/2.9/100-ssp-compat.patch	Sun Apr 19 16:17:11 2009 +0000
     1.3 @@ -0,0 +1,193 @@
     1.4 +Original patch from: gentoo/src/patchsets/glibc/2.9/0010_all_glibc-2.7-ssp-compat.patch
     1.5 +
     1.6 +-= BEGIN original header =-
     1.7 +Add backwards compat support for gcc-3.x ssp ... older ssp versions
     1.8 +used __guard and __stack_smash_handler symbols while gcc-4.1 and newer
     1.9 +uses __stack_chk_guard and __stack_chk_fail.
    1.10 +
    1.11 +-= END original header =-
    1.12 +
    1.13 +diff -durN glibc-2_9.orig/Versions.def glibc-2_9/Versions.def
    1.14 +--- glibc-2_9.orig/Versions.def	2008-08-01 19:13:40.000000000 +0200
    1.15 ++++ glibc-2_9/Versions.def	2009-02-02 22:00:33.000000000 +0100
    1.16 +@@ -113,6 +113,9 @@
    1.17 +   GLIBC_2.0
    1.18 +   GLIBC_2.1
    1.19 +   GLIBC_2.3
    1.20 ++%ifdef ENABLE_OLD_SSP_COMPAT
    1.21 ++  GLIBC_2.3.2
    1.22 ++%endif
    1.23 +   GLIBC_2.4
    1.24 +   GLIBC_PRIVATE
    1.25 + }
    1.26 +diff -durN glibc-2_9.orig/config.h.in glibc-2_9/config.h.in
    1.27 +--- glibc-2_9.orig/config.h.in	2007-03-26 22:40:08.000000000 +0200
    1.28 ++++ glibc-2_9/config.h.in	2009-02-02 22:00:32.000000000 +0100
    1.29 +@@ -42,6 +42,9 @@
    1.30 +    assembler instructions per line.  Default is `;'  */
    1.31 + #undef ASM_LINE_SEP
    1.32 + 
    1.33 ++/* Define if we want to enable support for old ssp symbols */
    1.34 ++#undef	ENABLE_OLD_SSP_COMPAT
    1.35 ++
    1.36 + /* Define if not using ELF, but `.init' and `.fini' sections are available.  */
    1.37 + #undef	HAVE_INITFINI
    1.38 + 
    1.39 +diff -durN glibc-2_9.orig/configure glibc-2_9/configure
    1.40 +--- glibc-2_9.orig/configure	2008-11-11 10:50:11.000000000 +0100
    1.41 ++++ glibc-2_9/configure	2009-02-02 22:00:32.000000000 +0100
    1.42 +@@ -1380,6 +1380,9 @@
    1.43 +   --enable-kernel=VERSION compile for compatibility with kernel not older than
    1.44 +                           VERSION
    1.45 +   --enable-all-warnings   enable all useful warnings gcc can issue
    1.46 ++  --disable-old-ssp-compat
    1.47 ++                          enable support for older ssp symbols
    1.48 ++                          [default=no]
    1.49 + 
    1.50 + Optional Packages:
    1.51 +   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
    1.52 +@@ -6470,6 +6473,20 @@
    1.53 + echo "${ECHO_T}$libc_cv_ssp" >&6; }
    1.54 + 
    1.55 + 
    1.56 ++# Check whether --enable-old-ssp-compat or --disable-old-ssp-compat was given.
    1.57 ++if test "${enable_old_ssp_compat+set}" = set; then
    1.58 ++  enableval="$enable_old_ssp_compat"
    1.59 ++  enable_old_ssp_compat=$enableval
    1.60 ++else
    1.61 ++  enable_old_ssp_compat=no
    1.62 ++fi;
    1.63 ++if test "x$enable_old_ssp_compat" = "xyes"; then
    1.64 ++  cat >>confdefs.h <<\_ACEOF
    1.65 ++#define ENABLE_OLD_SSP_COMPAT 1
    1.66 ++_ACEOF
    1.67 ++
    1.68 ++fi
    1.69 ++
    1.70 + { echo "$as_me:$LINENO: checking for -fgnu89-inline" >&5
    1.71 + echo $ECHO_N "checking for -fgnu89-inline... $ECHO_C" >&6; }
    1.72 + if test "${libc_cv_gnu89_inline+set}" = set; then
    1.73 +diff -durN glibc-2_9.orig/configure.in glibc-2_9/configure.in
    1.74 +--- glibc-2_9.orig/configure.in	2008-11-11 10:50:11.000000000 +0100
    1.75 ++++ glibc-2_9/configure.in	2009-02-02 22:00:32.000000000 +0100
    1.76 +@@ -1647,6 +1647,15 @@
    1.77 + rm -f conftest*])
    1.78 + AC_SUBST(libc_cv_ssp)
    1.79 + 
    1.80 ++AC_ARG_ENABLE([old-ssp-compat],
    1.81 ++	      AC_HELP_STRING([--enable-old-ssp-compat],
    1.82 ++	                     [enable support for older ssp symbols @<:@default=no@:>@]),
    1.83 ++	      [enable_old_ssp_compat=$enableval],
    1.84 ++	      [enable_old_ssp_compat=no])
    1.85 ++if test "x$enable_old_ssp_compat" = "xyes"; then
    1.86 ++  AC_DEFINE(ENABLE_OLD_SSP_COMPAT)
    1.87 ++fi
    1.88 ++
    1.89 + AC_CACHE_CHECK(for -fgnu89-inline, libc_cv_gnu89_inline, [dnl
    1.90 + cat > conftest.c <<EOF
    1.91 + int foo;
    1.92 +diff -durN glibc-2_9.orig/csu/Versions glibc-2_9/csu/Versions
    1.93 +--- glibc-2_9.orig/csu/Versions	2006-10-28 01:11:41.000000000 +0200
    1.94 ++++ glibc-2_9/csu/Versions	2009-02-02 22:00:32.000000000 +0100
    1.95 +@@ -17,6 +17,12 @@
    1.96 +     # New special glibc functions.
    1.97 +     gnu_get_libc_release; gnu_get_libc_version;
    1.98 +   }
    1.99 ++  GLIBC_2.3.2 {
   1.100 ++%ifdef ENABLE_OLD_SSP_COMPAT
   1.101 ++    # global objects and functions for the old propolice patch in gcc
   1.102 ++    __guard;
   1.103 ++%endif
   1.104 ++  }
   1.105 +   GLIBC_PRIVATE {
   1.106 + %if HAVE___THREAD
   1.107 +     # This version is for the TLS symbol, GLIBC_2.0 is the old object symbol.
   1.108 +diff -durN glibc-2_9.orig/csu/libc-start.c glibc-2_9/csu/libc-start.c
   1.109 +--- glibc-2_9.orig/csu/libc-start.c	2007-08-21 00:27:50.000000000 +0200
   1.110 ++++ glibc-2_9/csu/libc-start.c	2009-02-02 22:00:32.000000000 +0100
   1.111 +@@ -37,6 +37,9 @@
   1.112 + uintptr_t __stack_chk_guard attribute_relro;
   1.113 + # endif
   1.114 + #endif
   1.115 ++#ifdef ENABLE_OLD_SSP_COMPAT
   1.116 ++uintptr_t __guard attribute_relro;
   1.117 ++#endif
   1.118 + 
   1.119 + #ifdef HAVE_PTR_NTHREADS
   1.120 + /* We need atomic operations.  */
   1.121 +@@ -141,6 +144,9 @@
   1.122 + 
   1.123 +   /* Set up the stack checker's canary.  */
   1.124 +   uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard ();
   1.125 ++#ifdef ENABLE_OLD_SSP_COMPAT
   1.126 ++  __guard = stack_chk_guard;
   1.127 ++#endif
   1.128 + # ifdef THREAD_SET_STACK_GUARD
   1.129 +   THREAD_SET_STACK_GUARD (stack_chk_guard);
   1.130 + # else
   1.131 +diff -durN glibc-2_9.orig/debug/Versions glibc-2_9/debug/Versions
   1.132 +--- glibc-2_9.orig/debug/Versions	2008-03-05 07:53:41.000000000 +0100
   1.133 ++++ glibc-2_9/debug/Versions	2009-02-02 22:00:32.000000000 +0100
   1.134 +@@ -10,6 +10,12 @@
   1.135 +     # These are to support some gcc features.
   1.136 +     __cyg_profile_func_enter; __cyg_profile_func_exit;
   1.137 +   }
   1.138 ++%ifdef ENABLE_OLD_SSP_COMPAT
   1.139 ++  GLIBC_2.3.2 {
   1.140 ++    # backwards ssp compat support; alias to __stack_chk_fail
   1.141 ++    __stack_smash_handler;
   1.142 ++  }
   1.143 ++%endif
   1.144 +   GLIBC_2.3.4 {
   1.145 +     __chk_fail;
   1.146 +     __memcpy_chk; __memmove_chk; __mempcpy_chk; __memset_chk; __stpcpy_chk;
   1.147 +diff -durN glibc-2_9.orig/debug/stack_chk_fail.c glibc-2_9/debug/stack_chk_fail.c
   1.148 +--- glibc-2_9.orig/debug/stack_chk_fail.c	2007-05-25 01:47:08.000000000 +0200
   1.149 ++++ glibc-2_9/debug/stack_chk_fail.c	2009-02-02 22:00:32.000000000 +0100
   1.150 +@@ -28,3 +28,7 @@
   1.151 + {
   1.152 +   __fortify_fail ("stack smashing detected");
   1.153 + }
   1.154 ++
   1.155 ++#ifdef ENABLE_OLD_SSP_COMPAT
   1.156 ++strong_alias (__stack_chk_fail, __stack_smash_handler)
   1.157 ++#endif
   1.158 +diff -durN glibc-2_9.orig/elf/Versions glibc-2_9/elf/Versions
   1.159 +--- glibc-2_9.orig/elf/Versions	2008-03-08 06:42:26.000000000 +0100
   1.160 ++++ glibc-2_9/elf/Versions	2009-02-02 22:00:33.000000000 +0100
   1.161 +@@ -43,6 +43,12 @@
   1.162 +     # runtime interface to TLS
   1.163 +     __tls_get_addr;
   1.164 +   }
   1.165 ++%ifdef ENABLE_OLD_SSP_COMPAT
   1.166 ++  GLIBC_2.3.2 {
   1.167 ++    # backwards ssp compat support
   1.168 ++    __guard;
   1.169 ++  }
   1.170 ++%endif
   1.171 +   GLIBC_2.4 {
   1.172 +     # stack canary
   1.173 +     __stack_chk_guard;
   1.174 +diff -durN glibc-2_9.orig/elf/rtld.c glibc-2_9/elf/rtld.c
   1.175 +--- glibc-2_9.orig/elf/rtld.c	2008-08-14 19:01:56.000000000 +0200
   1.176 ++++ glibc-2_9/elf/rtld.c	2009-02-02 22:00:32.000000000 +0100
   1.177 +@@ -89,6 +89,9 @@
   1.178 +    in thread local area.  */
   1.179 + uintptr_t __stack_chk_guard attribute_relro;
   1.180 + #endif
   1.181 ++#ifdef ENABLE_OLD_SSP_COMPAT
   1.182 ++uintptr_t __guard attribute_relro;
   1.183 ++#endif
   1.184 + 
   1.185 + /* Only exported for architectures that don't store the pointer guard
   1.186 +    value in thread local area.  */
   1.187 +@@ -842,6 +845,9 @@
   1.188 + {
   1.189 +   /* Set up the stack checker's canary.  */
   1.190 +   uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard ();
   1.191 ++#ifdef ENABLE_OLD_SSP_COMPAT
   1.192 ++  __guard = stack_chk_guard;
   1.193 ++#endif
   1.194 + #ifdef THREAD_SET_STACK_GUARD
   1.195 +   THREAD_SET_STACK_GUARD (stack_chk_guard);
   1.196 + #else