|
| 1 | +.POSIX: |
| 2 | +.PHONY: all clean check |
| 3 | + |
| 4 | +E9TOOL ?= ../../e9tool |
| 5 | +E9COMPILE ?= ../../e9compile.sh |
| 6 | + |
1 | 7 | FCF_NONE := $(shell \ |
2 | 8 | if gcc -fcf-protection=none --version 2>&1 | grep -q 'unrecognized'; \ |
3 | 9 | then true; \ |
4 | 10 | else echo -fcf-protection=none; fi) |
5 | 11 |
|
6 | | -all: |
7 | | - gcc -x assembler-with-cpp -o test test.s -no-pie -nostdlib \ |
| 12 | +BASE ::= test test.pie bugs test.libc libtest.so test_c test_c.debug example.so |
| 13 | +TRAMPOLINE ::= inst patch dl init fini |
| 14 | +IN ::= $(wildcard *.in) |
| 15 | +EXE ::= $(IN:.in=.exe) |
| 16 | + |
| 17 | +all: regtest $(BASE) $(TRAMPOLINE) |
| 18 | + |
| 19 | +clean: |
| 20 | + rm -f regtest |
| 21 | + rm -f $(BASE) $(TRAMPOLINE) $(EXE) |
| 22 | + rm -f *.out *.log *.diff |
| 23 | + |
| 24 | +regtest: regtest.cpp |
| 25 | + $(CXX) -std=c++11 -O2 -g -fPIC -pie $< -o $@ |
| 26 | + |
| 27 | +%.exe: in=$(shell head -1 $<) |
| 28 | +%.exe: %.in $(BASE) $(TRAMPOLINE) $(E9TOOL) |
| 29 | + $(E9TOOL) $(E9TOOL_OPTIONS) -M 'addr >= &"entry"' $(in)\ |
| 30 | + -E data..data_END -E data2...text -E .text..begin -o $@ |
| 31 | + |
| 32 | +test: test.s |
| 33 | + $(CC) -x assembler-with-cpp -o $@ $< -no-pie -nostdlib \ |
8 | 34 | -Wl,--section-start=.text=0xa000000 -Wl,--section-start=.bss=0xc000000 \ |
9 | 35 | -Wl,-z -Wl,max-page-size=4096 -DPIE=0 |
10 | | - gcc -x assembler-with-cpp -o test.pie test.s -pie -nostdlib \ |
| 36 | + |
| 37 | +test.pie: test.s |
| 38 | + $(CC) -x assembler-with-cpp -o $@ $< -pie -nostdlib \ |
11 | 39 | -Wl,--section-start=.text=0xa000000 -Wl,--section-start=.bss=0xc000000 \ |
12 | 40 | -Wl,-z -Wl,max-page-size=4096 -DPIE=1 \ |
13 | 41 | -Wl,--export-dynamic |
14 | | - gcc -x assembler-with-cpp -o bugs bugs.s -no-pie -nostdlib \ |
| 42 | + |
| 43 | +bugs: bugs.s |
| 44 | + $(CC) -x assembler-with-cpp -o $@ $< -no-pie -nostdlib \ |
15 | 45 | -Wl,--section-start=.text=0xa000000 -Wl,--section-start=.bss=0xc000000 \ |
16 | 46 | -Wl,-z -Wl,max-page-size=4096 -DPIE=0 |
17 | | - gcc -x assembler-with-cpp -o test.libc test_libc.s -pie -Wl,--export-dynamic |
18 | | - gcc -x assembler-with-cpp -shared -o libtest.so libtest.s |
19 | | - gcc -O2 -fPIC $(FCF_NONE) -pie -o test_c test_c.c \ |
| 47 | + |
| 48 | +test.libc: test_libc.s |
| 49 | + $(CC) -x assembler-with-cpp -pie $< -Wl,--export-dynamic -o $@ |
| 50 | + |
| 51 | +libtest.so: libtest.s |
| 52 | + $(CC) -x assembler-with-cpp $< -shared -o $@ |
| 53 | + |
| 54 | +test_c: test_c.c |
| 55 | + $(CC) -O2 -fPIC $(FCF_NONE) -pie -o $@ $< \ |
20 | 56 | -Wl,--export-dynamic -U_FORTIFY_SOURCE |
21 | 57 | strip test_c |
22 | | - gcc -O0 -g -fPIC -pie -o test_c.debug test_c.c |
23 | | - ../../e9compile.sh inst.c -I ../../examples/ |
24 | | - ../../e9compile.sh patch.cpp -std=c++11 -I ../../examples/ |
25 | | - NO_SIMD_CHECK=1 ../../e9compile.sh dl.c -I ../../examples/ |
26 | | - ../../e9compile.sh init.c -I ../../examples/ |
27 | | - ../../e9compile.sh fini.c -I ../../examples/ |
28 | | - g++ -std=c++11 -fPIC -shared -o example.so -O2 \ |
29 | | - ../../examples/plugins/example.cpp -I ../../src/e9tool/ |
30 | | - g++ -std=c++11 -pie -fPIC -o regtest regtest.cpp -O2 |
31 | | - echo "XXX" > FILE.txt |
32 | | - chmod 0640 FILE.txt |
33 | 58 |
|
34 | | -clean: |
35 | | - rm -f *.log *.out *.exe test test.pie test.libc libtest.so inst inst.o \ |
36 | | - patch patch.o init init.o regtest |
| 59 | +test_c.debug: test_c.c |
| 60 | + $(CC) -O0 -g -fPIC -pie $< -o $@ |
| 61 | + |
| 62 | +inst: inst.c ../../examples/stdlib.c $(E9COMPILE) |
| 63 | + $(E9COMPILE) $< -I../../examples |
| 64 | + |
| 65 | +patch: patch.cpp ../../examples/stdlib.c $(E9COMPILE) |
| 66 | + $(E9COMPILE) $< -std=c++11 -I../../examples |
| 67 | + |
| 68 | +dl: dl.c ../../examples/stdlib.c $(E9COMPILE) |
| 69 | + NO_SIMD_CHECK=1 $(E9COMPILE) $< -I../../examples |
| 70 | + |
| 71 | +init: init.c ../../examples/stdlib.c $(E9COMPILE) |
| 72 | + $(E9COMPILE) $< -I../../examples |
| 73 | + |
| 74 | +fini: fini.c ../../examples/stdlib.c $(E9COMPILE) |
| 75 | + $(E9COMPILE) $< -I../../examples |
| 76 | + |
| 77 | +example.so: ../../examples/plugins/example.cpp ../../src/e9tool/e9plugin.h |
| 78 | + $(CXX) -std=c++11 -O2 -fPIC -I../../src/e9tool $< -shared -o $@ |
| 79 | + |
| 80 | +check: run-tests $(EXE) |
| 81 | + ./$^ |
0 commit comments