Makefile 1.9 KB

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