summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-02 08:52:21 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-02 08:52:21 +0000
commit0d55f4d0aeaeb16629a2c07c96a190695b83a7e6 (patch)
tree1cb854702400de0149fb900c82b137e5603e222b /gcc
parentc656b4ab03db593f6251031bbdcf8fa2e7324ee0 (diff)
downloadgcc-0d55f4d0aeaeb16629a2c07c96a190695b83a7e6.tar.gz
* Makefile.def (target_modules): Add libssp.
* configure.in (target_libraries): Add target-libssp. * configure: Rebuilt. * Makefile.in: Rebuilt. gcc/ * gcc.c (LINK_SSP_SPEC): Define. (link_ssp_spec): New variable. (LINK_COMMAND_SPEC): Add %(link_ssp). (static_specs): Add link_ssp_spec. * configure.ac (TARGET_LIBC_PROVIDES_SSP): New test. * configure: Rebuilt. * config.in: Rebuilt. * config/rs6000/linux.h (TARGET_THREAD_SSP_OFFSET): Define. * config/rs6000/linux64.h (TARGET_THREAD_SSP_OFFSET): Likewise. * config/i386/linux.h (TARGET_THREAD_SSP_OFFSET): Likewise. * config/i386/linux64.h (TARGET_THREAD_SSP_OFFSET): Likewise. * config/rs6000/rs6000.md (stack_protect_set, stack_protect_test): If TARGET_THREAD_SSP_OFFSET is defined, use -0x7010(13) resp. -0x7008(2) instead of reading __stack_chk_guard variable. * config/i386/i386.md (UNSPEC_SP_SET, UNSPEC_SP_TEST): Change number. (UNSPEC_SP_TLS_SET, UNSPEC_SP_TLS_TEST): New constants. (stack_protect_set, stack_protect_test): Use *_tls* patterns if TARGET_THREAD_SSP_OFFSET is defined. (stack_tls_protect_set_si, stack_tls_protect_set_di, stack_tls_protect_test_si, stack_tls_protect_test_di): New insns. Revert: 2005-06-27 Richard Henderson <rth@redhat.com> * libgcc-std.ver (GCC_4.1.0): New. * libgcc.h (__stack_chk_guard): Declare. (__stack_chk_fail, __stack_chk_fail_local): Declare. * libgcc2.c (L_stack_chk, L_stack_chk_local): New. * mklibgcc.in (lib2funcs): Add them. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101531 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog33
-rw-r--r--gcc/config.in6
-rw-r--r--gcc/config/i386/i386.md64
-rw-r--r--gcc/config/i386/linux.h5
-rw-r--r--gcc/config/i386/linux64.h6
-rw-r--r--gcc/config/rs6000/linux.h5
-rw-r--r--gcc/config/rs6000/linux64.h6
-rw-r--r--gcc/config/rs6000/rs6000.md10
-rwxr-xr-xgcc/configure48
-rw-r--r--gcc/configure.ac39
-rw-r--r--gcc/gcc.c12
-rw-r--r--gcc/libgcc-std.ver7
-rw-r--r--gcc/libgcc2.c138
-rw-r--r--gcc/libgcc2.h5
-rw-r--r--gcc/mklibgcc.in2
15 files changed, 232 insertions, 154 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a29ff99f76a..10a8536bc92 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,36 @@
+2005-07-02 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.c (LINK_SSP_SPEC): Define.
+ (link_ssp_spec): New variable.
+ (LINK_COMMAND_SPEC): Add %(link_ssp).
+ (static_specs): Add link_ssp_spec.
+ * configure.ac (TARGET_LIBC_PROVIDES_SSP): New test.
+ * configure: Rebuilt.
+ * config.in: Rebuilt.
+
+ * config/rs6000/linux.h (TARGET_THREAD_SSP_OFFSET): Define.
+ * config/rs6000/linux64.h (TARGET_THREAD_SSP_OFFSET): Likewise.
+ * config/i386/linux.h (TARGET_THREAD_SSP_OFFSET): Likewise.
+ * config/i386/linux64.h (TARGET_THREAD_SSP_OFFSET): Likewise.
+ * config/rs6000/rs6000.md (stack_protect_set, stack_protect_test):
+ If TARGET_THREAD_SSP_OFFSET is defined, use -0x7010(13) resp.
+ -0x7008(2) instead of reading __stack_chk_guard variable.
+ * config/i386/i386.md (UNSPEC_SP_SET, UNSPEC_SP_TEST): Change
+ number.
+ (UNSPEC_SP_TLS_SET, UNSPEC_SP_TLS_TEST): New constants.
+ (stack_protect_set, stack_protect_test): Use *_tls* patterns
+ if TARGET_THREAD_SSP_OFFSET is defined.
+ (stack_tls_protect_set_si, stack_tls_protect_set_di,
+ stack_tls_protect_test_si, stack_tls_protect_test_di): New insns.
+
+ Revert:
+ 2005-06-27 Richard Henderson <rth@redhat.com>
+ * libgcc-std.ver (GCC_4.1.0): New.
+ * libgcc.h (__stack_chk_guard): Declare.
+ (__stack_chk_fail, __stack_chk_fail_local): Declare.
+ * libgcc2.c (L_stack_chk, L_stack_chk_local): New.
+ * mklibgcc.in (lib2funcs): Add them.
+
2005-07-01 Richard Henderson <rth@redhat.com>
* config/i386/linux-unwind.h (x86_64_fallback_frame_state): Cast to
diff --git a/gcc/config.in b/gcc/config.in
index 2d12fd04042..192b4619465 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1270,6 +1270,12 @@
#endif
+/* Define if your target C library provides stack protector support */
+#ifndef USED_FOR_TARGET
+#undef TARGET_LIBC_PROVIDES_SSP
+#endif
+
+
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#ifndef USED_FOR_TARGET
#undef TIME_WITH_SYS_TIME
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 1ca5d223272..c0823b608d8 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -81,8 +81,6 @@
(UNSPEC_FLDCW 25)
(UNSPEC_REP 26)
(UNSPEC_EH_RETURN 27)
- (UNSPEC_SP_SET 28)
- (UNSPEC_SP_TEST 29)
; For SSE/MMX support:
(UNSPEC_FIX_NOTRUNC 30)
@@ -140,6 +138,12 @@
(UNSPEC_FPREM_U 89)
(UNSPEC_FPREM1_F 90)
(UNSPEC_FPREM1_U 91)
+
+ ; SSP patterns
+ (UNSPEC_SP_SET 100)
+ (UNSPEC_SP_TEST 101)
+ (UNSPEC_SP_TLS_SET 102)
+ (UNSPEC_SP_TLS_TEST 103)
])
(define_constants
@@ -19613,10 +19617,19 @@
(match_operand 1 "memory_operand" "")]
""
{
+#ifdef TARGET_THREAD_SSP_OFFSET
+ if (TARGET_64BIT)
+ emit_insn (gen_stack_tls_protect_set_di (operands[0],
+ GEN_INT (TARGET_THREAD_SSP_OFFSET)));
+ else
+ emit_insn (gen_stack_tls_protect_set_si (operands[0],
+ GEN_INT (TARGET_THREAD_SSP_OFFSET)));
+#else
if (TARGET_64BIT)
emit_insn (gen_stack_protect_set_di (operands[0], operands[1]));
else
emit_insn (gen_stack_protect_set_si (operands[0], operands[1]));
+#endif
DONE;
})
@@ -19638,6 +19651,24 @@
"mov{q}\t{%1, %2|%2, %1}\;mov{q}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2"
[(set_attr "type" "multi")])
+(define_insn "stack_tls_protect_set_si"
+ [(set (match_operand:SI 0 "memory_operand" "=m")
+ (unspec:SI [(match_operand:SI 1 "const_int_operand" "i")] UNSPEC_SP_TLS_SET))
+ (set (match_scratch:SI 2 "=&r") (const_int 0))
+ (clobber (reg:CC FLAGS_REG))]
+ ""
+ "mov{l}\t{%%gs:%P1, %2|%2, DWORD PTR %%gs:%P1}\;mov{l}\t{%2, %0|%0, %2}\;xor{l}\t%2, %2"
+ [(set_attr "type" "multi")])
+
+(define_insn "stack_tls_protect_set_di"
+ [(set (match_operand:DI 0 "memory_operand" "=m")
+ (unspec:DI [(match_operand:DI 1 "const_int_operand" "i")] UNSPEC_SP_TLS_SET))
+ (set (match_scratch:DI 2 "=&r") (const_int 0))
+ (clobber (reg:CC FLAGS_REG))]
+ "TARGET_64BIT"
+ "mov{q}\t{%%fs:%P1, %2|%2, QWORD PTR %%fs:%P1}\;mov{q}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2"
+ [(set_attr "type" "multi")])
+
(define_expand "stack_protect_test"
[(match_operand 0 "memory_operand" "")
(match_operand 1 "memory_operand" "")
@@ -19649,10 +19680,19 @@
ix86_compare_op1 = operands[1];
ix86_compare_emitted = flags;
+#ifdef TARGET_THREAD_SSP_OFFSET
+ if (TARGET_64BIT)
+ emit_insn (gen_stack_tls_protect_test_di (flags, operands[0],
+ GEN_INT (TARGET_THREAD_SSP_OFFSET)));
+ else
+ emit_insn (gen_stack_tls_protect_test_si (flags, operands[0],
+ GEN_INT (TARGET_THREAD_SSP_OFFSET)));
+#else
if (TARGET_64BIT)
emit_insn (gen_stack_protect_test_di (flags, operands[0], operands[1]));
else
emit_insn (gen_stack_protect_test_si (flags, operands[0], operands[1]));
+#endif
emit_jump_insn (gen_beq (operands[2]));
DONE;
})
@@ -19677,6 +19717,26 @@
"mov{q}\t{%1, %3|%3, %1}\;xor{q}\t{%2, %3|%3, %2}"
[(set_attr "type" "multi")])
+(define_insn "stack_tls_protect_test_si"
+ [(set (match_operand:CCZ 0 "flags_reg_operand" "")
+ (unspec:CCZ [(match_operand:SI 1 "memory_operand" "m")
+ (match_operand:SI 2 "const_int_operand" "i")]
+ UNSPEC_SP_TLS_TEST))
+ (clobber (match_scratch:SI 3 "=r"))]
+ ""
+ "mov{l}\t{%1, %3|%3, %1}\;xor{l}\t{%%gs:%P2, %3|%3, DWORD PTR %%gs:%P2}"
+ [(set_attr "type" "multi")])
+
+(define_insn "stack_tls_protect_test_di"
+ [(set (match_operand:CCZ 0 "flags_reg_operand" "")
+ (unspec:CCZ [(match_operand:DI 1 "memory_operand" "m")
+ (match_operand:DI 2 "const_int_operand" "i")]
+ UNSPEC_SP_TLS_TEST))
+ (clobber (match_scratch:DI 3 "=r"))]
+ "TARGET_64BIT"
+ "mov{q}\t{%1, %3|%3, %1}\;xor{q}\t{%%fs:%P2, %3|%3, QWORD PTR %%fs:%P2}"
+ [(set_attr "type" "multi")])
+
(include "sse.md")
(include "mmx.md")
(include "sync.md")
diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index 5f4c10d3f18..082cc958e07 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -185,3 +185,8 @@ Boston, MA 02110-1301, USA. */
/* This macro may be overridden in i386/k*bsd-gnu.h. */
#define REG_NAME(reg) reg
+
+#ifdef TARGET_LIBC_PROVIDES_SSP
+/* i386 glibc provides __stack_chk_guard in %gs:0x14. */
+#define TARGET_THREAD_SSP_OFFSET 0x14
+#endif
diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index 2578958c77d..3a37f634bb6 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -73,3 +73,9 @@ Boston, MA 02110-1301, USA. */
/* This macro may be overridden in i386/k*bsd-gnu.h. */
#define REG_NAME(reg) reg
+
+#ifdef TARGET_LIBC_PROVIDES_SSP
+/* i386 glibc provides __stack_chk_guard in %gs:0x14,
+ x86_64 glibc provides it in %fs:0x28. */
+#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? 0x28 : 0x14)
+#endif
diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
index 949af27bc96..79eb199f952 100644
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -113,3 +113,8 @@
#define TARGET_HAS_F_SETLKW
#define MD_UNWIND_SUPPORT "config/rs6000/linux-unwind.h"
+
+#ifdef TARGET_LIBC_PROVIDES_SSP
+/* ppc32 glibc provides __stack_chk_guard in -0x7008(2). */
+#define TARGET_THREAD_SSP_OFFSET -0x7008
+#endif
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 68b121c7a49..7343cbb8723 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -547,3 +547,9 @@ while (0)
#endif
#define MD_UNWIND_SUPPORT "config/rs6000/linux-unwind.h"
+
+#ifdef TARGET_LIBC_PROVIDES_SSP
+/* ppc32 glibc provides __stack_chk_guard in -0x7008(2),
+ ppc64 glibc provides it at -0x7010(13). */
+#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? -0x7010 : -0x7008)
+#endif
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 9211e567a9f..3f5c1b4b0dd 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -10764,6 +10764,11 @@
(match_operand 1 "memory_operand" "")]
""
{
+#ifdef TARGET_THREAD_SSP_OFFSET
+ rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
+ rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
+ operands[1] = gen_rtx_MEM (Pmode, addr);
+#endif
if (TARGET_64BIT)
emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
else
@@ -10795,6 +10800,11 @@
(match_operand 2 "" "")]
""
{
+#ifdef TARGET_THREAD_SSP_OFFSET
+ rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
+ rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
+ operands[1] = gen_rtx_MEM (Pmode, addr);
+#endif
rs6000_compare_op0 = operands[0];
rs6000_compare_op1 = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, operands[1]),
UNSPEC_SP_TEST);
diff --git a/gcc/configure b/gcc/configure
index f557c2de921..79ed496b99d 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -15514,6 +15514,54 @@ _ACEOF
fi
+# Test for stack protector support in target C library.
+case "$target" in
+ *-*-linux*)
+ echo "$as_me:$LINENO: checking __stack_chk_fail in target GNU C library" >&5
+echo $ECHO_N "checking __stack_chk_fail in target GNU C library... $ECHO_C" >&6
+if test "${gcc_cv_libc_provides_ssp+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ gcc_cv_libc_provides_ssp=no
+ if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
+ if test "x$with_sysroot" = x; then
+ glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-include"
+ elif test "x$with_sysroot" = xyes; then
+ glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-root/usr/include"
+ else
+ glibc_header_dir="${with_sysroot}/usr/include"
+ fi
+ else
+ glibc_header_dir=/usr/include
+ fi
+ # glibc 2.4 and later provides __stack_chk_fail and
+ # either __stack_chk_guard, or TLS access to stack guard canary.
+ if test -f $glibc_header_dir/features.h \
+ && $EGREP '^[ ]*#[ ]*define[ ]+__GNU_LIBRARY__[ ]+([1-9][0-9]|[6-9])' \
+ $glibc_header_dir/features.h > /dev/null; then
+ if $EGREP '^[ ]*#[ ]*define[ ]+__GLIBC__[ ]+([1-9][0-9]|[3-9])' \
+ $glibc_header_dir/features.h > /dev/null; then
+ gcc_cv_libc_provides_ssp=yes
+ elif $EGREP '^[ ]*#[ ]*define[ ]+__GLIBC__[ ]+2' \
+ $glibc_header_dir/features.h > /dev/null \
+ && $EGREP '^[ ]*#[ ]*define[ ]+__GLIBC_MINOR__[ ]+([1-9][0-9]|[4-9])' \
+ $glibc_header_dir/features.h > /dev/null; then
+ gcc_cv_libc_provides_ssp=yes
+ fi
+ fi
+fi
+echo "$as_me:$LINENO: result: $gcc_cv_libc_provides_ssp" >&5
+echo "${ECHO_T}$gcc_cv_libc_provides_ssp" >&6 ;;
+ *) gcc_cv_libc_provides_ssp=no ;;
+esac
+if test x$gcc_cv_libc_provides_ssp = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TARGET_LIBC_PROVIDES_SSP 1
+_ACEOF
+
+fi
+
# Find out what GC implementation we want, or may, use.
# Check whether --with-gc or --without-gc was given.
diff --git a/gcc/configure.ac b/gcc/configure.ac
index f93d8a35fcb..945162c4356 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2972,6 +2972,45 @@ if test x$with_sysroot = x && test x$host = x$target \
[Define to PREFIX/include if cpp should also search that directory.])
fi
+# Test for stack protector support in target C library.
+case "$target" in
+ *-*-linux*)
+ AC_CACHE_CHECK(__stack_chk_fail in target GNU C library,
+ gcc_cv_libc_provides_ssp,
+ [gcc_cv_libc_provides_ssp=no
+ if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
+ if test "x$with_sysroot" = x; then
+ glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-include"
+ elif test "x$with_sysroot" = xyes; then
+ glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-root/usr/include"
+ else
+ glibc_header_dir="${with_sysroot}/usr/include"
+ fi
+ else
+ glibc_header_dir=/usr/include
+ fi
+ # glibc 2.4 and later provides __stack_chk_fail and
+ # either __stack_chk_guard, or TLS access to stack guard canary.
+ if test -f $glibc_header_dir/features.h \
+ && $EGREP '^@<:@ @:>@*#[ ]*define[ ]+__GNU_LIBRARY__[ ]+([1-9][0-9]|[6-9])' \
+ $glibc_header_dir/features.h > /dev/null; then
+ if $EGREP '^@<:@ @:>@*#[ ]*define[ ]+__GLIBC__[ ]+([1-9][0-9]|[3-9])' \
+ $glibc_header_dir/features.h > /dev/null; then
+ gcc_cv_libc_provides_ssp=yes
+ elif $EGREP '^@<:@ @:>@*#[ ]*define[ ]+__GLIBC__[ ]+2' \
+ $glibc_header_dir/features.h > /dev/null \
+ && $EGREP '^@<:@ @:>@*#[ ]*define[ ]+__GLIBC_MINOR__[ ]+([1-9][0-9]|[4-9])' \
+ $glibc_header_dir/features.h > /dev/null; then
+ gcc_cv_libc_provides_ssp=yes
+ fi
+ fi]) ;;
+ *) gcc_cv_libc_provides_ssp=no ;;
+esac
+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])
+fi
+
# Find out what GC implementation we want, or may, use.
AC_ARG_WITH(gc,
[ --with-gc={page,zone} choose the garbage collection mechanism to use
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 3c9fe32df8f..6ec8e5387e3 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -668,6 +668,14 @@ proper position among the other output files. */
#define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G"
#endif
+#ifndef LINK_SSP_SPEC
+#ifdef TARGET_LIBC_PROVIDES_SSP
+#define LINK_SSP_SPEC "%{fstack-protector:}"
+#else
+#define LINK_SSP_SPEC "%{fstack-protector:-lssp_nonshared -lssp }"
+#endif
+#endif
+
#ifndef LINK_PIE_SPEC
#ifdef HAVE_LD_PIE
#define LINK_PIE_SPEC "%{pie:-pie} "
@@ -689,7 +697,7 @@ proper position among the other output files. */
%{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
%{static:} %{L*} %(mfwrap) %(link_libgcc) %o %(mflib)\
%{fprofile-arcs|fprofile-generate|coverage:-lgcov}\
- %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\
+ %{!nostdlib:%{!nodefaultlibs:%(link_ssp)%(link_gcc_c_sequence)}}\
%{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
#endif
@@ -719,6 +727,7 @@ static const char *cpp_spec = CPP_SPEC;
static const char *cc1_spec = CC1_SPEC;
static const char *cc1plus_spec = CC1PLUS_SPEC;
static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC;
+static const char *link_ssp_spec = LINK_SSP_SPEC;
static const char *asm_spec = ASM_SPEC;
static const char *asm_final_spec = ASM_FINAL_SPEC;
static const char *link_spec = LINK_SPEC;
@@ -1516,6 +1525,7 @@ static struct spec_list static_specs[] =
INIT_STATIC_SPEC ("cc1_options", &cc1_options),
INIT_STATIC_SPEC ("cc1plus", &cc1plus_spec),
INIT_STATIC_SPEC ("link_gcc_c_sequence", &link_gcc_c_sequence_spec),
+ INIT_STATIC_SPEC ("link_ssp", &link_ssp_spec),
INIT_STATIC_SPEC ("endfile", &endfile_spec),
INIT_STATIC_SPEC ("link", &link_spec),
INIT_STATIC_SPEC ("lib", &lib_spec),
diff --git a/gcc/libgcc-std.ver b/gcc/libgcc-std.ver
index d6c182130a7..341cf7a481b 100644
--- a/gcc/libgcc-std.ver
+++ b/gcc/libgcc-std.ver
@@ -252,10 +252,3 @@ GCC_4.0.0 {
__mulxc3
__multc3
}
-
-%inherit GCC_4.1.0 GCC_4.0.0
-GCC_4.1.0 {
- # stack smash handler symbols
- __stack_chk_guard
- __stack_chk_fail
-}
diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c
index a49c8c128f9..3108bff6729 100644
--- a/gcc/libgcc2.c
+++ b/gcc/libgcc2.c
@@ -2015,141 +2015,3 @@ func_ptr __DTOR_LIST__[2];
#endif
#endif /* no INIT_SECTION_ASM_OP and not CTOR_LISTS_DEFINED_EXTERNALLY */
#endif /* L_ctors */
-
-#ifdef L_stack_chk
-#ifndef TARGET_LIBC_PROVIDES_SSP
-
-#ifndef inhibit_libc
-# include <string.h>
-# include <unistd.h>
-# include <fcntl.h>
-# ifdef HAVE_PATHS_H
-# include <paths.h>
-# endif
-# ifndef _PATH_TTY
-# define _PATH_TTY "/dev/tty"
-# endif
-# ifdef HAVE_SYSLOG_H
-# include <syslog.h>
-# endif
-#endif
-
-void *__stack_chk_guard = 0;
-
-static void __attribute__ ((constructor))
-__guard_setup (void)
-{
- unsigned char *p;
-
- if (__stack_chk_guard != 0)
- return;
-
-#ifndef inhibit_libc
- {
- int fd = open ("/dev/urandom", O_RDONLY);
- if (fd != -1)
- {
- ssize_t size = read (fd, &__stack_chk_guard,
- sizeof (__stack_chk_guard));
- close (fd);
- if (size == sizeof(__stack_chk_guard))
- return;
- }
- }
-#endif
-
- /* If a random generator can't be used, the protector switches the guard
- to the "terminator canary". */
- p = (unsigned char *)&__stack_chk_guard;
- p[sizeof(__stack_chk_guard)-1] = 255;
- p[sizeof(__stack_chk_guard)-2] = '\n';
- p[0] = 0;
-}
-
-void
-__stack_chk_fail (void)
-{
-#ifndef inhibit_libc
-# ifdef __GNU_LIBRARY__
- extern char * __progname;
-# else
- static const char __progname[] = "";
-# endif
-
- int fd;
-
- /* Print error message directly to the tty. This avoids Bad Things
- happening if stderr is redirected. */
- fd = open (_PATH_TTY, O_WRONLY);
- if (fd != -1)
- {
- static const char msg1[] = "*** stack smashing detected ***: ";
- static const char msg2[] = " terminated\n";
- size_t progname_len, len;
- char *buf, *p;
-
- progname_len = strlen (__progname);
- len = sizeof(msg1)-1 + progname_len + sizeof(msg2)-1 + 1;
- p = buf = alloca (len);
-
- memcpy (p, msg1, sizeof(msg1)-1);
- p += sizeof(msg1)-1;
- memcpy (p, __progname, progname_len);
- p += progname_len;
- memcpy (p, msg2, sizeof(msg2));
-
- while (len > 0)
- {
- ssize_t wrote = write (fd, buf, len);
- if (wrote < 0)
- break;
- len -= wrote;
- }
- close (fd);
- }
-
-# ifdef HAVE_SYSLOG_H
- /* Only send the error to syslog if there was no tty available. */
- else
- syslog (LOG_CRIT, "stack smashing detected: terminated");
-# endif /* HAVE_SYSLOG_H */
-#endif /* inhibit_libc */
-
- /* Try very hard to exit. Note that signals may be blocked preventing
- the first two options from working. The use of volatile is here to
- prevent optimizers from "knowing" that __builtin_trap is called first,
- and that it doesn't return, and so "obviously" the rest of the code
- is dead. */
- {
- volatile int state;
- for (state = 0; ; state++)
- switch (state)
- {
- case 0:
- __builtin_trap ();
- break;
- case 1:
- *(volatile int *)-1L = 0;
- break;
- case 2:
- _exit (127);
- break;
- }
- }
-}
-#endif /* TARGET_LIBC_PROVIDES_SSP */
-#endif /* L_stack_chk */
-
-#ifdef L_stack_chk_local
-#ifndef TARGET_LIBC_PROVIDES_SSP
-/* Some targets can avoid loading a GP for calls to hidden functions.
- Using this entry point may avoid the load of a GP entirely for the
- function, making the overall code smaller. */
-
-void
-__stack_chk_fail_local (void)
-{
- __stack_chk_fail ();
-}
-#endif /* TARGET_LIBC_PROVIDES_SSP */
-#endif /* L_stack_chk_local */
diff --git a/gcc/libgcc2.h b/gcc/libgcc2.h
index cd1e47e1137..05901d89215 100644
--- a/gcc/libgcc2.h
+++ b/gcc/libgcc2.h
@@ -390,11 +390,6 @@ extern int __parityDI2 (UDWtype);
extern void __enable_execute_stack (void *);
-extern void *__stack_chk_guard;
-extern void __stack_chk_fail (void) __attribute__ ((__noreturn__));
-extern void __stack_chk_fail_local (void)
- __attribute__ ((__noreturn__)) ATTRIBUTE_HIDDEN;
-
#ifndef HIDE_EXPORTS
#pragma GCC visibility pop
#endif
diff --git a/gcc/mklibgcc.in b/gcc/mklibgcc.in
index d2581d55b1e..aa61d41f433 100644
--- a/gcc/mklibgcc.in
+++ b/gcc/mklibgcc.in
@@ -63,7 +63,7 @@ lib2funcs='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
_ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
_popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2
_powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3
- _divxc3 _divtc3 _stack_chk _stack_chk_local'
+ _divxc3 _divtc3'
# Disable SHLIB_LINK if shared libgcc not enabled.
if [ "@enable_shared@" = "no" ]; then