1314bcbf0SMark Brown# SPDX-License-Identifier: GPL-2.0 2314bcbf0SMark Brown 3314bcbf0SMark BrownTEST_GEN_PROGS := btitest nobtitest 4314bcbf0SMark Brown 5314bcbf0SMark Brown# These tests are built as freestanding binaries since otherwise BTI 6314bcbf0SMark Brown# support in ld.so is required which is not currently widespread; when 7314bcbf0SMark Brown# it is available it will still be useful to test this separately as the 8314bcbf0SMark Brown# cases for statically linked and dynamically lined binaries are 9314bcbf0SMark Brown# slightly different. 10314bcbf0SMark Brown 119f93c2e0SMark BrownCFLAGS_NOBTI = -mbranch-protection=none -DBTI=0 12314bcbf0SMark BrownCFLAGS_BTI = -mbranch-protection=standard -DBTI=1 13314bcbf0SMark Brown 14314bcbf0SMark BrownCFLAGS_COMMON = -ffreestanding -Wall -Wextra $(CFLAGS) 15314bcbf0SMark Brown 16314bcbf0SMark BrownBTI_CC_COMMAND = $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -c -o $@ $< 17314bcbf0SMark BrownNOBTI_CC_COMMAND = $(CC) $(CFLAGS_NOBTI) $(CFLAGS_COMMON) -c -o $@ $< 18314bcbf0SMark Brown 19*e08302eeSAndre Przywara$(OUTPUT)/%-bti.o: %.c 20314bcbf0SMark Brown $(BTI_CC_COMMAND) 21314bcbf0SMark Brown 22*e08302eeSAndre Przywara$(OUTPUT)/%-bti.o: %.S 23314bcbf0SMark Brown $(BTI_CC_COMMAND) 24314bcbf0SMark Brown 25*e08302eeSAndre Przywara$(OUTPUT)/%-nobti.o: %.c 26314bcbf0SMark Brown $(NOBTI_CC_COMMAND) 27314bcbf0SMark Brown 28*e08302eeSAndre Przywara$(OUTPUT)/%-nobti.o: %.S 29314bcbf0SMark Brown $(NOBTI_CC_COMMAND) 30314bcbf0SMark Brown 31314bcbf0SMark BrownBTI_OBJS = \ 32*e08302eeSAndre Przywara $(OUTPUT)/test-bti.o \ 33*e08302eeSAndre Przywara $(OUTPUT)/signal-bti.o \ 34*e08302eeSAndre Przywara $(OUTPUT)/start-bti.o \ 35*e08302eeSAndre Przywara $(OUTPUT)/syscall-bti.o \ 36*e08302eeSAndre Przywara $(OUTPUT)/system-bti.o \ 37*e08302eeSAndre Przywara $(OUTPUT)/teststubs-bti.o \ 38*e08302eeSAndre Przywara $(OUTPUT)/trampoline-bti.o 39*e08302eeSAndre Przywara$(OUTPUT)/btitest: $(BTI_OBJS) 40d7a49291SAndre Przywara $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^ 41314bcbf0SMark Brown 42314bcbf0SMark BrownNOBTI_OBJS = \ 43*e08302eeSAndre Przywara $(OUTPUT)/test-nobti.o \ 44*e08302eeSAndre Przywara $(OUTPUT)/signal-nobti.o \ 45*e08302eeSAndre Przywara $(OUTPUT)/start-nobti.o \ 46*e08302eeSAndre Przywara $(OUTPUT)/syscall-nobti.o \ 47*e08302eeSAndre Przywara $(OUTPUT)/system-nobti.o \ 48*e08302eeSAndre Przywara $(OUTPUT)/teststubs-nobti.o \ 49*e08302eeSAndre Przywara $(OUTPUT)/trampoline-nobti.o 50*e08302eeSAndre Przywara$(OUTPUT)/nobtitest: $(NOBTI_OBJS) 51d7a49291SAndre Przywara $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^ 52314bcbf0SMark Brown 53314bcbf0SMark Brown# Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list 54314bcbf0SMark Brown# to account for any OUTPUT target-dirs optionally provided by 55314bcbf0SMark Brown# the toplevel makefile 56314bcbf0SMark Browninclude ../../lib.mk 57