aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-05-26 13:19:57 +0200
committervan Hauser <vh@thc.org>2020-05-26 13:19:57 +0200
commit996e1515b320fb2d44c367dea7b4d26f2d56f5df (patch)
tree6a298c420819aa9a22feae38bf88385d305d6e41
parent0994972c07333af3a1fecf694c6527517da966ca (diff)
downloadafl++-996e1515b320fb2d44c367dea7b4d26f2d56f5df.tar.gz
better performance compilation options for afl++ and targets
-rw-r--r--GNUmakefile8
-rw-r--r--TODO.md1
-rw-r--r--docs/Changelog.md1
-rw-r--r--examples/aflpp_driver/GNUmakefile27
-rw-r--r--examples/aflpp_driver/Makefile26
-rw-r--r--llvm_mode/GNUmakefile12
-rw-r--r--llvm_mode/Makefile2
-rw-r--r--llvm_mode/afl-clang-fast.c6
-rw-r--r--llvm_mode/afl-llvm-rt.o.c4
9 files changed, 46 insertions, 41 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 0cb9ede8..14ecfaad 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -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
diff --git a/TODO.md b/TODO.md
index 3ee8d091..b7d51369 100644
--- a/TODO.md
+++ b/TODO.md
@@ -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
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 9d4d7815..5f404dba 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -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
diff --git a/examples/aflpp_driver/GNUmakefile b/examples/aflpp_driver/GNUmakefile
new file mode 100644
index 00000000..fca3fd2c
--- /dev/null
+++ b/examples/aflpp_driver/GNUmakefile
@@ -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
diff --git a/examples/aflpp_driver/Makefile b/examples/aflpp_driver/Makefile
index 6f7c7bc9..3666a74d 100644
--- a/examples/aflpp_driver/Makefile
+++ b/examples/aflpp_driver/Makefile
@@ -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
diff --git a/llvm_mode/GNUmakefile b/llvm_mode/GNUmakefile
index a41dfbdf..50a6be2b 100644
--- a/llvm_mode/GNUmakefile
+++ b/llvm_mode/GNUmakefile
@@ -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
diff --git a/llvm_mode/Makefile b/llvm_mode/Makefile
index 0b306dde..3666a74d 100644
--- a/llvm_mode/Makefile
+++ b/llvm_mode/Makefile
@@ -1,2 +1,2 @@
all:
- @echo please use GNU make, thanks!
+ @gmake all || echo please install GNUmake
diff --git a/llvm_mode/afl-clang-fast.c b/llvm_mode/afl-clang-fast.c
index e8f20bb2..fb072651 100644
--- a/llvm_mode/afl-clang-fast.c
+++ b/llvm_mode/afl-clang-fast.c
@@ -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;
}
diff --git a/llvm_mode/afl-llvm-rt.o.c b/llvm_mode/afl-llvm-rt.o.c
index a461bc03..b151de8e 100644
--- a/llvm_mode/afl-llvm-rt.o.c
+++ b/llvm_mode/afl-llvm-rt.o.c
@@ -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) {