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