xref: /freebsd/lib/libc/tests/ssp/Makefile (revision e9ac41698b2f322d55ccf9da50a3596edb2c1800)
12f121787SEnji Cooper.include <bsd.own.mk>
22f121787SEnji Cooper
37fa2f2a6SAlex RichardsonMK_WERROR=	no
42f121787SEnji CooperWARNS?=	2
52f121787SEnji Cooper
62f121787SEnji CooperCFLAGS.h_raw+=	-fstack-protector-all -Wstack-protector
7fe525d3fSAlex Richardson.if ${COMPILER_TYPE} == "clang"
8fe525d3fSAlex Richardson# Only use -fsanitize=bounds when using clang. Otherwise we are not able to
9fe525d3fSAlex Richardson# override the sanitizer runtime libraries to be the ones installed on the
10fe525d3fSAlex Richardson# target system.
112f121787SEnji CooperCFLAGS.h_raw+=	-fsanitize=bounds
1299ea6757SBrooks DavisLIBADD+=sys
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
28ff44c538SEnji Cooper# XXX: the h_raw/h_read testcases don't cause a SIGABRT with in-tree gcc right
29ff44c538SEnji Cooper# now on amd64 when it trips the stack bounds specified in t_ssp.sh . This
30ff44c538SEnji Cooper# probably needs to be fixed as it's currently hardcoded.
31fe525d3fSAlex Richardson.if ${COMPILER_TYPE} == "clang" && !defined(_SKIP_BUILD) && \
32*da925fceSMark Johnston    (!defined(_RECURSING_PROGS) || ${PROG} == "h_raw") && \
33*da925fceSMark Johnston    defined(MK_CLANG) && ${MK_CLANG} == "yes"
34fe525d3fSAlex Richardson.include "${SRCTOP}/lib/libclang_rt/compiler-rt-vars.mk"
35fe525d3fSAlex Richardson_libclang_rt_ubsan=	${SYSROOT}${SANITIZER_LIBDIR}/libclang_rt.ubsan_standalone-${CRTARCH}.a
36f272627fSBryan Drewery.if exists(${_libclang_rt_ubsan})
372f121787SEnji CooperPROGS+=		h_raw
38fe525d3fSAlex RichardsonLDADD.h_raw+=	${SANITIZER_LDFLAGS}
39fe525d3fSAlex Richardson.else
40fe525d3fSAlex Richardson.if make(all)
416f6fbfa3SEd Maste.info Could not find runtime library ${_libclang_rt_ubsan}, skipping h_raw
42fe525d3fSAlex Richardson.endif
43ff44c538SEnji Cooper.endif
444d871c1eSSean Bruno.endif
452f121787SEnji CooperPROGS+=		h_read
462f121787SEnji CooperPROGS+=		h_readlink
472f121787SEnji CooperPROGS+=		h_snprintf
482f121787SEnji CooperPROGS+=		h_sprintf
492f121787SEnji CooperPROGS+=		h_stpcpy
502f121787SEnji CooperPROGS+=		h_stpncpy
512f121787SEnji CooperPROGS+=		h_strcat
522f121787SEnji CooperPROGS+=		h_strcpy
532f121787SEnji CooperPROGS+=		h_strncat
542f121787SEnji CooperPROGS+=		h_strncpy
552f121787SEnji CooperPROGS+=		h_vsnprintf
562f121787SEnji CooperPROGS+=		h_vsprintf
572f121787SEnji Cooper
582f121787SEnji Cooper.include "../Makefile.netbsd-tests"
592f121787SEnji Cooper
602f121787SEnji Cooper.include <bsd.test.mk>
61