forked from ilebedev/security_monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
security_monitor.Makefrag
76 lines (58 loc) · 2.66 KB
/
security_monitor.Makefrag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
SECURITY_MONITOR_DIR := $(SANCTUM_DIR)/security_monitor
SM_SRC_DIR := $(SECURITY_MONITOR_DIR)/src
SM_BUILD := $(BUILD_DIR)/security_monitor
S_TRAP_DIR := $(SM_SRC_DIR)/trap_from_untrusted
S_ECALL_DIR := $(S_TRAP_DIR)/ecall_from_s
E_TRAP_DIR := $(SM_SRC_DIR)/trap_from_enclave
E_ECALL_DIR := $(E_TRAP_DIR)/ecall_from_e
TEST_DIR := $(SECURITY_MONITOR_DIR)/test
UNIT_TESTS_DIR := $(TEST_DIR)/unit_tests
TEST_NAMES := $(notdir $(basename $(wildcard $(UNIT_TESTS_DIR)/test_*)))
TEST_ELFS := $(addprefix $(SM_BUILD)/, $(addsuffix .elf, $(HW_TEST_NAMES)))
TEST_TASKS := $(addsuffix .task, $(TEST_NAMES))
TEST_IDPT := $(SM_BUILD)/idpt.bin
SM_INCLUDE := -I $(SM_SRC_DIR) -I $(S_ECALL_DIR) -I $(E_ECALL_DIR) -I $(COMMON_DIR)
TEST_INCLUDE := -I $(SM_BUILD) -I $(TEST_DIR)
CFLAGS += $(SM_INCLUDE) $(TEST_INCLUDE)
ASFLAGS := $(CFLAGS)
SM_SRC := $(SM_SRC_DIR)/init.S $(SM_SRC_DIR)/init/init.c $(SM_SRC_DIR)/sm_stack.S $(S_TRAP_DIR)/entry.S $(E_TRAP_DIR)/entry.S $(SM_SRC_DIR)/sm_util/sm_util.c
SM_SRC += $(wildcard $(S_TRAP_DIR)/trap_*.S)
SM_SRC += $(wildcard $(S_TRAP_DIR)/trap_hacks.c)
SM_SRC += $(wildcard $(S_TRAP_DIR)/interrupt_*.S)
SM_SRC += $(wildcard $(S_ECALL_DIR)/ecall_s_*.c)
SM_SRC += $(wildcard $(E_TRAP_DIR)/trap_*.S)
SM_SRC += $(wildcard $(E_TRAP_DIR)/interrupt_*.S)
SM_SRC += $(wildcard $(E_ECALL_DIR)/ecall_e_*.c)
SM_SRC += $(COMMON_DIR)/clib/memcpy.c
SM_SRC += $(COMMON_DIR)/clib/memset.c
SM_SRC += $(COMMON_DIR)/sha3/sha3.c
SM_OBJS := $(addprefix ,$(addsuffix .o, $(basename $(SM_SRC))))
TEST_SRC := $(TEST_DIR)/os/sm_api_os.c
TEST_SRC += $(TEST_DIR)/os/os_stack.S
TEST_SRC += $(TEST_DIR)/os/os_pt.S
TEST_SRC += $(TEST_DIR)/enclave/sm_api_enclave.c
TEST_SRC += $(TEST_DIR)/enclave/enclave_code.S
TEST_SRC += $(TEST_DIR)/htif/htif.c
TEST_OBJS := $(addsuffix .o, $(basename $(TEST_SRC)))
OBJS := $(SM_OBJS) $(TEST_OBJS) $(wildcard $(UNIT_TESTS_DIR)/*.o)
$(TEST_IDPT): $(TEST_DIR)/make_idpt.py
mkdir -p $(SM_BUILD)
cd $(SM_BUILD) && python $(TEST_DIR)/make_idpt.py
$(SM_BUILD)/%.elf: $(TEST_IDPT) $(SM_OBJS) $(TEST_OBJS) $(UNIT_TESTS_DIR)/%.o
mkdir -p $(SM_BUILD)
echo $(SM_OBJS)
echo $(SM_SRC)
cd $(SM_SRC_DIR) && $(CC) -T security_monitor.lds $(CFLAGS) $(SM_OBJS) $(TEST_OBJS) $(UNIT_TESTS_DIR)/$*.o -o $@
.PHONY: security_monitor_test_elfs
security_monitor_test_elfs: $(TEST_ELFS)
.PHONY: security_monitor_objs
security_monitor_objs: $(OBJS)
%.task: $(SM_BUILD)/%.elf
cd $(BUILD_DIR)/security_monitor && $(QEMU) $(QEMU_FLAGS) -kernel $^
.PHONY: security_monitor_tests
security_monitor_tests: $(TEST_TASKS)
@echo "All the test cases in $(UNIT_TESTS_DIR) have been run."
@echo "The tests were: $(TEST_NAMES)"
.PHONY: clean_security_monitor
clean_security_monitor:
rm -f $(OBJS) $(TEST_ELFS)