1314bcbf0SMark Brown# SPDX-License-Identifier: GPL-2.0 2314bcbf0SMark Brown 3314bcbf0SMark BrownTEST_GEN_PROGS := btitest nobtitest 4314bcbf0SMark Brown 5314bcbf0SMark BrownPROGS := $(patsubst %,gen/%,$(TEST_GEN_PROGS)) 6314bcbf0SMark Brown 7314bcbf0SMark Brown# These tests are built as freestanding binaries since otherwise BTI 8314bcbf0SMark Brown# support in ld.so is required which is not currently widespread; when 9314bcbf0SMark Brown# it is available it will still be useful to test this separately as the 10314bcbf0SMark Brown# cases for statically linked and dynamically lined binaries are 11314bcbf0SMark Brown# slightly different. 12314bcbf0SMark Brown 13314bcbf0SMark BrownCFLAGS_NOBTI = -DBTI=0 14314bcbf0SMark BrownCFLAGS_BTI = -mbranch-protection=standard -DBTI=1 15314bcbf0SMark Brown 16314bcbf0SMark BrownCFLAGS_COMMON = -ffreestanding -Wall -Wextra $(CFLAGS) 17314bcbf0SMark Brown 18314bcbf0SMark BrownBTI_CC_COMMAND = $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -c -o $@ $< 19314bcbf0SMark BrownNOBTI_CC_COMMAND = $(CC) $(CFLAGS_NOBTI) $(CFLAGS_COMMON) -c -o $@ $< 20314bcbf0SMark Brown 21314bcbf0SMark Brown%-bti.o: %.c 22314bcbf0SMark Brown $(BTI_CC_COMMAND) 23314bcbf0SMark Brown 24314bcbf0SMark Brown%-bti.o: %.S 25314bcbf0SMark Brown $(BTI_CC_COMMAND) 26314bcbf0SMark Brown 27314bcbf0SMark Brown%-nobti.o: %.c 28314bcbf0SMark Brown $(NOBTI_CC_COMMAND) 29314bcbf0SMark Brown 30314bcbf0SMark Brown%-nobti.o: %.S 31314bcbf0SMark Brown $(NOBTI_CC_COMMAND) 32314bcbf0SMark Brown 33314bcbf0SMark BrownBTI_OBJS = \ 34314bcbf0SMark Brown test-bti.o \ 35314bcbf0SMark Brown signal-bti.o \ 36314bcbf0SMark Brown start-bti.o \ 37314bcbf0SMark Brown syscall-bti.o \ 38314bcbf0SMark Brown system-bti.o \ 39314bcbf0SMark Brown teststubs-bti.o \ 40314bcbf0SMark Brown trampoline-bti.o 41314bcbf0SMark Browngen/btitest: $(BTI_OBJS) 42*d7a49291SAndre Przywara $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^ 43314bcbf0SMark Brown 44314bcbf0SMark BrownNOBTI_OBJS = \ 45314bcbf0SMark Brown test-nobti.o \ 46314bcbf0SMark Brown signal-nobti.o \ 47314bcbf0SMark Brown start-nobti.o \ 48314bcbf0SMark Brown syscall-nobti.o \ 49314bcbf0SMark Brown system-nobti.o \ 50314bcbf0SMark Brown teststubs-nobti.o \ 51314bcbf0SMark Brown trampoline-nobti.o 52314bcbf0SMark Browngen/nobtitest: $(NOBTI_OBJS) 53*d7a49291SAndre Przywara $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^ 54314bcbf0SMark Brown 55314bcbf0SMark Brown# Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list 56314bcbf0SMark Brown# to account for any OUTPUT target-dirs optionally provided by 57314bcbf0SMark Brown# the toplevel makefile 58314bcbf0SMark Browninclude ../../lib.mk 59314bcbf0SMark Brown 60314bcbf0SMark Brown$(TEST_GEN_PROGS): $(PROGS) 61314bcbf0SMark Brown cp $(PROGS) $(OUTPUT)/ 62