Makefile 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # SPDX-License-Identifier: GPL-2.0
  2. # Copyright (C) 2020 ARM Limited
  3. # preserve CC value from top level Makefile
  4. ifeq ($(CC),cc)
  5. CC := $(CROSS_COMPILE)gcc
  6. endif
  7. CFLAGS += -mbranch-protection=pac-ret
  8. # check if the compiler supports ARMv8.3 and branch protection with PAuth
  9. pauth_cc_support := $(shell if ($(CC) $(CFLAGS) -march=armv8.3-a -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)
  10. ifeq ($(pauth_cc_support),1)
  11. TEST_GEN_PROGS := pac
  12. TEST_GEN_FILES := pac_corruptor.o helper.o
  13. TEST_GEN_PROGS_EXTENDED := exec_target
  14. endif
  15. include ../../lib.mk
  16. ifeq ($(pauth_cc_support),1)
  17. # pac* and aut* instructions are not available on architectures berfore
  18. # ARMv8.3. Therefore target ARMv8.3 wherever they are used directly
  19. $(OUTPUT)/pac_corruptor.o: pac_corruptor.S
  20. $(CC) -c $^ -o $@ $(CFLAGS) -march=armv8.3-a
  21. $(OUTPUT)/helper.o: helper.c
  22. $(CC) -c $^ -o $@ $(CFLAGS) -march=armv8.3-a
  23. # when -mbranch-protection is enabled and the target architecture is ARMv8.3 or
  24. # greater, gcc emits pac* instructions which are not in HINT NOP space,
  25. # preventing the tests from occurring at all. Compile for ARMv8.2 so tests can
  26. # run on earlier targets and print a meaningful error messages
  27. $(OUTPUT)/exec_target: exec_target.c $(OUTPUT)/helper.o
  28. $(CC) $^ -o $@ $(CFLAGS) -march=armv8.2-a
  29. $(OUTPUT)/pac: pac.c $(OUTPUT)/pac_corruptor.o $(OUTPUT)/helper.o
  30. $(CC) $^ -o $@ $(CFLAGS) -march=armv8.2-a
  31. endif