-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
74 lines (54 loc) · 1.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
BUILDARCH := $(shell go env GOARCH)
HOSTARCH ?= $(BUILDARCH)
TARGETARCH ?= arm64
AFLVER ?= 2.52b
ifeq ("$(TARGETARCH)", "arm64")
CC ?= "aarch64-linux-gnu-gcc"
CXX ?= "aarch64-linux-gnu-g++"
else ifeq ("$(TARGETARCH)", "arm")
CC ?= "arm-linux-gnueabihf-gcc"
CXX ?= "arm-linux-gnueabihf-g++"
endif
NOSTATIC ?= 0
ifeq ($(NOSTATIC), 0)
ADDCFLAGS += -static
endif
.PHONY: all fuzzer zip afl-setup afl-fuzz format clean
all: executor fuzzer
executor:bin/$(TARGETARCH)/executor
bin/$(TARGETARCH)/executor: executor/executor.cc
mkdir -p ./bin/$(TARGETARCH)
$(CXX) -o $@ $^ \
-Wall -Wparentheses -Werror \
$(ADDCFLAGS) $(CFLAGS)
fuzzer: afl-setup afl-fuzz afl-cmin afl-showmap
afl-setup: fuzzer/afl-$(AFLVER)
fuzzer/afl-$(AFLVER):
cd fuzzer; \
wget lcamtuf.coredump.cx/afl/releases/afl-$(AFLVER).tgz; \
tar -xf afl-$(AFLVER).tgz; \
rm afl-$(AFLVER).tgz; \
cd afl-$(AFLVER); \
patch -p1 < ../afl-$(AFLVER).patch
afl-cmin: bin/$(TARGETARCH)/afl-cmin
bin/$(TARGETARCH)/fuzzer:
mkdir -p ./bin/$(TARGETARCH)
$(MAKE) AFL_NO_X86=1 ADDCFLAGS="$(ADDCFLAGS)" CC=$(CC) -C fuzzer/afl-$(AFLVER) afl-fuzz \
&& mv fuzzer/afl-$(AFLVER)/afl-fuzz $@
afl-fuzz: bin/$(TARGETARCH)/fuzzer
bin/$(TARGETARCH)/afl-cmin:
mkdir -p ./bin/$(TARGETARCH)
cp fuzzer/afl-$(AFLVER)/afl-cmin $@
afl-showmap: bin/$(TARGETARCH)/afl-showmap
bin/$(TARGETARCH)/afl-showmap:
mkdir -p ./bin/$(TARGETARCH)
$(MAKE) AFL_NO_X86=1 ADDCFLAGS="$(ADDCFLAGS)" CC=$(CC) -C fuzzer/afl-$(AFLVER) afl-showmap \
&& mv fuzzer/afl-$(AFLVER)/afl-showmap $@
zip: bin.zip
bin.zip:
zip -r $@ bin
format:
clang-format -i executor/executor.cc fuzzer/ashmem.h
find linux -iname '*.c' -o -iname '*.h' | xargs clang-format -i
clean:
rm -rf ./bin ./fuzzer/afl-$(AFLVER)