You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
198 lines
11 KiB
198 lines
11 KiB
* Respect AR, CC, CFLAGS, CPPFLAGS, LDFLAGS everywhere when building.
|
|
* Ignore build flags then when testing the CC wrappers (could contain
|
|
incompatible flags).
|
|
* Disable LTO for runtime objects, these shouldn't contain IR.
|
|
|
|
--- a/GNUmakefile
|
|
+++ b/GNUmakefile
|
|
@@ -423,7 +423,7 @@ afl-as: src/afl-as.c include/afl-as.h $(COMM_HDR) | test_x86
|
|
@ln -sf afl-as as
|
|
|
|
src/afl-performance.o : $(COMM_HDR) src/afl-performance.c include/hash.h
|
|
- $(CC) $(CFLAGS) $(CFLAGS_OPT) -Iinclude -c src/afl-performance.c -o src/afl-performance.o
|
|
+ $(CC) $(CFLAGS) -Iinclude -c src/afl-performance.c -o src/afl-performance.o
|
|
|
|
src/afl-common.o : $(COMM_HDR) src/afl-common.c include/common.h
|
|
$(CC) $(CFLAGS) $(CFLAGS_FLTO) -c src/afl-common.c -o src/afl-common.o
|
|
@@ -531,7 +531,7 @@ .PHONY: test_build
|
|
ifndef AFL_NO_X86
|
|
test_build: afl-cc afl-gcc afl-as afl-showmap
|
|
@echo "[*] Testing the CC wrapper afl-cc and its instrumentation output..."
|
|
- @unset AFL_MAP_SIZE AFL_USE_UBSAN AFL_USE_CFISAN AFL_USE_LSAN AFL_USE_ASAN AFL_USE_MSAN; ASAN_OPTIONS=detect_leaks=0 AFL_INST_RATIO=100 AFL_PATH=. ./afl-cc test-instr.c $(LDFLAGS) -o test-instr 2>&1 || (echo "Oops, afl-cc failed"; exit 1 )
|
|
+ @unset AFL_MAP_SIZE AFL_USE_UBSAN AFL_USE_CFISAN AFL_USE_LSAN AFL_USE_ASAN AFL_USE_MSAN; ASAN_OPTIONS=detect_leaks=0 AFL_INST_RATIO=100 AFL_PATH=. ./afl-cc test-instr.c -o test-instr 2>&1 || (echo "Oops, afl-cc failed"; exit 1 )
|
|
ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -m none -q -o .test-instr0 ./test-instr < /dev/null
|
|
echo 1 | ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -m none -q -o .test-instr1 ./test-instr
|
|
@rm -f test-instr
|
|
--- a/GNUmakefile.gcc_plugin
|
|
+++ b/GNUmakefile.gcc_plugin
|
|
@@ -131,18 +131,18 @@ afl-common.o: ./src/afl-common.c
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ $(LDFLAGS)
|
|
|
|
./afl-compiler-rt.o: instrumentation/afl-compiler-rt.o.c
|
|
- $(CC) $(CFLAGS_SAFE) $(CPPFLAGS) -O3 -Wno-unused-result -fPIC -c $< -o $@
|
|
+ $(CC) $(CFLAGS) $(CFLAGS_SAFE) $(CPPFLAGS) -Wno-unused-result -fPIC -fno-lto -c $< -o $@
|
|
|
|
./afl-compiler-rt-32.o: instrumentation/afl-compiler-rt.o.c
|
|
@printf "[*] Building 32-bit variant of the runtime (-m32)... "
|
|
- @$(CC) $(CFLAGS_SAFE) $(CPPFLAGS) -O3 -Wno-unused-result -m32 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
+ @$(CC) $(CFLAGS) $(CFLAGS_SAFE) $(CPPFLAGS) -Wno-unused-result -m32 -fPIC -fno-lto -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
|
|
./afl-compiler-rt-64.o: instrumentation/afl-compiler-rt.o.c
|
|
@printf "[*] Building 64-bit variant of the runtime (-m64)... "
|
|
- @$(CC) $(CFLAGS_SAFE) $(CPPFLAGS) -O3 -Wno-unused-result -m64 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
+ @$(CC) $(CFLAGS) $(CFLAGS_SAFE) $(CPPFLAGS) -Wno-unused-result -m64 -fPIC -fno-lto -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
|
|
./afl-gcc-pass.so: instrumentation/afl-gcc-pass.so.cc | test_deps
|
|
- $(CXX) $(CXXEFLAGS) $(PLUGIN_FLAGS) -shared $< -o $@
|
|
+ $(CXX) $(CXXEFLAGS) $(PLUGIN_FLAGS) -shared $< -o $@ $(LDFLAGS)
|
|
ln -sf afl-cc afl-gcc-fast
|
|
ln -sf afl-cc afl-g++-fast
|
|
ln -sf afl-cc.8 afl-gcc-fast.8
|
|
--- a/GNUmakefile.llvm
|
|
+++ b/GNUmakefile.llvm
|
|
@@ -410,7 +410,7 @@ endif
|
|
|
|
./afl-ld-lto: src/afl-ld-lto.c
|
|
ifeq "$(LLVM_LTO)" "1"
|
|
- $(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@
|
|
endif
|
|
|
|
./SanitizerCoverageLTO.so: instrumentation/SanitizerCoverageLTO.so.cc instrumentation/afl-llvm-common.o
|
|
@@ -444,25 +444,25 @@ afl-llvm-dict2file.so: instrumentation/afl-llvm-dict2file.so.cc instrumentation/
|
|
|
|
.PHONY: document
|
|
document:
|
|
- $(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -O3 -Wno-unused-result -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt.o
|
|
- @$(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -O3 -Wno-unused-result -m32 -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt-32.o 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
- @$(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -O3 -Wno-unused-result -m64 -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt-64.o 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
+ $(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS) $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -Wno-unused-result -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt.o
|
|
+ @$(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS) $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -Wno-unused-result -m32 -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt-32.o 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
+ @$(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS) $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -Wno-unused-result -m64 -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt-64.o 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
|
|
./afl-compiler-rt.o: instrumentation/afl-compiler-rt.o.c
|
|
- $(CC) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -O3 -Wno-unused-result -fPIC -c $< -o $@
|
|
+ $(CC) $(CFLAGS) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -Wno-unused-result -fPIC -fno-lto -c $< -o $@
|
|
|
|
./afl-compiler-rt-32.o: instrumentation/afl-compiler-rt.o.c
|
|
@printf "[*] Building 32-bit variant of the runtime (-m32)... "
|
|
- @$(CC) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -O3 -Wno-unused-result -m32 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
+ @$(CC) $(CFLAGS) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -Wno-unused-result -m32 -fPIC -fno-lto -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
|
|
./afl-compiler-rt-64.o: instrumentation/afl-compiler-rt.o.c
|
|
@printf "[*] Building 64-bit variant of the runtime (-m64)... "
|
|
- @$(CC) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -O3 -Wno-unused-result -m64 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
+ @$(CC) $(CFLAGS) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -Wno-unused-result -m64 -fPIC -fno-lto -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
|
|
.PHONY: test_build
|
|
test_build: $(PROGS)
|
|
@echo "[*] Testing the CC wrapper and instrumentation output..."
|
|
- unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; ASAN_OPTIONS=detect_leaks=0 AFL_QUIET=1 AFL_PATH=. AFL_LLVM_LAF_ALL=1 ./afl-cc $(CFLAGS) $(CPPFLAGS) ./test-instr.c -o test-instr $(LDFLAGS)
|
|
+ unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; ASAN_OPTIONS=detect_leaks=0 AFL_QUIET=1 AFL_PATH=. AFL_LLVM_LAF_ALL=1 ./afl-cc ./test-instr.c -o test-instr
|
|
ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -m none -q -o .test-instr0 ./test-instr < /dev/null
|
|
echo 1 | ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -m none -q -o .test-instr1 ./test-instr
|
|
@rm -f test-instr
|
|
--- a/custom_mutators/honggfuzz/Makefile
|
|
+++ b/custom_mutators/honggfuzz/Makefile
|
|
@@ -1,5 +1,6 @@
|
|
|
|
-CFLAGS = -O3 -funroll-loops -fPIC -Wl,-Bsymbolic
|
|
+CFLAGS ?= -O3
|
|
+CFLAGS += -funroll-loops -fPIC -Wl,-Bsymbolic
|
|
|
|
all: honggfuzz-mutator.so
|
|
|
|
--- a/custom_mutators/libfuzzer/Makefile
|
|
+++ b/custom_mutators/libfuzzer/Makefile
|
|
@@ -1,5 +1,5 @@
|
|
|
|
-CFLAGS = -g -O3 -funroll-loops -fPIC -fpermissive -std=c++11
|
|
-#CFLAGS = -g -O0 -fPIC -fpermissive -std=c++11
|
|
+CFLAGS ?= -g -O3
|
|
+CFLAGS += -funroll-loops -fpermissive -std=c++11 -fPIC
|
|
CXX ?= clang++
|
|
|
|
--- a/frida_mode/GNUmakefile
|
|
+++ b/frida_mode/GNUmakefile
|
|
@@ -17,7 +17,6 @@ CFLAGS+=-fPIC \
|
|
-D_GNU_SOURCE \
|
|
-D_FORTIFY_SOURCE=2 \
|
|
-g \
|
|
- -O3 \
|
|
-funroll-loops \
|
|
-ffunction-sections \
|
|
|
|
--- a/frida_mode/test/png/persistent/hook/GNUmakefile
|
|
+++ b/frida_mode/test/png/persistent/hook/GNUmakefile
|
|
@@ -5,11 +5,9 @@ BUILD_DIR:=$(PWD)build/
|
|
AFLPP_FRIDA_DRIVER_HOOK_OBJ=$(ROOT)frida_mode/build/frida_hook.so
|
|
AFLPP_QEMU_DRIVER_HOOK_OBJ=$(ROOT)frida_mode/build/qemu_hook.so
|
|
|
|
-CFLAGS+=-O3 \
|
|
- -funroll-loops \
|
|
+CFLAGS+= -funroll-loops \
|
|
-g \
|
|
- -fPIC \
|
|
- -funroll-loops \
|
|
+ -fPIC
|
|
|
|
LDFLAGS+=-shared \
|
|
|
|
--- a/utils/aflpp_driver/GNUmakefile
|
|
+++ b/utils/aflpp_driver/GNUmakefile
|
|
@@ -13,40 +13,42 @@ ifneq "" "$(LLVM_BINDIR)"
|
|
LLVM_BINDIR := $(LLVM_BINDIR)/
|
|
endif
|
|
|
|
-CFLAGS := -O3 -funroll-loops -g -fPIC
|
|
+AR ?= ar
|
|
+CFLAGS ?= -O3 -funroll-loops -g
|
|
+CFLAGS += -fPIC -fno-lto
|
|
|
|
all: libAFLDriver.a libAFLQemuDriver.a aflpp_qemu_driver_hook.so
|
|
|
|
aflpp_driver.o: aflpp_driver.c
|
|
- -$(LLVM_BINDIR)clang -I. -I../../include $(CFLAGS) -c aflpp_driver.c
|
|
+ $(CC) $(CPPFLAGS) -I. -I../../include $(CFLAGS) -c aflpp_driver.c
|
|
|
|
libAFLDriver.a: aflpp_driver.o
|
|
- @ar rc libAFLDriver.a aflpp_driver.o
|
|
+ $(AR) rc libAFLDriver.a aflpp_driver.o
|
|
@cp -vf libAFLDriver.a ../../
|
|
|
|
debug:
|
|
- $(LLVM_BINDIR)clang -Wno-deprecated -I../../include $(CFLAGS) -D_DEBUG=\"1\" -c -o afl-performance.o ../../src/afl-performance.c
|
|
- $(LLVM_BINDIR)clang -I../../include -D_DEBUG=\"1\" -g -funroll-loops -c aflpp_driver.c
|
|
+ $(CC) $(CPPFLAGS) -Wno-deprecated -I../../include $(CFLAGS) -D_DEBUG=\"1\" -c -o afl-performance.o ../../src/afl-performance.c
|
|
+ $(CC) $(CPPFLAGS) -I../../include -D_DEBUG=\"1\" $(CFLAGS) -g -funroll-loops -c aflpp_driver.c
|
|
#$(LLVM_BINDIR)clang -S -emit-llvm -Wno-deprecated -I../../include $(CFLAGS) -D_DEBUG=\"1\" -c -o afl-performance.ll ../../src/afl-performance.c
|
|
#$(LLVM_BINDIR)clang -S -emit-llvm -I../../include -D_DEBUG=\"1\" -g -funroll-loops -c aflpp_driver.c
|
|
- ar rc libAFLDriver.a afl-performance.o aflpp_driver.o
|
|
+ $(AR) rc libAFLDriver.a afl-performance.o aflpp_driver.o
|
|
|
|
aflpp_qemu_driver.o: aflpp_qemu_driver.c
|
|
- -$(LLVM_BINDIR)clang $(CFLAGS) -O0 -funroll-loops -c aflpp_qemu_driver.c
|
|
+ $(CC) $(CPPFLAGS) $(CFLAGS) -O0 -funroll-loops -c aflpp_qemu_driver.c
|
|
|
|
libAFLQemuDriver.a: aflpp_qemu_driver.o
|
|
- @-ar rc libAFLQemuDriver.a aflpp_qemu_driver.o
|
|
- @-cp -vf libAFLQemuDriver.a ../../
|
|
+ $(AR) rc libAFLQemuDriver.a aflpp_qemu_driver.o
|
|
+ @cp -vf libAFLQemuDriver.a ../../
|
|
|
|
aflpp_qemu_driver_hook.so: aflpp_qemu_driver_hook.o
|
|
- @-test -e aflpp_qemu_driver_hook.o && $(LLVM_BINDIR)clang $(LDFLAGS) -shared aflpp_qemu_driver_hook.o -o aflpp_qemu_driver_hook.so || echo "Note: Optional aflpp_qemu_driver_hook.so not built."
|
|
+ @test -e aflpp_qemu_driver_hook.o && $(CC) $(LDFLAGS) -shared aflpp_qemu_driver_hook.o -o aflpp_qemu_driver_hook.so || echo "Note: Optional aflpp_qemu_driver_hook.so not built."
|
|
|
|
aflpp_qemu_driver_hook.o: aflpp_qemu_driver_hook.c
|
|
- @-test -e ../../qemu_mode/qemuafl/qemuafl/api.h && $(LLVM_BINDIR)clang $(CFLAGS) -funroll-loops -c aflpp_qemu_driver_hook.c || echo "Note: Optional aflpp_qemu_driver_hook.o not built."
|
|
+ @test -e ../../qemu_mode/qemuafl/qemuafl/api.h && $(CC) $(CPPFLAGS) $(CFLAGS) -funroll-loops -c aflpp_qemu_driver_hook.c || echo "Note: Optional aflpp_qemu_driver_hook.o not built."
|
|
|
|
test: debug
|
|
#clang -S -emit-llvm -D_DEBUG=\"1\" -I../../include -Wl,--allow-multiple-definition -funroll-loops -o aflpp_driver_test.ll aflpp_driver_test.c
|
|
- afl-clang-fast -D_DEBUG=\"1\" -I../../include -Wl,--allow-multiple-definition -funroll-loops -o aflpp_driver_test aflpp_driver_test.c libAFLDriver.a afl-performance.o
|
|
+ ../../afl-clang-fast -D_DEBUG=\"1\" -I../../include -Wl,--allow-multiple-definition -funroll-loops -o aflpp_driver_test aflpp_driver_test.c libAFLDriver.a afl-performance.o
|
|
|
|
clean:
|
|
rm -f *.o libAFLDriver*.a libAFLQemuDriver.a aflpp_qemu_driver_hook.so *~ core aflpp_driver_test
|