-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
579 lines (466 loc) · 18.7 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
SHELL := /bin/bash
# check whether it is a windows env
OSType ?= $(shell echo %OS%)
ifeq ($(OSType),Windows_NT)
ARCH ?= x86_64
else
ARCH ?= $(shell arch)
OSType := $(shell uname)
ifeq ($(ARCH),arm64)
ARCH := aarch64
endif
endif
# set variables
OPT_LEVEL ?= O2
# extra security features (comment them out if not needed)
# common option in Windows and Linux
#enable_stack_nx_protection = yes
#disable_stack_nx_protection = yes
#enable_stack_protection = yes
#disable_stack_protection = yes
#enable_aslr_protection = yes
#disable_aslr_protection = yes
#enable_cet_shadow_stack = yes
#enable_default_address_sanitizer = yes
# common option in Linux
#enable_got_protection = yes
#disable_got_protection = yes
#enable_vtable_verify = yes
#disable_vtable_verify = yes
#enable_control_flow_protection = yes
#disable_control_flow_protection = yes
#enable_stack_clash_protection = yes
#enable_address_sanitizer_without_leaker = yes
#enable_undefined_sanitizer = yes
#enable_full_address_sanitizer = yes
#enable_full_undefined_sanitizer = yes
# common option in Windows, msvc specific safety feature
#enable_extra_stack_protection = yes
#enable_heap_integrity = yes
#enable_return_address_sanitizer = yes
#enable_fuzzer_address_sanitizer = yes
#enable_fuzzer_address_sanitizer_withou_object_flags = yes
# specific hardware secrutiy features
#enable_riscv64_cheri = yes
#enable_aarch64_morello = yes
#enable_aarch64_mte = yes
#enable_aarch64_pa = yes
#enable_aarch64_bti = yes
# define paths and objects
ifeq ($(OSType),Windows_NT)
# platform
CPU_INFO ?= $(shell echo %PROCESSOR_IDENTIFIER%)
RUN_PREFIX :=
test-path := test
log-path := trace-log
# compiler
CXX := cl
ASM := ml64
CLIBAPI := visualcpp
OBJDUMP := dumpbin
CXXFLAGS_BASE := /std:c11 /nologo /W3 /WX- /Oi /DNDEBUG /D_CONSOLE /D_UNICODE /DUNICODE \
/EHsc /MD /Gy /Gd /I./lib
ifdef BUFFER_SIZE
CXXFLAGS_BASE += /DBUFFER_SIZE=$(BUFFER_SIZE)
endif
ifdef BUFFER_KIND
CXXFLAGS_BASE += /DBUFFER_KIND=$(BUFFER_KIND)
endif
ifdef REGION_KIND
CXXFLAGS_BASE += /DREGION_KIND=$(REGION_KIND)
endif
ifneq ($(and $(BUFFER_VAL_UNDERFLOW),$(BUFFER_VAL_MID),$(BUFFER_VAL_OVERFLOW)),)
CXXFLAGS_BASE += /DBUFFER_VAL_UNDERFLOW=$(BUFFER_VAL_UNDERFLOW) /DBUFFER_VAL_MID=$(BUFFER_VAL_MID) /DBUFFER_VAL_OVERFLOW=$(BUFFER_VAL_OVERFLOW)
endif
ifdef TRACE_RUN
CXXFLAGS_BASE += /DTRACE_RUN=$(TRACE_RUN)
endif
SCHEDULER_CXXFLAGS := /O2 $(CXXFLAGS_BASE) /I. /DRUN_PREFIX="\"$(RUN_PREFIX)\""
OBJECT_CXXFLAGS := /$(OPT_LEVEL) /Zi $(CXXFLAGS_BASE)
CXXFLAGS := /$(OPT_LEVEL) /Zi $(CXXFLAGS_BASE)
ASMFLAGS := /nologo /Zi /c
# If there is a whitespace between windows msvc's output option and output file,
# will raise error
OUTPUT_EXE_OPTION := /Fe
OUTPUT_LIB_OPTION := /c /Fo
OUTPUT_DYN_OPTION := /LD /Fe
MIDFILE_SUFFIX := .obj
DLL_SUFFIX := .dll
LDFLAGS := /link /incremental:no /OPT:NOREF /OPT:NOICF
LIB_LDFLAGS := /link
OBJDUMPFLAGS := /DISASM
DYNCFI_OPTION := libcfi.lib
func-opcode-gen := .\script\get_x64_func_inst.bat
dynlibcfi := $(addsuffix $(DLL_SUFFIX), libcfi)
independent_assembly := lib/x86_64/visualcpp_indepassembly_func.obj
# define compiling flags
ifdef enable_stack_nx_protection
CXXFLAGS += /NXCOMPAT
LDFLAGS += /NXCOMPAT
LIB_LDFLAGS += /NXCOMPAT
endif
ifdef disable_stack_nx_protection
CXXFLAGS += /NXCOMPAT:NO
LDFLAGS += /NXCOMPAT:NO
LIB_LDFLAGS += /NXCOMPAT:NO
endif
ifdef enable_stack_protection
CXXFLAGS += /GS
endif
ifdef disable_stack_protection
CXXFLAGS += /GS-
endif
ifdef enable_aslr_protection
LDFLAGS += /DYNAMICBASE /LARGEADDRESSAWARE /HIGHENTROPYVA
LIB_LDFLAGS += /DYNAMICBASE /LARGEADDRESSAWARE /HIGHENTROPYVA
endif
ifdef disable_aslr_protection
LDFLAGS += /DYNAMICBASE:NO /LARGEADDRESSAWARE:NO /HIGHENTROPYVA:NO
LIB_LDFLAGS += /DYNAMICBASE:NO /LARGEADDRESSAWARE:NO /HIGHENTROPYVA:NO
endif
ifdef enable_control_flow_protection
CXXFLAGS += /guard:cf
LDFLAGS += /GUARD:CF
endif
ifdef disable_control_flow_protection
CXXFLAGS += /guard:cf-
LDFLAGS += /GUARD:NO
endif
ifdef enable_cet_shadow_stack
LDFLAGS += /CETCOMPAT
endif
ifdef enable_heap_integrity
CXXFLAGS += /sdl /GS
endif
ifdef enable_extra_stack_protection
CXXFLAGS += /RTCs
endif
ifdef enable_default_address_sanitizer
CXXFLAGS += /fsanitize=address
endif
ifdef enable_fuzzer_address_sanitizer
CXXFLAGS += /fsanitize=fuzzer
OBJECT_CXXFLAGS += /fsanitize=fuzzer
endif
ifdef enable_return_address_sanitizer
CXXFLAGS += /fsanitize-address-use-after-return
OBJECT_CXXFLAGS += /fsanitize-address-use-after-return
RUN_PREFIX += ASAN_OPTIONS=detect_stack_use_after_return=1
endif
ifdef enable_fuzzer_address_sanitizer_withou_object_flags
CXXFLAGS += /fsanitize=fuzzer
endif
else
# platform
ifeq ($(OSType),Darwin)
CPU_INFO = $(shell sysctl -n machdep.cpu.brand_string)
else
CPU_INFO = $(shell grep -m 1 "model name" /proc/cpuinfo)
endif
RUN_PREFIX :=
test-path := test
log-path := trace-log
#compiler
ifeq ($(OSType),Darwin)
CXX := clang++
else
CXX := g++
endif
ASM := as
CLIBAPI := posix
OBJDUMP := objdump
CXXFLAGS_BASE = ${CXXFLAGS} -I./lib -std=c++11 -Wall
ifdef BUFFER_SIZE
CXXFLAGS_BASE += -DBUFFER_SIZE=$(BUFFER_SIZE)
endif
ifdef BUFFER_KIND
CXXFLAGS_BASE += -DBUFFER_KIND=$(BUFFER_KIND)
endif
ifdef REGION_KIND
CXXFLAGS_BASE += -DREGION_KIND=$(REGION_KIND)
endif
ifneq ($(and $(BUFFER_VAL_UNDERFLOW),$(BUFFER_VAL_MID),$(BUFFER_VAL_OVERFLOW)),)
CXXFLAGS_BASE += -DBUFFER_VAL_UNDERFLOW=$(BUFFER_VAL_UNDERFLOW) -DBUFFER_VAL_MID=$(BUFFER_VAL_MID) -DBUFFER_VAL_OVERFLOW=$(BUFFER_VAL_OVERFLOW)
endif
ifdef TRACE_RUN
CXXFLAGS_BASE += -DTRACE_RUN=$(TRACE_RUN)
endif
SCHEDULER_CXXFLAGS := -O2 $(CXXFLAGS_BASE) -I. -DRUN_PREFIX="\"$(RUN_PREFIX)\""
OBJECT_CXXFLAGS := -$(OPT_LEVEL) $(CXXFLAGS_BASE)
CXXFLAGS := $(CXXFLAGS_BASE)
ASMFLAGS :=
OUTPUT_EXE_OPTION := -o
OUTPUT_LIB_OPTION := -c -o
OUTPUT_DYN_OPTION := -shared -fPIC -o
MIDFILE_SUFFIX := .o
DLL_SUFFIX := .so
LDFLAGS :=
LIB_LDFLAGS :=
OBJDUMPFLAGS := -D -l -S
DYNCFI_OPTION := -Llib/common/ -Wl,-rpath,lib/common/ -lcfi
func-opcode-gen := ./script/get_x64_func_inst.sh
ifeq ($(ARCH), aarch64)
func-opcode-gen := ./script/get_aarch64_func_inst.sh
else ifeq ($(ARCH), riscv64)
func-opcode-gen := ./script/get_riscv64_func_inst.sh
endif
dynlibcfi := $(addsuffix $(DLL_SUFFIX), lib/common/libcfi)
independent_assembly := $(addprefix lib/$(ARCH)/, indepassembly.o)
ifeq ($(CXX),$(filter $(CXX),clang++ c++))
ifneq ($(OSType),Darwin)
CXXFLAGS += -fuse-ld=lld
endif
endif
# define compiling flags
ifdef enable_stack_nx_protection
CXXFLAGS += -z noexecstack
endif
ifdef disable_stack_nx_protection
CXXFLAGS += -z execstack
endif
ifdef enable_stack_protection
CXXFLAGS += -Wstack-protector -fstack-protector-all
ifeq ($(ARCH),x86_64)
CXXFLAGS += -mstack-protector-guard=global
endif
endif
ifdef disable_stack_protection
CXXFLAGS += -fno-stack-protector
endif
ifdef enable_aslr_protection
CXXFLAGS += pie -fPIE
LDFLAGS += -Wl, pie
endif
ifdef disable_aslr_protection
CXXFLAGS += -no-pie
LDFLAGS += -Wl,-no-pie
endif
ifdef enable_got_protection
LDFLAGS += -Wl,-z,relro,-z,now
endif
ifdef disable_got_protection
LDFLAGS += -Wl,-z, norelro,-z,lazy
endif
ifdef enable_vtable_verify
CXXFLAGS += -fvtable-verify=std
endif
ifdef disable_vtable_verify
CXXFLAGS += -fvtable-verify=none
endif
ifdef enable_control_flow_protection
ifeq ($(ARCH),x86_64)
CXXFLAGS += -fcf-protection=full
endif
endif
ifdef enable_cet_shadow_stack
CXXFLAGS += -fcf-protection=return
endif
ifdef disable_control_flow_protection
ifeq ($(ARCH),x86_64)
CXXFLAGS += -fcf-protection=none
endif
endif
ifdef enable_stack_clash_protection
CXXFLAGS += -fstack-clash-protection
endif
ifdef enable_default_address_sanitizer
CXXFLAGS += -fsanitize=address -fno-sanitize-recover=all
OBJECT_CXXFLAGS += -fsanitize=address -fno-sanitize-recover=all
endif
ifdef enable_address_sanitizer_without_leaker
CXXFLAGS += -fsanitize=address -fno-sanitize-recover=all
OBJECT_CXXFLAGS += -fsanitize=address -fno-sanitize-recover=all
RUN_PREFIX += ASAN_OPTIONS=detect_leaks=0
endif
ifdef enable_undefined_sanitizer
CXXFLAGS += -fsanitize=undefined -fno-sanitize-recover=all
OBJECT_CXXFLAGS += -fsanitize=undefined -fno-sanitize-recover=all
SIMPLE_FLAGS :=$(SIMPLE_FLAGS)-uasan
endif
ifdef enable_full_address_sanitizer
CXXFLAGS += -fsanitize=address -fsanitize-address-use-after-scope -fno-common -fsanitize=pointer-compare -fsanitize=pointer-subtract -fno-sanitize-recover=all
OBJECT_CXXFLAGS += -fsanitize=address -fsanitize-address-use-after-scope -fno-common -fsanitize=pointer-compare -fsanitize=pointer-subtract -fno-sanitize-recover=all
ifeq ($(CXX),$(filter $(CXX),clang++ c++))
CXXFLAGS += -fsanitize-address-use-after-return=always
OBJECT_CXXFLAGS += -fsanitize-address-use-after-return=always
endif
RUN_PREFIX += ASAN_OPTIONS=detect_stack_use_after_return=1:detect_invalid_pointer_pairs=2
SIMPLE_FLAGS :=$(SIMPLE_FLAGS)-fullasan
endif
ifdef enable_full_undefined_sanitizer
CXXFLAGS += -fsanitize=undefined -fsanitize=signed-integer-overflow -fno-sanitize-recover=all
ifndef without_extra_ojbect_safety_options
OBJECT_CXXFLAGS += -fsanitize=undefined -fsanitize=signed-integer-overflow -fno-sanitize-recover=all
endif
ifeq ($(CXX),$(filter $(CXX),clang++ c++))
CXXFLAGS += -fsanitize=local-bounds -fsanitize=unsigned-integer-overflow
OBJECT_CXXFLAGS += -fsanitize=local-bounds -fsanitize=unsigned-integer-overflow
endif
SIMPLE_FLAGS :=$(SIMPLE_FLAGS)-fulluasan
endif
endif
ifdef enable_riscv64_cheri
ARCH := cheri_riscv64
CXXFLAGS += -mno-relax -march=rv64gcxcheri -mabi=l64pc128d -cheri-bounds=very-aggressive
SCHEDULER_CXXFLAGS += -mno-relax
OBJECT_CXXFLAGS += -mno-relax -march=rv64gcxcheri -mabi=l64pc128d -cheri-bounds=very-aggressive
endif
ifdef enable_aarch64_morello
ARCH := aarch64
CXXFLAGS += -march=morello -mabi=purecap -cheri-bounds=very-aggressive
OBJECT_CXXFLAGS += -march=morello -mabi=purecap -cheri-bounds=very-aggressive
endif
ifdef enable_aarch64_mte
CXXFLAGS := $(CXXFLAGS) -march=armv8.5-a+memtag -fsanitize=hwaddress
OBJECT_CXXFLAGS += -march=armv8.5-a+memtag -fsanitize=hwaddress
endif
ifdef enable_aarch64_pa
CXXFLAGS := $(CXXFLAGS) -march=armv8.3-a+pauth -mbranch-protection=pac-ret
OBJECT_CXXFLAGS += -march=armv8.3-a+pauth -mbranch-protection=pac-ret
endif
ifdef enable_aarch64_bti
CXXFLAGS := $(CXXFLAGS) -march=armv8.5-a -mbranch-protection=bti
OBJECT_CXXFLAGS += -march=armv8.5-a -mbranch-protection=bti
endif
# define cases
mss-path = mss
mss-cpps = $(wildcard $(mss-path)/*.cpp)
mss-obj = $(addsuffix $(MIDFILE_SUFFIX),$(addprefix $(test-path)/mss-, $(basename $(notdir $(mss-cpps)))))
mss-tests = $(addprefix $(test-path)/mss-, $(basename $(notdir $(mss-cpps))))
mss-cpps-prep = $(addsuffix .prep, $(mss-cpps))
mts-path = mts
mts-cpps = $(wildcard $(mts-path)/*.cpp)
mts-obj = $(addsuffix $(MIDFILE_SUFFIX), $(addprefix $(test-path)/mts-, $(basename $(notdir $(mts-cpps)))))
mts-tests = $(addprefix $(test-path)/mts-, $(basename $(notdir $(mts-cpps))))
mts-cpps-prep = $(addsuffix .prep, $(mts-cpps))
acc-path = acc
acc-cpps = $(wildcard $(acc-path)/*.cpp)
acc-obj = $(addsuffix $(MIDFILE_SUFFIX), $(addprefix $(test-path)/acc-, $(basename $(notdir $(acc-cpps)))))
acc-tests = $(addprefix $(test-path)/acc-, $(basename $(notdir $(acc-cpps))))
acc-cpps-prep = $(addsuffix .prep, $(acc-cpps))
cpi-path = cpi
cpi-cpps = $(wildcard $(cpi-path)/*.cpp)
cpi-obj = $(addsuffix $(MIDFILE_SUFFIX), $(addprefix $(test-path)/cpi-, $(basename $(notdir $(cpi-cpps)))))
cpi-tests = $(addprefix $(test-path)/cpi-, $(basename $(notdir $(cpi-cpps))))
cpi-cpps-prep = $(addsuffix .prep, $(cpi-cpps))
cfi-path = cfi
cfi-cpps = $(wildcard $(cfi-path)/*.cpp)
cfi-obj = $(addsuffix $(MIDFILE_SUFFIX), $(addprefix $(test-path)/cfi-, $(basename $(notdir $(cfi-cpps)))))
cfi-tests = $(addprefix $(test-path)/cfi-, $(basename $(notdir $(cfi-cpps))))
cfi-cpps-prep = $(addsuffix .prep, $(cfi-cpps))
sec-tests := $(mss-tests) $(mts-tests) $(acc-tests) $(cpi-tests) $(cfi-tests)
sec-tests-dump = $(addsuffix .dump, $(sec-tests))
sec-tests-prep := $(mss-cpps-prep) $(mts-cpps-prep) $(acc-cpps-prep) $(cpi-cpps-prep) $(cfi-cpps-prep)
headers := $(wildcard lib/include/*.hpp) $(wildcard lib/$(ARCH)/*.hpp) $(wildcard lib/$(CLIBAPI)/*.hpp)
extra_objects := lib/common/global_var lib/common/temp_file $(addprefix lib/$(ARCH)/, assembly) $(addprefix lib/$(CLIBAPI)/, signal)
extra_objects := $(addsuffix $(MIDFILE_SUFFIX), $(extra_objects))
libmss := $(addsuffix $(MIDFILE_SUFFIX), lib/common/mss)
all: run-test
.PHONY: all
run-test: scheduler/run-test.cpp lib/common/temp_file.cpp lib/include/temp_file.hpp scheduler/json.hpp $(test-path)/sys_info.txt
$(CXX) $(SCHEDULER_CXXFLAGS) $< lib/common/temp_file.cpp $(OUTPUT_EXE_OPTION)$@
ifeq ($(OSType),Windows_NT)
$(test-path)/sys_info.txt:
-mkdir $(test-path)
-mkdir $(log-path)
echo "CPU: & System : " > $(test-path)/sys_info.txt
systeminfo | findstr /C:"Windows" /C:"Intel" >> $(test-path)/sys_info.txt
echo "Compiler : " >> $(test-path)/sys_info.txt
echo "VSCMD_VER=" %VSCMD_VER% " UCRTVersion=" %UCRTVersion% " VCToolsVersion=" %VCToolsVersion% >> $(test-path)/sys_info.txt
Reg Query "HKLM\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0" >> $(test-path)/sys_info.txt
echo "Flags : " >> $(test-path)/sys_info.txt
echo "OBJECT_CXXFLAGS = " $(OBJECT_CXXFLAGS) >> $(test-path)/sys_info.txt
echo "CXXFLAGS = " $(CXXFLAGS) >> $(test-path)/sys_info.txt
echo "LDFLAGS = " $(LDFLAGS) >> $(test-path)/sys_info.txt
rubbish += run-test.exe
else
$(test-path)/sys_info.txt:
-mkdir -p $(test-path)
-mkdir -p $(log-path)
echo "CPU: $(CPU_INFO)" > $(test-path)/sys_info.txt
echo "System : " >> $(test-path)/sys_info.txt
uname -srp >> $(test-path)/sys_info.txt
echo "Compiler : " >> $(test-path)/sys_info.txt
$(CXX) --version >> $(test-path)/sys_info.txt
echo "LIBC : " >> $(test-path)/sys_info.txt
$(OBJDUMP) --version >> $(test-path)/sys_info.txt
echo "Flags : " >> $(test-path)/sys_info.txt
echo "OBJECT_CXXFLAGS = " $(OBJECT_CXXFLAGS) >> $(test-path)/sys_info.txt
echo "CXXFLAGS = " $(CXXFLAGS) >> $(test-path)/sys_info.txt
echo "LDFLAGS = " $(LDFLAGS) >> $(test-path)/sys_info.txt
rubbish += run-test
endif
$(dynlibcfi): lib/common/cfi.cpp lib/include/cfi.hpp
$(CXX) $(OBJECT_CXXFLAGS) $< $(OUTPUT_DYN_OPTION)$@ $(LIB_LDFLAGS)
cfi_base := $(basename $(dynlibcfi))
rubbish += $(cfi_base).so $(cfi_base).dll $(cfi_base).pdb $(cfi_base).obj $(cfi_base).lib $(cfi_base).ilk $(cfi_base).exp lib/common/cfi.obj
$(extra_objects): %$(MIDFILE_SUFFIX) : %.cpp $(headers)
$(CXX) $(OBJECT_CXXFLAGS) $< $(OUTPUT_LIB_OPTION)$@ $(LIB_LDFLAGS)
rubbish += $(extra_objects)
$(independent_assembly): %$(MIDFILE_SUFFIX) : %.asm
$(ASM) $(OUTPUT_LIB_OPTION)$@ $(ASMFLAGS) $^ $(LIB_LDFLAGS)
rubbish += $(independent_assembly)
$(libmss): %$(MIDFILE_SUFFIX) : %.cpp lib/include/mss.hpp
$(CXX) $(OBJECT_CXXFLAGS) -c $< $(OUTPUT_LIB_OPTION)$@ $(LIB_LDFLAGS)
rubbish += $(libmss)
$(mss-obj): $(test-path)/mss-%$(MIDFILE_SUFFIX):$(mss-path)/%.cpp
$(CXX) $(OBJECT_CXXFLAGS) $< $(OUTPUT_LIB_OPTION)$@ $(LIB_LDFLAGS)
$(mss-tests): %:%$(MIDFILE_SUFFIX) $(extra_objects) $(libmss) $(independent_assembly)
$(CXX) $(CXXFLAGS) $< $(extra_objects) $(independent_assembly) $(libmss) $(OUTPUT_EXE_OPTION)$@ $(LDFLAGS)
$(mss-cpps-prep): %.prep:%
$(CXX) -E $(CXXFLAGS) $< > $@
$(mts-obj): $(test-path)/mts-%$(MIDFILE_SUFFIX):$(mts-path)/%.cpp
$(CXX) $(OBJECT_CXXFLAGS) $< $(OUTPUT_LIB_OPTION)$@ $(LIB_LDFLAGS)
$(mts-tests): %:%$(MIDFILE_SUFFIX) $(extra_objects) $(libmss) $(independent_assembly)
$(CXX) $(CXXFLAGS) $< $(extra_objects) $(independent_assembly) $(libmss) $(OUTPUT_EXE_OPTION)$@ $(LDFLAGS)
$(mts-cpps-prep): %.prep:%
$(CXX) -E $(CXXFLAGS) $< > $@
$(acc-obj): $(test-path)/acc-%$(MIDFILE_SUFFIX):$(acc-path)/%.cpp
$(CXX) $(OBJECT_CXXFLAGS) $< $(OUTPUT_LIB_OPTION)$@ $(LIB_LDFLAGS)
$(acc-tests): %:%$(MIDFILE_SUFFIX) $(extra_objects) $(independent_assembly)
$(CXX) $(CXXFLAGS) $< $(extra_objects) $(independent_assembly) $(OUTPUT_EXE_OPTION)$@ $(LDFLAGS)
$(test-path)/acc-read-func-func-opcode.tmp: $(func-opcode-gen) $(test-path)/acc-read-func
ifeq ($(OSType),Windows_NT)
$< $(test-path)\acc-read-func.exe helper 8 $(test-path)\acc-read-func-func-opcode.tmp
else
$^ helper 8 $@
endif
$(test-path)/acc-read-func.gen: %.gen:% $(test-path)/acc-read-func-func-opcode.tmp
ifeq ($(OSType), Windows_NT)
copy /Y $(test-path)\acc-read-func.exe $(test-path)\acc-read-func.gen
else
cp $< $@
endif
$(acc-cpps-prep): %.prep:%
$(CXX) -E $(CXXFLAGS) $< > $@
$(cpi-obj): $(test-path)/cpi-%$(MIDFILE_SUFFIX):$(cpi-path)/%.cpp
$(CXX) $(OBJECT_CXXFLAGS) $< $(OUTPUT_LIB_OPTION)$@ $(LIB_LDFLAGS)
$(cpi-tests): %:%$(MIDFILE_SUFFIX) $(extra_objects) $(dynlibcfi) $(independent_assembly)
$(CXX) $(CXXFLAGS) $< $(extra_objects) $(independent_assembly) $(DYNCFI_OPTION) $(OUTPUT_EXE_OPTION)$@ $(LDFLAGS)
$(cpi-cpps-prep): %.prep:%
$(CXX) -E $(CXXFLAGS) $< > $@
$(cfi-obj): $(test-path)/cfi-%$(MIDFILE_SUFFIX):$(cfi-path)/%.cpp
$(CXX) $(OBJECT_CXXFLAGS) $< $(OUTPUT_LIB_OPTION)$@ $(LIB_LDFLAGS)
$(cfi-tests): %:%$(MIDFILE_SUFFIX) $(extra_objects) $(dynlibcfi) $(independent_assembly)
$(CXX) $(CXXFLAGS) $< $(extra_objects) $(independent_assembly) $(DYNCFI_OPTION) $(OUTPUT_EXE_OPTION)$@ $(LDFLAGS)
$(cfi-cpps-prep): %.prep:%
$(CXX) -E $(CXXFLAGS) $< > $@
rubbish += results.json results.dat variables.json
dump: $(sec-tests-dump)
$(sec-tests-dump): %.dump:%
$(OBJDUMP) $(OBJDUMPFLAGS) $< > $@
prep: $(sec-tests-prep)
ifeq ($(OSType),Windows_NT)
# cmd can not identify "/", so use powershell remove-item
# powershell remove-item separates diff items by comma not whitespace
rubbish:= $(subst /,\,$(rubbish))
clean:
-del /Q $(rubbish) $(test-path) $(log-path) *.tmp *.ilk *.pdb *.obj *.exe *.dump *.dll *.lib *.exp
else
clean:
-rm -rf $(rubbish) $(test-path) $(log-path) *.tmp > /dev/null 2>&1
endif
.PHONY: clean run dump prep
doc:
cd doc; pdflatex specification
.PHONY: doc