xref: /freebsd/lib/libc/tests/ssp/Makefile (revision 7fa2f2a62f04f095e1e27ad55aa22a8f59b1df8f)
12f121787SEnji Cooper# $FreeBSD$
22f121787SEnji Cooper
32f121787SEnji Cooper.include <bsd.own.mk>
42f121787SEnji Cooper
5*7fa2f2a6SAlex RichardsonMK_WERROR=	no
62f121787SEnji CooperWARNS?=	2
72f121787SEnji Cooper
82f121787SEnji CooperCFLAGS.h_raw+=	-fstack-protector-all -Wstack-protector
93e7449a3SBrooks Davis.if ${COMPILER_TYPE} == "clang" && ${CC} == "cc"
103e7449a3SBrooks Davis# Only use -fsanitize=bounds when using the in-tree compiler.  Otherwise
113e7449a3SBrooks Davis# we may link to a sanitizer library targeted at a newer kernel/libc.
122f121787SEnji CooperCFLAGS.h_raw+=	-fsanitize=bounds
132f121787SEnji Cooper.elif ${COMPILER_TYPE} == "gcc"
142f121787SEnji CooperCFLAGS.h_raw+=	--param ssp-buffer-size=1
15b1e20a1dSBryan DreweryLDADD+=	-lssp
162f121787SEnji Cooper.endif
172f121787SEnji Cooper
182f121787SEnji CooperNETBSD_ATF_TESTS_SH=	ssp_test
192f121787SEnji Cooper
202f121787SEnji CooperBINDIR=		${TESTSDIR}
212f121787SEnji Cooper
222f121787SEnji CooperPROGS=		h_fgets
232f121787SEnji CooperPROGS+=		h_gets
242f121787SEnji CooperPROGS+=		h_getcwd
252f121787SEnji CooperPROGS+=		h_memcpy
262f121787SEnji CooperPROGS+=		h_memmove
272f121787SEnji CooperPROGS+=		h_memset
2897e4ab09SEnji Cooper# This testcase doesn't run properly when not compiled with -fsantize=bounds
2997e4ab09SEnji Cooper# with clang, which is currently contingent on a compiler_rt update
30ff44c538SEnji Cooper#
31ff44c538SEnji Cooper# XXX: the h_raw/h_read testcases don't cause a SIGABRT with in-tree gcc right
32ff44c538SEnji Cooper# now on amd64 when it trips the stack bounds specified in t_ssp.sh . This
33ff44c538SEnji Cooper# probably needs to be fixed as it's currently hardcoded.
344d871c1eSSean Bruno#
354d871c1eSSean Bruno# sanitizer is not tested or supported for ARM right now. sbruno
36b0bffa3aSBrooks Davis.if ${COMPILER_TYPE} == "clang" && ${CC} == "cc" && !defined(_SKIP_BUILD) && \
37f272627fSBryan Drewery    (!defined(_RECURSING_PROGS) || ${PROG} == "h_raw")
38f272627fSBryan Drewery.if !defined(_CLANG_RESOURCE_DIR)
39f272627fSBryan Drewery_CLANG_RESOURCE_DIR!=	${CC:N${CCACHE_BIN}} -print-resource-dir
40f272627fSBryan Drewery.export _CLANG_RESOURCE_DIR
41f272627fSBryan Drewery.endif
42f272627fSBryan Drewery_libclang_rt_arch=	${MACHINE_ARCH:S/amd64/x86_64/:C/hf$//:S/mipsn32/mips64/}
43f272627fSBryan Drewery_libclang_rt_ubsan=	${_CLANG_RESOURCE_DIR}/lib/freebsd/libclang_rt.ubsan_standalone-${_libclang_rt_arch}.a
44f272627fSBryan Drewery.if exists(${_libclang_rt_ubsan})
452f121787SEnji CooperPROGS+=		h_raw
46ff44c538SEnji Cooper.endif
474d871c1eSSean Bruno.endif
482f121787SEnji CooperPROGS+=		h_read
492f121787SEnji CooperPROGS+=		h_readlink
502f121787SEnji CooperPROGS+=		h_snprintf
512f121787SEnji CooperPROGS+=		h_sprintf
522f121787SEnji CooperPROGS+=		h_stpcpy
532f121787SEnji CooperPROGS+=		h_stpncpy
542f121787SEnji CooperPROGS+=		h_strcat
552f121787SEnji CooperPROGS+=		h_strcpy
562f121787SEnji CooperPROGS+=		h_strncat
572f121787SEnji CooperPROGS+=		h_strncpy
582f121787SEnji CooperPROGS+=		h_vsnprintf
592f121787SEnji CooperPROGS+=		h_vsprintf
602f121787SEnji Cooper
612f121787SEnji Cooper.include "../Makefile.netbsd-tests"
622f121787SEnji Cooper
632f121787SEnji Cooper.include <bsd.test.mk>
64