Makefile 1.9 KB

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