Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 # Copyright (C) 2020 ARM Limited
0003 
0004 # preserve CC value from top level Makefile
0005 ifeq ($(CC),cc)
0006 CC := $(CROSS_COMPILE)gcc
0007 endif
0008 
0009 CFLAGS += -mbranch-protection=pac-ret
0010 # check if the compiler supports ARMv8.3 and branch protection with PAuth
0011 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)
0012 
0013 ifeq ($(pauth_cc_support),1)
0014 TEST_GEN_PROGS := pac
0015 TEST_GEN_FILES := pac_corruptor.o helper.o
0016 TEST_GEN_PROGS_EXTENDED := exec_target
0017 endif
0018 
0019 include ../../lib.mk
0020 
0021 ifeq ($(pauth_cc_support),1)
0022 # pac* and aut* instructions are not available on architectures berfore
0023 # ARMv8.3. Therefore target ARMv8.3 wherever they are used directly
0024 $(OUTPUT)/pac_corruptor.o: pac_corruptor.S
0025         $(CC) -c $^ -o $@ $(CFLAGS) -march=armv8.3-a
0026 
0027 $(OUTPUT)/helper.o: helper.c
0028         $(CC) -c $^ -o $@ $(CFLAGS) -march=armv8.3-a
0029 
0030 # when -mbranch-protection is enabled and the target architecture is ARMv8.3 or
0031 # greater, gcc emits pac* instructions which are not in HINT NOP space,
0032 # preventing the tests from occurring at all. Compile for ARMv8.2 so tests can
0033 # run on earlier targets and print a meaningful error messages
0034 $(OUTPUT)/exec_target: exec_target.c $(OUTPUT)/helper.o
0035         $(CC) $^ -o $@ $(CFLAGS) -march=armv8.2-a
0036 
0037 $(OUTPUT)/pac: pac.c $(OUTPUT)/pac_corruptor.o $(OUTPUT)/helper.o
0038         $(CC) $^ -o $@ $(CFLAGS) -march=armv8.2-a
0039 endif