better performance compilation options for afl++ and targets

This commit is contained in:
van Hauser 2020-05-26 13:19:57 +02:00
parent 0994972c07
commit 996e1515b3
9 changed files with 46 additions and 41 deletions

View File

@ -51,11 +51,11 @@ endif
endif
ifneq "$(shell uname)" "Darwin"
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -Werror -x c - -march=native -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
CFLAGS_OPT += -march=native
endif
#ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -Werror -x c - -march=native -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
# CFLAGS_OPT += -march=native
#endif
# OS X does not like _FORTIFY_SOURCE=2
# CFLAGS_OPT += -D_FORTIFY_SOURCE=2
CFLAGS_OPT += -D_FORTIFY_SOURCE=2
endif
ifdef STATIC

View File

@ -9,6 +9,7 @@
- learn from honggfuzz
- for persistent mode, have a functionality that transports the test case
via shared memory (and the int write to the FD from afl-fuzz is the size)
- CPU affinity for many cores?
## Further down the road

View File

@ -32,6 +32,7 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
- fixed crash in compare-transform-pass when strcasecmp/strncasecmp was
tried to be instrumented with LTO
- fixed crash in cmplog with LTO
- slightly better performance compilation options for afl++ and targets
- fixed afl-gcc/afl-as that could break on fast systems reusing pids in
the same second
- added lots of dictionaries from oss-fuzz, go-fuzz and Jakub Wilk

View File

@ -0,0 +1,27 @@
ifeq "" "$(LLVM_CONFIG)"
LLVM_CONFIG=llvm-config
endif
LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null)
ifneq "" "$(LLVM_BINDIR)"
LLVM_BINDIR := $(LLVM_BINDIR)/
endif
FLAGS=-O3 -funroll-loops
all: libAFLDriver.a libAFLDriver2.a
aflpp_driver.o: aflpp_driver.cpp
$(LLVM_BINDIR)clang++ $(FLAGS) -stdlib=libc++ -funroll-loops -std=c++11 -c aflpp_driver.cpp
afl-llvm-rt.o: ../../llvm_mode/afl-llvm-rt.o.c
$(LLVM_BINDIR)clang $(FLAGS) -I../../include -c -o afl-llvm-rt.o ../../llvm_mode/afl-llvm-rt.o.c
libAFLDriver.a: aflpp_driver.o
ar ru libAFLDriver.a aflpp_driver.o
libAFLDriver2.a: aflpp_driver.o afl-llvm-rt.o
ar ru libAFLDriver2.a aflpp_driver.o afl-llvm-rt.o
clean:
rm -f *.o libAFLDriver*.a *~ core

View File

@ -1,24 +1,2 @@
ifeq "" "$(LLVM_CONFIG)"
LLVM_CONFIG=llvm-config
endif
LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null)
ifneq "" "$(LLVM_BINDIR)"
LLVM_BINDIR := $(LLVM_BINDIR)/
endif
all: libAFLDriver.a
aflpp_driver.o: aflpp_driver.cpp
$(LLVM_BINDIR)clang++ -O3 -march=native -stdlib=libc++ -funroll-loops -std=c++11 -c aflpp_driver.cpp
afl-llvm-rt.o: ../../llvm_mode/afl-llvm-rt.o.c
$(LLVM_BINDIR)clang++ -O3 -march=native -funroll-loops -stdlib=libc++ -std=c++11 -c aflpp_driver.cpp
libAFLDriver.a: aflpp_driver.o afl-llvm-rt.o
ar ru libAFLDriver.a aflpp_driver.o
clean:
rm -f *.o libAFLDriver.a *~ core
all:
@gmake all || echo please install GNUmake

View File

@ -160,9 +160,9 @@ endif
# After we set CC/CXX we can start makefile magic tests
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -march=native -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
CFLAGS_OPT = -march=native
endif
#ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -march=native -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
# CFLAGS_OPT = -march=native
#endif
ifeq "$(shell echo 'int main() {return 0; }' | $(CLANG_BIN) -x c - -flto=full -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
AFL_CLANG_FLTO ?= -flto=full
@ -196,8 +196,7 @@ ifeq "$(shell echo 'int main() {return 0; }' | $(CLANG_BIN) -x c - -fuse-ld=`com
endif
endif
CFLAGS ?= -O3 -funroll-loops
# -D_FORTIFY_SOURCE=2
CFLAGS ?= -O3 -funroll-loops -D_FORTIFY_SOURCE=2
override CFLAGS += -Wall \
-g -Wno-pointer-sign -I ../include/ \
-DAFL_PATH=\"$(HELPER_PATH)\" -DBIN_PATH=\"$(BIN_PATH)\" \
@ -210,8 +209,7 @@ ifdef AFL_TRACE_PC
$(info Compile option AFL_TRACE_PC is deprecated, just set AFL_LLVM_INSTRUMENT=PCGUARD to activate when compiling targets )
endif
CXXFLAGS ?= -O3 -funroll-loops
# -D_FORTIFY_SOURCE=2
CXXFLAGS ?= -O3 -funroll-loops -D_FORTIFY_SOURCE=2
override CXXFLAGS += -Wall -g -I ../include/ \
-DVERSION=\"$(VERSION)\" -Wno-variadic-macros

View File

@ -1,2 +1,2 @@
all:
@echo please use GNU make, thanks!
@gmake all || echo please install GNUmake

View File

@ -335,7 +335,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
}
cc_params[cc_par_cnt++] = "-Qunused-arguments";
//cc_params[cc_par_cnt++] = "-Qunused-arguments";
// in case LLVM is installed not via a package manager or "make install"
// e.g. compiled download or compiled from github then it's ./lib directory
@ -440,8 +440,8 @@ static void edit_params(u32 argc, char **argv, char **envp) {
cc_params[cc_par_cnt++] = "-g";
cc_params[cc_par_cnt++] = "-O3";
cc_params[cc_par_cnt++] = "-funroll-loops";
if (strlen(march_opt) > 1 && march_opt[0] == '-')
cc_params[cc_par_cnt++] = march_opt;
//if (strlen(march_opt) > 1 && march_opt[0] == '-')
// cc_params[cc_par_cnt++] = march_opt;
}

View File

@ -789,12 +789,12 @@ void __sanitizer_cov_trace_pc_guard(uint32_t *guard) {
void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
u32 inst_ratio = 100;
u8 *x;
char *x;
if (start == stop || *start) return;
x = getenv("AFL_INST_RATIO");
if (x) inst_ratio = atoi(x);
if (x) inst_ratio = (u32)atoi(x);
if (!inst_ratio || inst_ratio > 100) {