-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
81 lines (66 loc) · 2.98 KB
/
Makefile
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
77
78
79
80
81
SRCDIR = src
OBJDIR = bin
DEBUG_FLAG = -O0 -g -D DEBUG=1
UNDEBUG_FLAG = -O2
FLAGS = -m64 -D DLL_APP=1
FLAGS_XX = $(FLAGS) -std=c++11
CXX = g++
CC = gcc
AR = ar
LIB_SGX_ENL_1 = lib/lib_sgx_enclave.o
LIB_SGX_ENL_2 = lib/lib_sgx_enclave_syscallwrap.o
LIB_SGX_ENL = $(LIB_SGX_ENL_1) $(LIB_SGX_ENL_2)
LIB_SGX_UT = lib/lib_sgx_untrusted.o
FLAGS_SYSCALL_WRAP= \
-Wl,-wrap,write \
-Wl,-wrap,access \
-Wl,-wrap,brk \
-Wl,-wrap,mmap
#-Wl,-wrap,puts
default : debug
debug : FLAGS_XX += $(DEBUG_FLAG)
debug :
@mkdir -p bin; rm bin/* || true
@#trusted
$(CXX) -shared -fPIC -c $(FLAGS_XX) src/user_enclave_foo.cpp -o $(OBJDIR)/enclave_foo.o
$(CXX) -shared -fPIC $(FLAGS_SYSCALL_WRAP) -Wl,--whole-archive $(OBJDIR)/enclave_foo.o $(LIB_SGX_ENL) -Wl,--no-whole-archive -o $(OBJDIR)/enclave_foo.so
@#rm $(OBJDIR)/enclave_foo.o
@#If a .so needs to be generated, all relocatable objects file needs to be generated with the same '-shared -fPIC' flag
@#can't combine multiple .so files in Linux, (.so is final); can only combine .o or .a files
$(CXX) -shared -fPIC $(FLAGS_XX) $(FLAGS_SYSCALL_WRAP) src/user_enclave_foo2.cpp -Wl,--whole-archive $(LIB_SGX_ENL) -Wl,--no-whole-archive -o $(OBJDIR)/enclave_foo2.so
@#untrusted
$(CXX) -rdynamic $(FLAGS_XX) src/user_main_ut.cpp $(LIB_SGX_UT) -ldl -o $(OBJDIR)/a.out
sha:
@mkdir -p bin; rm bin/* || true
$(CXX) -shared -fPIC $(FLAGS_XX) $(FLAGS_SYSCALL_WRAP) src/user_enclave_app_openssl.cpp src/user_enclave_lib_openssl_sha1.cpp -Wl,--whole-archive $(LIB_SGX_ENL) -Wl,--no-whole-archive -o $(OBJDIR)/enclave_sha.so
$(CXX) -rdynamic $(FLAGS_XX) src/user_main_sha.cpp $(LIB_SGX_UT) -ldl -o $(OBJDIR)/a.out
c : product-compile
product-compile : FLAGS_XX += $(UNDEBUG_FLAG)
product-compile :
@mkdir -p bin; rm bin/* || true
@#trusted
$(CXX) -shared -fPIC $(FLAGS_XX) $(FLAGS_SYSCALL_WRAP) src/user_enclave_foo.cpp -Wl,--whole-archive $(LIB_SGX_ENL) -Wl,--no-whole-archive -o $(OBJDIR)/enclave_foo.so
@#If a .so needs to be generated, all relocatable objects file needs to be generated with the same '-shared -fPIC' flag
@#can't combine multiple .so files in Linux, (.so is final); can only combine .o or .a files
$(CXX) -shared -fPIC $(FLAGS_XX) $(FLAGS_SYSCALL_WRAP) src/user_enclave_foo2.cpp -Wl,--whole-archive $(LIB_SGX_ENL) -Wl,--no-whole-archive -o $(OBJDIR)/enclave_foo2.so
@#untrusted
$(CXX) -rdynamic $(FLAGS_XX) src/user_main_ut.cpp $(LIB_SGX_UT) -ldl -o $(OBJDIR)/a.out
#deprecated
slink :
$(CC) $(FLAG) $(SRC_ALL) -o $(OBJDIR)/a.out
#deprecated
dll :
$(CC) -shared -fPIC $(FLAG) src/enclave.cpp -o $(OBJDIR)/enclave.so
$(CC) $(FLAG) src/main_ut.cpp $(OBJDIR)/enclave.so -o $(OBJDIR)/a.out
d : debug-run
debug-run :
@echo 0 | sudo tee /proc/sys/kernel/randomize_va_space #it is important to turn off ASLR! @ubuntu
@$(MAKE) --no-print-directory run
@echo 2 | sudo tee /proc/sys/kernel/randomize_va_space #it is important to turn back on ASLR! @ubuntu
r : run
run :
@./bin/a.out
s :
@strace ./bin/a.out 2>&1 | view -
clean :
@rm lib/*; rm bin/* || true