xref: /freebsd/lib/libc/tests/ssp/Makefile (revision cddbc3b40812213ff00041f79174cac0be360a2a)
1# $FreeBSD$
2
3.include <bsd.own.mk>
4
5NO_WERROR=
6WARNS?=	2
7
8CFLAGS.h_raw+=	-fstack-protector-all -Wstack-protector
9.if ${COMPILER_TYPE} == "clang"
10CFLAGS.h_raw+=	-fsanitize=bounds
11.elif ${COMPILER_TYPE} == "gcc"
12CFLAGS.h_raw+=	--param ssp-buffer-size=1
13LDADD+=	-lssp
14.endif
15
16NETBSD_ATF_TESTS_SH=	ssp_test
17
18BINDIR=		${TESTSDIR}
19
20PROGS=		h_fgets
21PROGS+=		h_gets
22PROGS+=		h_getcwd
23PROGS+=		h_memcpy
24PROGS+=		h_memmove
25PROGS+=		h_memset
26# This testcase doesn't run properly when not compiled with -fsantize=bounds
27# with clang, which is currently contingent on a compiler_rt update
28#
29# XXX: the h_raw/h_read testcases don't cause a SIGABRT with in-tree gcc right
30# now on amd64 when it trips the stack bounds specified in t_ssp.sh . This
31# probably needs to be fixed as it's currently hardcoded.
32#
33# sanitizer is not tested or supported for ARM right now. sbruno
34.if ${COMPILER_TYPE} == "clang" && !defined(_SKIP_BUILD) && \
35    (!defined(_RECURSING_PROGS) || ${PROG} == "h_raw")
36.if !defined(_CLANG_RESOURCE_DIR)
37_CLANG_RESOURCE_DIR!=	${CC:N${CCACHE_BIN}} -print-resource-dir
38.export _CLANG_RESOURCE_DIR
39.endif
40_libclang_rt_arch=	${MACHINE_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}
41_libclang_rt_ubsan=	${_CLANG_RESOURCE_DIR}/lib/freebsd/libclang_rt.ubsan_standalone-${_libclang_rt_arch}.a
42.if exists(${_libclang_rt_ubsan})
43PROGS+=		h_raw
44.endif
45.endif
46PROGS+=		h_read
47PROGS+=		h_readlink
48PROGS+=		h_snprintf
49PROGS+=		h_sprintf
50PROGS+=		h_stpcpy
51PROGS+=		h_stpncpy
52PROGS+=		h_strcat
53PROGS+=		h_strcpy
54PROGS+=		h_strncat
55PROGS+=		h_strncpy
56PROGS+=		h_vsnprintf
57PROGS+=		h_vsprintf
58
59.include "../Makefile.netbsd-tests"
60
61.include <bsd.test.mk>
62