1# SPDX-License-Identifier: GPL-2.0 2 3TEST_GEN_PROGS := btitest nobtitest 4 5PROGS := $(patsubst %,gen/%,$(TEST_GEN_PROGS)) 6 7# These tests are built as freestanding binaries since otherwise BTI 8# support in ld.so is required which is not currently widespread; when 9# it is available it will still be useful to test this separately as the 10# cases for statically linked and dynamically lined binaries are 11# slightly different. 12 13CFLAGS_NOBTI = -DBTI=0 14CFLAGS_BTI = -mbranch-protection=standard -DBTI=1 15 16CFLAGS_COMMON = -ffreestanding -Wall -Wextra $(CFLAGS) 17 18BTI_CC_COMMAND = $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -c -o $@ $< 19NOBTI_CC_COMMAND = $(CC) $(CFLAGS_NOBTI) $(CFLAGS_COMMON) -c -o $@ $< 20 21%-bti.o: %.c 22 $(BTI_CC_COMMAND) 23 24%-bti.o: %.S 25 $(BTI_CC_COMMAND) 26 27%-nobti.o: %.c 28 $(NOBTI_CC_COMMAND) 29 30%-nobti.o: %.S 31 $(NOBTI_CC_COMMAND) 32 33BTI_OBJS = \ 34 test-bti.o \ 35 signal-bti.o \ 36 start-bti.o \ 37 syscall-bti.o \ 38 system-bti.o \ 39 teststubs-bti.o \ 40 trampoline-bti.o 41gen/btitest: $(BTI_OBJS) 42 $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -o $@ $^ 43 44NOBTI_OBJS = \ 45 test-nobti.o \ 46 signal-nobti.o \ 47 start-nobti.o \ 48 syscall-nobti.o \ 49 system-nobti.o \ 50 teststubs-nobti.o \ 51 trampoline-nobti.o 52gen/nobtitest: $(NOBTI_OBJS) 53 $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -o $@ $^ 54 55# Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list 56# to account for any OUTPUT target-dirs optionally provided by 57# the toplevel makefile 58include ../../lib.mk 59 60$(TEST_GEN_PROGS): $(PROGS) 61 cp $(PROGS) $(OUTPUT)/ 62