Index: contrib/netbsd-tests/lib/libc/ssp/h_gets.c =================================================================== --- contrib/netbsd-tests/lib/libc/ssp/h_gets.c +++ contrib/netbsd-tests/lib/libc/ssp/h_gets.c @@ -34,6 +34,10 @@ #include #ifdef __FreeBSD__ +#ifdef _FORTIFY_SOURCE +#undef gets +#endif + /* * We want to test the gets() implementation, but cannot simply link against * the gets symbol because it is not in the default version. (We've made it Index: include/ssp/unistd.h =================================================================== --- include/ssp/unistd.h +++ include/ssp/unistd.h @@ -36,8 +36,17 @@ #if __SSP_FORTIFY_LEVEL > 0 __BEGIN_DECLS +#ifdef LIBC +/* + * We call it _read in libc. Not all headers in libc that include unistd.h do + * so between namespace.h/un-namespace.h. + */ +__ssp_redirect0(ssize_t, _read, (int __fd, void *__buf, size_t __len), \ + (__fd, __buf, __len)); +#else __ssp_redirect0(ssize_t, read, (int __fd, void *__buf, size_t __len), \ (__fd, __buf, __len)); +#endif __ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \ char *__restrict __buf, size_t __len), (__path, __buf, __len)); Index: lib/libc/Makefile =================================================================== --- lib/libc/Makefile +++ lib/libc/Makefile @@ -21,6 +21,8 @@ LIBC_ARCH=${MACHINE_CPUARCH} .endif +CFLAGS+=-DLIBC + # All library objects contain FreeBSD revision strings by default; they may be # excluded as a space-saving measure. To produce a library that does # not contain these strings, add -DSTRIP_FBSDID (see ) to CFLAGS Index: lib/libc/amd64/string/bcopy.c =================================================================== --- lib/libc/amd64/string/bcopy.c +++ lib/libc/amd64/string/bcopy.c @@ -6,6 +6,9 @@ __FBSDID("$FreeBSD$"); #include +#ifdef _FORTIFY_SOURCE +#undef bcopy +#endif void bcopy(const void *src, void *dst, size_t len) Index: lib/libc/amd64/string/bzero.c =================================================================== --- lib/libc/amd64/string/bzero.c +++ lib/libc/amd64/string/bzero.c @@ -6,6 +6,9 @@ __FBSDID("$FreeBSD$"); #include +#ifdef _FORTIFY_SOURCE +#undef bzero +#endif void bzero(void *b, size_t len) Index: lib/libc/gen/getcwd.c =================================================================== --- lib/libc/gen/getcwd.c +++ lib/libc/gen/getcwd.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "un-namespace.h" #include "gen-private.h" @@ -55,7 +56,7 @@ extern int __getcwd(char *, size_t); char * -getcwd(char *pt, size_t size) +__ssp_real(getcwd)(char *pt, size_t size) { struct dirent *dp; DIR *dir = NULL; Index: lib/libc/stdio/fgets.c =================================================================== --- lib/libc/stdio/fgets.c +++ lib/libc/stdio/fgets.c @@ -45,6 +45,9 @@ #include "un-namespace.h" #include "local.h" #include "libc_private.h" +#ifdef _FORTIFY_SOURCE +#undef fgets +#endif /* * Read at most n-1 characters from the given file. Index: lib/libc/stdio/gets.c =================================================================== --- lib/libc/stdio/gets.c +++ lib/libc/stdio/gets.c @@ -44,6 +44,9 @@ #include "un-namespace.h" #include "libc_private.h" #include "local.h" +#ifdef _FORTIFY_SOURCE +#undef gets +#endif char * __gets_unsafe(char *buf) Index: lib/libc/stdio/snprintf.c =================================================================== --- lib/libc/stdio/snprintf.c +++ lib/libc/stdio/snprintf.c @@ -50,6 +50,9 @@ #include "xlocale_private.h" #include "local.h" +#ifdef _FORTIFY_SOURCE +#undef snprintf +#endif int snprintf(char * __restrict str, size_t n, char const * __restrict fmt, ...) Index: lib/libc/stdio/sprintf.c =================================================================== --- lib/libc/stdio/sprintf.c +++ lib/libc/stdio/sprintf.c @@ -48,6 +48,9 @@ #include #include "local.h" #include "xlocale_private.h" +#ifdef _FORTIFY_SOURCE +#undef sprintf +#endif int sprintf(char * __restrict str, char const * __restrict fmt, ...) Index: lib/libc/stdio/vsnprintf.c =================================================================== --- lib/libc/stdio/vsnprintf.c +++ lib/libc/stdio/vsnprintf.c @@ -48,6 +48,9 @@ #include #include "local.h" #include "xlocale_private.h" +#ifdef _FORTIFY_SOURCE +#undef vsnprintf +#endif int vsnprintf_l(char * __restrict str, size_t n, locale_t locale, Index: lib/libc/stdio/vsprintf.c =================================================================== --- lib/libc/stdio/vsprintf.c +++ lib/libc/stdio/vsprintf.c @@ -47,6 +47,9 @@ #include #include "local.h" #include "xlocale_private.h" +#ifdef _FORTIFY_SOURCE +#undef vsprintf +#endif int vsprintf_l(char * __restrict str, locale_t locale, Index: lib/libc/string/bcopy.c =================================================================== --- lib/libc/string/bcopy.c +++ lib/libc/string/bcopy.c @@ -52,6 +52,10 @@ */ #if defined(MEMCOPY) || defined(MEMMOVE) #include +#ifdef _FORTIFY_SOURCE +#undef memcpy +#undef memmove +#endif void * #ifdef MEMCOPY @@ -62,6 +66,9 @@ (void *dst0, const void *src0, size_t length) #else #include +#ifdef _FORTIFY_SOURCE +#undef bcopy +#endif void bcopy(const void *src0, void *dst0, size_t length) Index: lib/libc/string/memset.c =================================================================== --- lib/libc/string/memset.c +++ lib/libc/string/memset.c @@ -51,6 +51,9 @@ #define RETURN return #define VAL 0 #define WIDEVAL 0 +#ifdef _FORTIFY_SOURCE +#undef bzero +#endif void bzero(void *dst0, size_t length) @@ -60,6 +63,9 @@ #define RETURN return (dst0) #define VAL c0 #define WIDEVAL c +#ifdef _FORTIFY_SOURCE +#undef memset +#endif void * memset(void *dst0, int c0, size_t length) Index: lib/libc/string/stpcpy.c =================================================================== --- lib/libc/string/stpcpy.c +++ lib/libc/string/stpcpy.c @@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include +#ifdef _FORTIFY_SOURCE +#undef stpcpy +#endif char * stpcpy(char * __restrict to, const char * __restrict from) Index: lib/libc/string/stpncpy.c =================================================================== --- lib/libc/string/stpncpy.c +++ lib/libc/string/stpncpy.c @@ -30,6 +30,9 @@ __FBSDID("$FreeBSD$"); #include +#ifdef _FORTIFY_SOURCE +#undef stpncpy +#endif char * stpncpy(char * __restrict dst, const char * __restrict src, size_t n) Index: lib/libc/string/strcat.c =================================================================== --- lib/libc/string/strcat.c +++ lib/libc/string/strcat.c @@ -36,6 +36,9 @@ __FBSDID("$FreeBSD$"); #include +#ifdef _FORTIFY_SOURCE +#undef strcat +#endif char * strcat(char * __restrict s, const char * __restrict append) Index: lib/libc/string/strncat.c =================================================================== --- lib/libc/string/strncat.c +++ lib/libc/string/strncat.c @@ -39,6 +39,9 @@ __FBSDID("$FreeBSD$"); #include +#ifdef _FORTIFY_SOURCE +#undef strncat +#endif /* * Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes Index: lib/libc/sys/read.c =================================================================== --- lib/libc/sys/read.c +++ lib/libc/sys/read.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "libc_private.h" __weak_reference(__sys_read, __read); Index: sys/sys/cdefs.h =================================================================== --- sys/sys/cdefs.h +++ sys/sys/cdefs.h @@ -631,6 +631,16 @@ #define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) #endif +#if !defined(_STANDALONE) && !defined(_KERNEL) +#if defined(__GNUC__) || defined(__PCC__) +#define __RENAME(x) __asm(__STRING(x)) +#else +#error "No function renaming possible" +#endif /* __GNUC__ */ +#else /* _STANDALONE || _KERNEL */ +#define __RENAME(x) no renaming in kernel/standalone environment +#endif + /*- * The following definitions are an extension of the behavior originally * implemented in , but with a different level of granularity.