Commit 77008252 by Jakub Jelinek Committed by Jakub Jelinek

Makefile.def (target_modules): Add libssp.

	* 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.

From-SVN: r101531
parent f60d6481
2005-07-02 Jakub Jelinek <jakub@redhat.com>
* Makefile.def (target_modules): Add libssp.
* configure.in (target_libraries): Add target-libssp.
* configure: Rebuilt.
* Makefile.in: Rebuilt.
2005-07-01 Zack Weinberg <zackw@panix.com>
* MAINTAINERS: Change email address. Resign from maintainership.
......
......@@ -115,6 +115,7 @@ host_modules= { module= gnattools; };
target_modules = { module= libstdc++-v3; lib_path=.libs; raw_cxx=true; };
target_modules = { module= libmudflap; lib_path=.libs; };
target_modules = { module= libssp; lib_path=.libs; };
target_modules = { module= newlib; };
target_modules = { module= libgfortran; };
target_modules = { module= libobjc; };
......
......@@ -900,6 +900,7 @@ target_libraries="target-libiberty \
target-newlib \
target-libstdc++-v3 \
target-libmudflap \
target-libssp \
target-libgfortran \
${libgcj} \
target-libobjc \
......
......@@ -147,6 +147,7 @@ target_libraries="target-libiberty \
target-newlib \
target-libstdc++-v3 \
target-libmudflap \
target-libssp \
target-libgfortran \
${libgcj} \
target-libobjc \
......
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
......
......@@ -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
......
......@@ -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")
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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);
......
......@@ -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.
......
......@@ -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
......
......@@ -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),
......
......@@ -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
}
......@@ -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 */
......@@ -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
......
......@@ -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
......
autom4te.cache
2005-07-02 Jakub Jelinek <jakub@redhat.com>
* ALL: First release as more than just a single file.
## Makefile for the toplevel directory of the libssp library.
##
## Copyright (C) 2005
## Free Software Foundation, Inc.
##
AUTOMAKE_OPTIONS = 1.9.5 foreign
ACLOCAL_AMFLAGS = -I .. -I ../config
MAINT_CHARSET = latin1
# May be used by various substitution variables.
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
if LIBSSP_USE_SYMVER
version_arg = -Wl,--version-script=$(srcdir)/ssp.map
version_dep = $(srcdir)/ssp.map
else
version_arg =
version_dep =
endif
AM_CFLAGS = -Wall
toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
nobase_include_HEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h
libssp_la_SOURCES = \
ssp.c gets-chk.c memcpy-chk.c memmove-chk.c mempcpy-chk.c \
memset-chk.c snprintf-chk.c sprintf-chk.c stpcpy-chk.c \
strcat-chk.c strcpy-chk.c strncat-chk.c strncpy-chk.c \
vsnprintf-chk.c vsprintf-chk.c
libssp_la_LIBADD =
libssp_la_DEPENDENCIES = $(version_dep) $(libssp_la_LIBADD)
libssp_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
$(version_arg)
libssp_nonshared_la_SOURCES = \
ssp-local.c
libssp_nonshared_la_CFLAGS = -prefer-pic
libssp_nonshared_la_LIBADD =
libssp_nonshared_la_DEPENDENCIES = $(libssp_nonshared_la_LIBADD)
libssp_nonshared_la_LDFLAGS = -static
# XXX hack alert
# From libffi/Makefile.am
# Work around what appears to be a GNU make bug handling MAKEFLAGS
# values defined in terms of make variables, as is the case for CC and
# friends when we are called from the top level Makefile.
AM_MAKEFLAGS = \
"AR_FLAGS=$(AR_FLAGS)" \
"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
"CFLAGS=$(CFLAGS)" \
"CXXFLAGS=$(CXXFLAGS)" \
"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
"INSTALL=$(INSTALL)" \
"INSTALL_DATA=$(INSTALL_DATA)" \
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
"JC1FLAGS=$(JC1FLAGS)" \
"LDFLAGS=$(LDFLAGS)" \
"LIBCFLAGS=$(LIBCFLAGS)" \
"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
"MAKE=$(MAKE)" \
"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
"PICFLAG=$(PICFLAG)" \
"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
"SHELL=$(SHELL)" \
"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
"exec_prefix=$(exec_prefix)" \
"infodir=$(infodir)" \
"libdir=$(libdir)" \
"prefix=$(prefix)" \
"includedir=$(includedir)" \
"AR=$(AR)" \
"AS=$(AS)" \
"CC=$(CC)" \
"CXX=$(CXX)" \
"LD=$(LD)" \
"LIBCFLAGS=$(LIBCFLAGS)" \
"NM=$(NM)" \
"PICFLAG=$(PICFLAG)" \
"RANLIB=$(RANLIB)" \
"DESTDIR=$(DESTDIR)"
MAKEOVERRIDES=
## ################################################################
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <alloca.h> header file. */
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* __attribute__((visibility ("hidden"))) supported */
#undef HAVE_HIDDEN_VISIBILITY
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `mempcpy' function. */
#undef HAVE_MEMPCPY
/* Define to 1 if you have the <paths.h> header file. */
#undef HAVE_PATHS_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strncat' function. */
#undef HAVE_STRNCAT
/* Define to 1 if you have the `strncpy' function. */
#undef HAVE_STRNCPY
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* vsnprintf is present and works */
#undef HAVE_USABLE_VSNPRINTF
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
This source diff could not be displayed because it is too large. You can view the blob instead.
# Process this file with autoconf to produce a configure script, like so:
# aclocal && autoconf && autoheader && automake
AC_PREREQ(2.59)
AC_INIT(libssp, 1.0)
AC_CONFIG_SRCDIR(ssp.c)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE
AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
AC_ARG_ENABLE(version-specific-runtime-libs,
[ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
[case "$enableval" in
yes) version_specific_libs=yes ;;
no) version_specific_libs=no ;;
*) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
esac],
[version_specific_libs=no])
AC_MSG_RESULT($version_specific_libs)
AM_MAINTAINER_MODE
AC_EXEEXT
AM_ENABLE_MULTILIB(, ..)
target_alias=${target_alias-$host_alias}
AC_SUBST(target_alias)
AC_CONFIG_HEADERS(config.h)
AC_LANG_C
# The same as in boehm-gc and libstdc++. Have to borrow it from there.
# We must force CC to /not/ be precious variables; otherwise
# the wrong, non-multilib-adjusted value will be used in multilibs.
# As a side effect, we have to subst CFLAGS ourselves.
m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
m4_define([_AC_ARG_VAR_PRECIOUS],[])
AC_PROG_CC
m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
AC_SUBST(CFLAGS)
if test "x$GCC" != "xyes"; then
AC_MSG_ERROR([libssp must be built with GCC])
fi
AC_PROG_CPP
AC_MSG_CHECKING([whether -fstack-protector works])
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fstack-protector -Werror"
AC_TRY_COMPILE([
void __attribute__((noinline)) bar (char *x)
{
__builtin_memset (x, 0, 64);
}],[char buf[64]; bar (buf);],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
CFLAGS="$save_CFLAGS"
AC_MSG_CHECKING([whether hidden visibility is supported])
AC_TRY_COMPILE([
void __attribute__((visibility ("hidden"))) bar (void) {}],,
[ssp_hidden=yes],[ssp_hidden=no])
AC_MSG_RESULT($ssp_hidden)
if test x$ssp_hidden = xyes; then
AC_DEFINE([HAVE_HIDDEN_VISIBILITY],[1],[__attribute__((visibility ("hidden"))) supported])
fi
AC_MSG_CHECKING([whether symbol versioning is supported])
cat > conftest.map <<EOF
FOO_1.0 {
global: *foo*; bar; local: *;
};
EOF
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -shared -Wl,--version-script,./conftest.map"
AC_TRY_LINK([int foo;],[],[ssp_use_symver=yes],[ssp_use_symver=no])
LDFLAGS="$save_LDFLAGS"
AC_MSG_RESULT($ssp_use_symver)
AM_CONDITIONAL(LIBSSP_USE_SYMVER, [test "x$ssp_use_symver" = xyes])
AC_CHECK_HEADERS(alloca.h paths.h syslog.h string.h unistd.h fcntl.h stdio.h limits.h)
AC_CHECK_FUNCS(mempcpy strncpy strncat)
AC_MSG_CHECKING([whether vsnprintf is usable])
AC_RUN_IFELSE(AC_LANG_PROGRAM([
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
int foo (char *buf, size_t n, const char *fmt, ...)
{
va_list ap;
int ret;
va_start (ap, fmt);
ret = vsnprintf (buf, n, fmt, ap);
va_end (ap);
return ret;
}],
[char buf@<:@8@:>@; memset (buf, 'A', sizeof (buf));
if (foo (buf, 4, ".%s.", "CDEFG") != 7)
return 1;
return memcmp (buf, ".CD\0AAAA", sizeof (buf)) != 0;]),
[ssp_have_usable_vsnprintf=define],
[ssp_have_usable_vsnprintf=undef],
[ssp_have_usable_vsnprintf=undef])
if test "x$ssp_have_usable_vsnprintf" = xdefine; then
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_USABLE_VSNPRINTF],[1],[vsnprintf is present and works])
else
AC_MSG_RESULT(no)
fi
AC_SUBST(ssp_have_usable_vsnprintf)
AM_PROG_LIBTOOL
AC_SUBST(enable_shared)
AC_SUBST(enable_static)
# Calculate toolexeclibdir
# Also toolexecdir, though it's only used in toolexeclibdir
case ${version_specific_libs} in
yes)
# Need the gcc compiler version to know where to install libraries
# and header files if --enable-version-specific-runtime-libs option
# is selected.
toolexecdir='$(libdir)/gcc/$(target_alias)'
toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
;;
no)
if test -n "$with_cross_host" &&
test x"$with_cross_host" != x"no"; then
# Install a library built with a cross compiler in tooldir, not libdir.
toolexecdir='$(exec_prefix)/$(target_alias)'
toolexeclibdir='$(toolexecdir)/lib'
else
toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
toolexeclibdir='$(libdir)'
fi
multi_os_directory=`$CC -print-multi-os-directory`
case $multi_os_directory in
.) ;; # Avoid trailing /.
*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
esac
;;
esac
AC_SUBST(toolexecdir)
AC_SUBST(toolexeclibdir)
if test ${multilib} = yes; then
multilib_arg="--enable-multilib"
else
multilib_arg=
fi
AC_CONFIG_FILES([Makefile ssp/ssp.h])
AC_OUTPUT
/* Checking gets.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#include <stdarg.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
char *
__gets_chk (char *s, size_t slen)
{
char *ret, *buf;
if (slen >= (size_t) INT_MAX)
return gets (s);
if (slen <= 8192)
buf = alloca (slen + 1);
else
buf = malloc (slen + 1);
if (buf == NULL)
return gets (s);
ret = fgets (buf, (int) (slen + 1), stdin);
if (ret != NULL)
{
size_t len = strlen (buf);
if (len > 0 && buf[len - 1] == '\n')
--len;
if (len == slen)
__chk_fail ();
memcpy (s, buf, len);
s[len] = '\0';
ret = s;
}
if (slen > 8192)
free (buf);
return ret;
}
# This file is used to maintain libtool version info for libssp. See
# the libtool manual to understand the meaning of the fields. This is
# a separate file so that version updates don't involve re-running
# automake.
# CURRENT:REVISION:AGE
0:0:0
/* Checking memcpy.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
void *
__memcpy_chk (void *__restrict__ dest, const void *__restrict__ src,
size_t len, size_t slen)
{
if (len > slen)
__chk_fail ();
return memcpy (dest, src, len);
}
/* Checking memmove.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
#ifdef HAVE_MEMPCPY
void *
__memmove_chk (void *dest, const void *src, size_t len, size_t slen)
{
if (len > slen)
__chk_fail ();
return memmove (dest, src, len);
}
#endif
/* Checking mempcpy.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
#ifdef HAVE_MEMPCPY
void *
__mempcpy_chk (void *__restrict__ dest, const void *__restrict__ src,
size_t len, size_t slen)
{
if (len > slen)
__chk_fail ();
return memcpy (dest, src, len) + len;
}
#endif
/* Checking memset.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
void *
__memset_chk (void *dest, int val, size_t len, size_t slen)
{
if (len > slen)
__chk_fail ();
return memset (dest, val, len);
}
/* Checking snprintf.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#include <stdarg.h>
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
#ifdef HAVE_USABLE_VSNPRINTF
int
__snprintf_chk (char *s, size_t n, int flags __attribute__((unused)),
size_t slen, const char *format, ...)
{
va_list arg;
int done;
if (n > slen)
__chk_fail ();
va_start (arg, format);
done = vsnprintf (s, n, format, arg);
va_end (arg);
return done;
}
#endif
/* Checking sprintf.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#include <stdarg.h>
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
#ifdef HAVE_USABLE_VSNPRINTF
int
__sprintf_chk (char *s, int flags __attribute__((unused)),
size_t slen, const char *format, ...)
{
va_list arg;
int done;
va_start (arg, format);
if (slen > (size_t) INT_MAX)
done = vsprintf (s, format, arg);
else
{
done = vsnprintf (s, slen, format, arg);
if (done >= 0 && (size_t) done >= slen)
__chk_fail ();
}
va_end (arg);
return done;
}
#endif
/* Stack protector support.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
extern void __stack_chk_fail (void);
/* 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. */
#ifdef HAVE_HIDDEN_VISIBILITY
void
__attribute__((visibility ("hidden")))
__stack_chk_fail_local (void)
{
__stack_chk_fail ();
}
#endif
/* Stack protector support.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#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
void *__stack_chk_guard = 0;
static void __attribute__ ((constructor))
__guard_setup (void)
{
unsigned char *p;
int fd;
if (__stack_chk_guard != 0)
return;
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) && __stack_chk_guard != 0)
return;
}
/* 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;
}
static void
fail (const char *msg1, size_t msg1len, const char *msg3)
{
#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 msg2[] = " terminated\n";
size_t progname_len, len;
char *buf, *p;
progname_len = strlen (__progname);
len = msg1len + progname_len + sizeof(msg2)-1 + 1;
p = buf = alloca (len);
memcpy (p, msg1, msg1len);
p += msg1len;
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;
buf += wrote;
len -= wrote;
}
close (fd);
}
#ifdef HAVE_SYSLOG_H
/* Only send the error to syslog if there was no tty available. */
else
syslog (LOG_CRIT, msg3);
#endif /* HAVE_SYSLOG_H */
/* 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;
}
}
}
void
__stack_chk_fail (void)
{
const char *msg = "*** stack smashing detected ***: ";
fail (msg, strlen (msg), "stack smashing detected: terminated");
}
void
__chk_fail (void)
{
const char *msg = "*** buffer overflow detected ***: ";
fail (msg, strlen (msg), "buffer overflow detected: terminated");
}
#ifdef HAVE_HIDDEN_VISIBILITY
void
__attribute__((visibility ("hidden")))
__stack_chk_fail_local (void)
{
__stack_chk_fail ();
}
#endif
LIBSSP_1.0 {
global:
__stack_chk_fail; __stack_chk_guard; __chk_fail;
__gets_chk; __memcpy_chk; __memmove_chk; __mempcpy_chk; __memset_chk;
__snprintf_chk; __sprintf_chk; __stpcpy_chk; __strcat_chk; __strcpy_chk;
__strncat_chk; __strncpy_chk; __vsnprintf_chk; __vsprintf_chk;
local:
*;
};
/* Object size checking support macros.
Copyright (C) 2004, 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#ifndef _SSP_H
#define _SSP_H 1
#if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 \
&& defined __GNUC__ \
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) \
&& !defined __cplusplus
# if _FORTIFY_SOURCE == 1
# define __SSP_FORTIFY_LEVEL 1
# elif _FORTIFY_SOURCE > 1
# define __SSP_FORTIFY_LEVEL 2
# endif
#endif
#if __SSP_FORTIFY_LEVEL > 0
# include <stddef.h>
# define __ssp_bos(ptr) __builtin_object_size (ptr, __SSP_FORTIFY_LEVEL > 1)
# define __ssp_bos0(ptr) __builtin_object_size (ptr, 0)
# define __SSP_REDIRECT(name, proto, alias) \
name proto __asm__ (__SSP_ASMNAME (#alias))
# define __SSP_ASMNAME(cname) __SSP_ASMNAME2 (__USER_LABEL_PREFIX__, cname)
# define __SSP_ASMNAME2(prefix, cname) __SSP_ASMNAME3 (prefix) cname
# define __SSP_ASMNAME3(prefix) #prefix
# @ssp_have_usable_vsnprintf@ __SSP_HAVE_VSNPRINTF
extern void __chk_fail (void) __attribute__((__noreturn__));
#endif
#endif /* _SSP_H */
/* Checking macros for stdio functions.
Copyright (C) 2004, 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#ifndef _SSP_STDIO_H
#define _SSP_STDIO_H 1
#include <ssp.h>
#include_next <stdio.h>
#if __SSP_FORTIFY_LEVEL > 0
#include <stdarg.h>
#undef sprintf
#undef vsprintf
#undef snprintf
#undef vsnprintf
#undef gets
#undef fgets
extern int __sprintf_chk (char *__restrict__ __s, int __flag, size_t __slen,
__const char *__restrict__ __format, ...);
extern int __vsprintf_chk (char *__restrict__ __s, int __flag, size_t __slen,
__const char *__restrict__ __format,
va_list __ap);
#define sprintf(str, ...) \
__builtin___sprintf_chk (str, 0, __ssp_bos (str), \
__VA_ARGS__)
#define vsprintf(str, fmt, ap) \
__builtin___vsprintf_chk (str, 0, __ssp_bos (str), fmt, ap)
extern int __snprintf_chk (char *__restrict__ __s, size_t __n, int __flag,
size_t __slen, __const char *__restrict__ __format,
...);
extern int __vsnprintf_chk (char *__restrict__ __s, size_t __n, int __flag,
size_t __slen, __const char *__restrict__ __format,
va_list __ap);
#define snprintf(str, len, ...) \
__builtin___snprintf_chk (str, len, 0, __ssp_bos (str), __VA_ARGS__)
#define vsnprintf(str, len, fmt, ap) \
__builtin___vsnprintf_chk (str, len, 0, __ssp_bos (str), fmt, ap)
extern char *__gets_chk (char *__str, size_t);
extern char *__SSP_REDIRECT (__gets_alias, (char *__str), gets);
extern inline __attribute__((__always_inline__)) char *
gets (char *__str)
{
if (__ssp_bos (__str) != (size_t) -1)
return __gets_chk (__str, __ssp_bos (__str));
return __gets_alias (__str);
}
extern char *__SSP_REDIRECT (__fgets_alias,
(char *__restrict__ __s, int __n,
FILE *__restrict__ __stream), fgets);
extern inline __attribute__((__always_inline__)) char *
fgets (char *__restrict__ __s, int __n, FILE *__restrict__ __stream)
{
if (__ssp_bos (__s) != (size_t) -1 && (size_t) __n > __ssp_bos (__s))
__chk_fail ();
return __fgets_alias (__s, __n, __stream);
}
#endif /* __SSP_FORTIFY_LEVEL > 0 */
#endif /* _SSP_STDIO_H */
/* Checking macros for string functions.
Copyright (C) 2004, 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#ifndef _SSP_STRING_H
#define _SSP_STRING_H 1
#include <ssp.h>
#include_next <string.h>
#if __SSP_FORTIFY_LEVEL > 0
#undef memcpy
#undef memmove
#undef memset
#undef strcat
#undef strcpy
#undef strncat
#undef strncpy
#undef mempcpy
#undef stpcpy
#undef bcopy
#undef bzero
#define memcpy(dest, src, len) \
((__ssp_bos0 (dest) != (size_t) -1) \
? __builtin___memcpy_chk (dest, src, len, __ssp_bos0 (dest)) \
: __memcpy_ichk (dest, src, len))
static inline __attribute__((__always_inline__)) void *
__memcpy_ichk (void *__restrict__ __dest, const void *__restrict__ __src,
size_t __len)
{
return __builtin___memcpy_chk (__dest, __src, __len, __ssp_bos0 (__dest));
}
#define memmove(dest, src, len) \
((__ssp_bos0 (dest) != (size_t) -1) \
? __builtin___memmove_chk (dest, src, len, __ssp_bos0 (dest)) \
: __memmove_ichk (dest, src, len))
static inline __attribute__((__always_inline__)) void *
__memmove_ichk (void *__dest, const void *__src, size_t __len)
{
return __builtin___memmove_chk (__dest, __src, __len, __ssp_bos0 (__dest));
}
#define mempcpy(dest, src, len) \
((__ssp_bos0 (dest) != (size_t) -1) \
? __builtin___mempcpy_chk (dest, src, len, __ssp_bos0 (dest)) \
: __mempcpy_ichk (dest, src, len))
static inline __attribute__((__always_inline__)) void *
__mempcpy_ichk (void *__restrict__ __dest, const void *__restrict__ __src,
size_t __len)
{
return __builtin___mempcpy_chk (__dest, __src, __len, __ssp_bos0 (__dest));
}
#define memset(dest, ch, len) \
((__ssp_bos0 (dest) != (size_t) -1) \
? __builtin___memset_chk (dest, ch, len, __ssp_bos0 (dest)) \
: __memset_ichk (dest, ch, len))
static inline __attribute__((__always_inline__)) void *
__memset_ichk (void *__dest, int __ch, size_t __len)
{
return __builtin___memset_chk (__dest, __ch, __len, __ssp_bos0 (__dest));
}
#define bcopy(src, dest, len) ((void) \
((__ssp_bos0 (dest) != (size_t) -1) \
? __builtin___memmove_chk (dest, src, len, __ssp_bos0 (dest)) \
: __memmove_ichk (dest, src, len)))
#define bzero(dest, len) ((void) \
((__ssp_bos0 (dest) != (size_t) -1) \
? __builtin___memset_chk (dest, '\0', len, __ssp_bos0 (dest)) \
: __memset_ichk (dest, '\0', len)))
#define strcpy(dest, src) \
((__ssp_bos (dest) != (size_t) -1) \
? __builtin___strcpy_chk (dest, src, __ssp_bos (dest)) \
: __strcpy_ichk (dest, src))
static inline __attribute__((__always_inline__)) char *
__strcpy_ichk (char *__restrict__ __dest, const char *__restrict__ __src)
{
return __builtin___strcpy_chk (__dest, __src, __ssp_bos (__dest));
}
#define stpcpy(dest, src) \
((__ssp_bos (dest) != (size_t) -1) \
? __builtin___stpcpy_chk (dest, src, __ssp_bos (dest)) \
: __stpcpy_ichk (dest, src))
static inline __attribute__((__always_inline__)) char *
__stpcpy_ichk (char *__restrict__ __dest, const char *__restrict__ __src)
{
return __builtin___stpcpy_chk (__dest, __src, __ssp_bos (__dest));
}
#define strncpy(dest, src, len) \
((__ssp_bos (dest) != (size_t) -1) \
? __builtin___strncpy_chk (dest, src, len, __ssp_bos (dest)) \
: __strncpy_ichk (dest, src, len))
static inline __attribute__((__always_inline__)) char *
__strncpy_ichk (char *__restrict__ __dest, const char *__restrict__ __src,
size_t __len)
{
return __builtin___strncpy_chk (__dest, __src, __len, __ssp_bos (__dest));
}
#define strcat(dest, src) \
((__ssp_bos (dest) != (size_t) -1) \
? __builtin___strcat_chk (dest, src, __ssp_bos (dest)) \
: __strcat_ichk (dest, src))
static inline __attribute__((__always_inline__)) char *
__strcat_ichk (char *__restrict__ __dest, const char *__restrict__ __src)
{
return __builtin___strcat_chk (__dest, __src, __ssp_bos (__dest));
}
#define strncat(dest, src, len) \
((__ssp_bos (dest) != (size_t) -1) \
? __builtin___strncat_chk (dest, src, len, __ssp_bos (dest)) \
: __strncat_ichk (dest, src, len))
static inline __attribute__((__always_inline__)) char *
__strncat_ichk (char *__restrict__ __dest, const char *__restrict__ __src,
size_t __len)
{
return __builtin___strncat_chk (__dest, __src, __len, __ssp_bos (__dest));
}
#endif /* __SSP_FORTIFY_LEVEL > 0 */
#endif /* _SSP_STRING_H */
/* Checking macros for unistd functions.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#ifndef _SSP_UNISTD_H
#define _SSP_UNISTD_H 1
#include <ssp.h>
#include_next <unistd.h>
#if __SSP_FORTIFY_LEVEL > 0
#undef read
#undef readlink
#undef getcwd
extern ssize_t __SSP_REDIRECT (__read_alias, (int __fd, void *__buf,
size_t __nbytes), read);
extern inline __attribute__((__always_inline__)) ssize_t
read (int __fd, void *__buf, size_t __nbytes)
{
if (__ssp_bos0 (__buf) != (size_t) -1 && __nbytes > __ssp_bos0 (__buf))
__chk_fail ();
return __read_alias (__fd, __buf, __nbytes);
}
extern int __SSP_REDIRECT (__readlink_alias,
(const char *__restrict__ __path,
char *__restrict__ __buf, size_t __len),
readlink);
extern inline __attribute__((__always_inline__)) int
readlink (const char *__restrict__ __path, char *__restrict__ __buf,
size_t __len)
{
if (__ssp_bos (__buf) != (size_t) -1 && __len > __ssp_bos (__buf))
__chk_fail ();
return __readlink_alias (__path, __buf, __len);
}
extern char *__SSP_REDIRECT (__getcwd_alias,
(char *__buf, size_t __size), getcwd);
extern inline __attribute__((__always_inline__)) char *
getcwd (char *__buf, size_t __size)
{
if (__ssp_bos (__buf) != (size_t) -1 && __size > __ssp_bos (__buf))
__chk_fail ();
return __getcwd_alias (__buf, __size);
}
#endif /* __SSP_FORTIFY_LEVEL > 0 */
#endif /* _SSP_UNISTD_H */
/* Checking stpcpy.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
char *
__stpcpy_chk (char *__restrict__ dest, const char *__restrict__ src,
size_t slen)
{
size_t len = strlen (src);
if (len >= slen)
__chk_fail ();
return memcpy (dest, src, len + 1) + len;
}
/* Checking strcat.
Copyright (C) 1991, 1997, 2003, 2004, 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
char *
__strcat_chk (char *__restrict__ dest, const char *__restrict__ src,
size_t slen)
{
char *s1 = dest;
const char *s2 = src;
char c;
do
{
if (slen-- == 0)
__chk_fail ();
c = *s1++;
}
while (c != '\0');
++slen;
s1 -= 2;
do
{
if (slen-- == 0)
__chk_fail ();
c = *s2++;
*++s1 = c;
}
while (c != '\0');
return dest;
}
/* Checking strcpy.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
char *
__strcpy_chk (char *__restrict__ dest, const char *__restrict__ src,
size_t slen)
{
size_t len = strlen (src);
if (len >= slen)
__chk_fail ();
return memcpy (dest, src, len + 1);
}
/* Checking strncat.
Copyright (C) 1991, 1997, 2003, 2004, 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
char *
__strncat_chk (char *__restrict__ dest, const char *__restrict__ src,
size_t n, size_t slen)
{
char c;
char *s = dest;
do
{
if (slen-- == 0)
__chk_fail ();
c = *dest++;
}
while (c != '\0');
++slen;
dest -= 2;
if (n >= 4)
{
size_t n4 = n >> 2;
do
{
if (slen-- == 0)
__chk_fail ();
c = *src++;
*++dest = c;
if (c == '\0')
return s;
if (slen-- == 0)
__chk_fail ();
c = *src++;
*++dest = c;
if (c == '\0')
return s;
if (slen-- == 0)
__chk_fail ();
c = *src++;
*++dest = c;
if (c == '\0')
return s;
if (slen-- == 0)
__chk_fail ();
c = *src++;
*++dest = c;
if (c == '\0')
return s;
if (slen-- == 0)
__chk_fail ();
c = *src++;
*++dest = c;
if (c == '\0')
return s;
} while (--n4 > 0);
n &= 3;
}
while (n > 0)
{
if (slen-- == 0)
__chk_fail ();
c = *src++;
*++dest = c;
if (c == '\0')
return s;
n--;
}
if (c != '\0')
{
if (slen-- == 0)
__chk_fail ();
*++dest = '\0';
}
return s;
}
/* Checking strncpy.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
#ifdef HAVE_STRNCPY
char *
__strncpy_chk (char *__restrict__ dest, const char *__restrict__ src,
size_t len, size_t slen)
{
if (len > slen)
__chk_fail ();
return strncpy (dest, src, len);
}
#endif
/* Checking vsnprintf.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#include <stdarg.h>
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
#ifdef HAVE_USABLE_VSNPRINTF
int
__vsnprintf_chk (char *s, size_t n, int flags __attribute__((unused)),
size_t slen, const char *format, va_list arg)
{
if (n > slen)
__chk_fail ();
return vsnprintf (s, n, format, arg);
}
#endif
/* Checking vsprintf.
Copyright (C) 2005 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.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
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. */
/* As a special exception, if you link this library with files compiled with
GCC to produce an executable, this does not cause the resulting executable
to be covered by the GNU General Public License. This exception does not
however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */
#include "config.h"
#include <ssp/ssp.h>
#include <stdarg.h>
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif
extern void __chk_fail (void) __attribute__((__noreturn__));
#ifdef HAVE_USABLE_VSNPRINTF
int
__vsprintf_chk (char *s, int flags __attribute__((unused)),
size_t slen, const char *format, va_list arg)
{
int done;
if (slen > (size_t) INT_MAX)
done = vsprintf (s, format, arg);
else
{
done = vsnprintf (s, slen, format, arg);
if (done >= 0 && (size_t) done >= slen)
__chk_fail ();
}
return done;
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment