-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
82 lines (71 loc) · 2.64 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
NPROCS := 1
OS := $(shell uname -s)
ifeq ($(OS),Linux)
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
endif
CXX ?= clang++
VENDOR_LIBS = vendor/lib/libdebug.a vendor/lib/libcpu.a vendor/lib/libcpudb.a vendor/lib/libavx.a vendor/lib/libfpu.a vendor/libfuzzer-ng/libFuzzer.a vendor/lib/gdbstub.o
VENDOR_OBJS =
LDFLAGS = -fPIE -lrt -ldl -lpthread -lsqlite3 -lstdc++fs -lcrypto #-fsanitize=address
INCLUDES = -I vendor/bochs \
-I vendor/bochs/gui \
-I vendor/include \
-I vendor/robin-map/include
CFLAGS = $(INCLUDES) -O3 -g -lsqlite3 -fPIE #-stdlib=libc++ -fsanitize=address
CXXFLAGS=-stdlib=libc++
LIBFUZZER_FLAGS = -max_len=8192 -rss_limit_mb=-1 -detect_leaks=0 -use_value_profile=1 ${LIBFUZZER_ARGS}
OBJS = main.o \
regs.o \
breakpoints.o \
db.o \
manual_ranges.o \
instrument.o \
feedback.o \
fuzz.o \
conveyor.o \
symbolize.o \
sym2addr_linux.o \
link_map.o \
ept.o \
cov.o \
vmcs.o \
enum.o \
sourcecov.o \
bochsapi/logfunctions.o \
devices.o \
bochsapi/system.o \
bochsapi/mem.o \
bochsapi/siminterface.o \
bochsapi/paramtree.o \
bochsapi/gui.o \
bochsapi/apic.o \
bochsapi/dbg.o
all: rebuild_bochs $(OBJS) $(VENDOR_LIBS) vendor/libfuzzer-ng/libFuzzer.a
$(CXX) $(CFLAGS) $(OBJS) $(VENDOR_OBJS) $(VENDOR_LIBS) $(LDFLAGS) -o fuzz
%.o: %.cc $(DEPS)
$(CXX) $(CFLAGS) $(LDFLAGS) -c -o $@ $<
vendor/libfuzzer-ng/libFuzzer.a:
cd vendor/libfuzzer-ng/; ./build.sh
rebuild_bochs:
mkdir -p vendor/bochs-build vendor/lib vendor/include
cd vendor/bochs-build; test -f config.h || ../bochs/configure \
--enable-vmx=2 --with-vncsrv --enable-x86-64 --enable-e1000 \
--without-x --without-x11 --without-win32 --without-macos \
--enable-cpu-level=6 --enable-pci --without-gui --enable-pnic \
--enable-fast-function-calls --enable-fpu --enable-cdrom \
--enable-avx --enable-evex --disable-docbook --enable-instrumentation --with-nogui \
--enable-gdb-stub
cd vendor/bochs-build; make -j $(NPROCS)
cp ./vendor/bochs-build/cpu/cpudb/libcpudb.a vendor/lib/
cp ./vendor/bochs-build/cpu/libcpu.a vendor/lib/
cp ./vendor/bochs-build/cpu/fpu/libfpu.a vendor/lib/
cp ./vendor/bochs-build/cpu/avx/libavx.a vendor/lib/
cp ./vendor/bochs-build/config.h vendor/include/
cp ./vendor/bochs-build/gdbstub.o vendor/lib/gdbstub.o
cp ./vendor/bochs/instrument/stubs/instrument.h vendor/include/
cd vendor/bochs-build; make -j bx_debug/libdebug.a
cp ./vendor/bochs-build/bx_debug/libdebug.a vendor/lib/
clean:
rm -rf vendor/bochs-build vendor/lib vendor/include
rm -rf bochsapi/*.o
rm -rf ./*.o