mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-18 20:48:07 +00:00
rename all 'Makefile' to 'GNUmakefile', use -Werror for -flto checks
This commit is contained in:
477
GNUmakefile
Normal file
477
GNUmakefile
Normal file
@ -0,0 +1,477 @@
|
|||||||
|
#
|
||||||
|
# american fuzzy lop++ - makefile
|
||||||
|
# -----------------------------
|
||||||
|
#
|
||||||
|
# Originally written by Michal Zalewski
|
||||||
|
#
|
||||||
|
# Copyright 2013, 2014, 2015, 2016, 2017 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
# For Heiko:
|
||||||
|
#TEST_MMAP=1
|
||||||
|
# the hash character is treated differently in different make versions
|
||||||
|
# so use a variable for '#'
|
||||||
|
HASH=\#
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
BIN_PATH = $(PREFIX)/bin
|
||||||
|
HELPER_PATH = $(PREFIX)/lib/afl
|
||||||
|
DOC_PATH = $(PREFIX)/share/doc/afl
|
||||||
|
MISC_PATH = $(PREFIX)/share/afl
|
||||||
|
MAN_PATH = $(PREFIX)/man/man8
|
||||||
|
|
||||||
|
PROGNAME = afl
|
||||||
|
VERSION = $(shell grep '^$(HASH)define VERSION ' ../config.h | cut -d '"' -f2)
|
||||||
|
|
||||||
|
# PROGS intentionally omit afl-as, which gets installed elsewhere.
|
||||||
|
|
||||||
|
PROGS = afl-gcc afl-fuzz afl-showmap afl-tmin afl-gotcpu afl-analyze
|
||||||
|
SH_PROGS = afl-plot afl-cmin afl-cmin.bash afl-whatsup afl-system-config
|
||||||
|
MANPAGES=$(foreach p, $(PROGS) $(SH_PROGS), $(p).8) afl-as.8
|
||||||
|
ASAN_OPTIONS=detect_leaks=0
|
||||||
|
|
||||||
|
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -Werror -x c - -flto=full -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
||||||
|
CFLAGS_FLTO ?= -flto=full
|
||||||
|
else
|
||||||
|
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -Werror -x c - -flto=thin -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
||||||
|
CFLAGS_FLTO ?= -flto=thin
|
||||||
|
else
|
||||||
|
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -Werror -x c - -flto -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
||||||
|
CFLAGS_FLTO ?= -flto
|
||||||
|
endif
|
||||||
|
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
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(shell uname -m)" "x86_64"
|
||||||
|
ifneq "$(shell uname -m)" "i386"
|
||||||
|
ifneq "$(shell uname -m)" "amd64"
|
||||||
|
ifneq "$(shell uname -m)" "i86pc"
|
||||||
|
AFL_NO_X86=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS ?= -O3 -funroll-loops $(CFLAGS_OPT) -D_FORTIFY_SOURCE=2
|
||||||
|
override CFLAGS += -Wall -g -Wno-pointer-sign \
|
||||||
|
-I include/ -Werror -DAFL_PATH=\"$(HELPER_PATH)\" \
|
||||||
|
-DBIN_PATH=\"$(BIN_PATH)\" -DDOC_PATH=\"$(DOC_PATH)\"
|
||||||
|
|
||||||
|
AFL_FUZZ_FILES = $(wildcard src/afl-fuzz*.c)
|
||||||
|
|
||||||
|
ifneq "$(shell type python3m 2>/dev/null)" ""
|
||||||
|
ifneq "$(shell type python3m-config 2>/dev/null)" ""
|
||||||
|
PYTHON_INCLUDE ?= $(shell python3m-config --includes)
|
||||||
|
PYTHON_VERSION ?= $(strip $(shell python3m --version 2>&1))
|
||||||
|
# Starting with python3.8, we need to pass the `embed` flag. Earier versions didn't know this flag.
|
||||||
|
ifeq "$(shell python3m-config --embed --libs 2>/dev/null | grep -q lpython && echo 1 )" "1"
|
||||||
|
PYTHON_LIB ?= $(shell python3m-config --libs --embed)
|
||||||
|
else
|
||||||
|
PYTHON_LIB ?= $(shell python3m-config --ldflags)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(shell type python3 2>/dev/null)" ""
|
||||||
|
ifneq "$(shell type python3-config 2>/dev/null)" ""
|
||||||
|
PYTHON_INCLUDE ?= $(shell python3-config --includes)
|
||||||
|
PYTHON_VERSION ?= $(strip $(shell python3 --version 2>&1))
|
||||||
|
# Starting with python3.8, we need to pass the `embed` flag. Earier versions didn't know this flag.
|
||||||
|
ifeq "$(shell python3-config --embed --libs 2>/dev/null | grep -q lpython && echo 1 )" "1"
|
||||||
|
PYTHON_LIB ?= $(shell python3-config --libs --embed)
|
||||||
|
else
|
||||||
|
PYTHON_LIB ?= $(shell python3-config --ldflags)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(shell type python 2>/dev/null)" ""
|
||||||
|
ifneq "$(shell type python-config 2>/dev/null)" ""
|
||||||
|
PYTHON_INCLUDE ?= $(shell python-config --includes)
|
||||||
|
PYTHON_LIB ?= $(shell python-config --ldflags)
|
||||||
|
PYTHON_VERSION ?= $(strip $(shell python --version 2>&1))
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef SOURCE_DATE_EPOCH
|
||||||
|
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d" 2>/dev/null || date -u "+%Y-%m-%d")
|
||||||
|
else
|
||||||
|
BUILD_DATE ?= $(shell date "+%Y-%m-%d")
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(filter Linux GNU%,$(shell uname))" ""
|
||||||
|
LDFLAGS += -ldl
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(findstring FreeBSD, $(shell uname))" ""
|
||||||
|
CFLAGS += -pthread
|
||||||
|
LDFLAGS += -lpthread
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(findstring NetBSD, $(shell uname))" ""
|
||||||
|
CFLAGS += -pthread
|
||||||
|
LDFLAGS += -lpthread
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(findstring clang, $(shell $(CC) --version 2>/dev/null))" ""
|
||||||
|
TEST_CC = afl-gcc
|
||||||
|
else
|
||||||
|
TEST_CC = afl-clang
|
||||||
|
endif
|
||||||
|
|
||||||
|
COMM_HDR = include/alloc-inl.h include/config.h include/debug.h include/types.h
|
||||||
|
|
||||||
|
ifeq "$(shell echo '$(HASH)include <Python.h>@int main() {return 0; }' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test $(PYTHON_INCLUDE) $(LDFLAGS) $(PYTHON_LIB) 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
||||||
|
PYTHON_OK=1
|
||||||
|
PYFLAGS=-DUSE_PYTHON $(PYTHON_INCLUDE) $(LDFLAGS) $(PYTHON_LIB) -DPYTHON_VERSION="\"$(PYTHON_VERSION)\""
|
||||||
|
else
|
||||||
|
PYTHON_OK=0
|
||||||
|
PYFLAGS=
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef STATIC
|
||||||
|
$(info Compiling static version of binaries)
|
||||||
|
# Disable python for static compilation to simplify things
|
||||||
|
PYTHON_OK=0
|
||||||
|
PYFLAGS=
|
||||||
|
|
||||||
|
CFLAGS += -static
|
||||||
|
LDFLAGS += -lm -lpthread -lz -lutil
|
||||||
|
endif
|
||||||
|
|
||||||
|
ASAN_CFLAGS=-fsanitize=address -fstack-protector-all -fno-omit-frame-pointer
|
||||||
|
ASAN_LDFLAGS+=-fsanitize=address -fstack-protector-all -fno-omit-frame-pointer
|
||||||
|
|
||||||
|
ifdef ASAN_BUILD
|
||||||
|
$(info Compiling ASAN version of binaries)
|
||||||
|
CFLAGS+=$(ASAN_CFLAGS)
|
||||||
|
LDFLAGS+=$(ASAN_LDFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef PROFILING
|
||||||
|
$(info Compiling profiling version of binaries)
|
||||||
|
CFLAGS+=-pg
|
||||||
|
LDFLAGS+=-pg
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(shell echo '$(HASH)include <sys/ipc.h>@$(HASH)include <sys/shm.h>@int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1"
|
||||||
|
SHMAT_OK=1
|
||||||
|
else
|
||||||
|
SHMAT_OK=0
|
||||||
|
CFLAGS+=-DUSEMMAP=1
|
||||||
|
LDFLAGS+=-Wno-deprecated-declarations
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(TEST_MMAP)" "1"
|
||||||
|
SHMAT_OK=0
|
||||||
|
CFLAGS+=-DUSEMMAP=1
|
||||||
|
LDFLAGS+=-Wno-deprecated-declarations
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: test_x86 test_shm test_python ready $(PROGS) afl-as test_build all_done
|
||||||
|
|
||||||
|
man: $(MANPAGES)
|
||||||
|
-$(MAKE) -C llvm_mode
|
||||||
|
-$(MAKE) -C gcc_plugin
|
||||||
|
|
||||||
|
tests: source-only
|
||||||
|
@cd test ; ./test.sh
|
||||||
|
@rm -f test/errors
|
||||||
|
|
||||||
|
performance-tests: performance-test
|
||||||
|
test-performance: performance-test
|
||||||
|
|
||||||
|
performance-test: source-only
|
||||||
|
@cd test ; ./test-performance.sh
|
||||||
|
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "HELP --- the following make targets exist:"
|
||||||
|
@echo "=========================================="
|
||||||
|
@echo "all: just the main afl++ binaries"
|
||||||
|
@echo "binary-only: everything for binary-only fuzzing: qemu_mode, unicorn_mode, libdislocator, libtokencap, radamsa"
|
||||||
|
@echo "source-only: everything for source code fuzzing: llvm_mode, gcc_plugin, libdislocator, libtokencap, radamsa"
|
||||||
|
@echo "distrib: everything (for both binary-only and source code fuzzing)"
|
||||||
|
@echo "man: creates simple man pages from the help option of the programs"
|
||||||
|
@echo "install: installs everything you have compiled with the build option above"
|
||||||
|
@echo "clean: cleans everything. for qemu_mode it means it deletes all downloads as well"
|
||||||
|
@echo "code-format: format the code, do this before you commit and send a PR please!"
|
||||||
|
@echo "tests: this runs the test framework. It is more catered for the developers, but if you run into problems this helps pinpointing the problem"
|
||||||
|
@echo "unit: perform unit tests (based on cmocka)"
|
||||||
|
@echo "document: creates afl-fuzz-document which will only do one run and save all manipulated inputs into out/queue/mutations"
|
||||||
|
@echo "help: shows these build options :-)"
|
||||||
|
@echo "=========================================="
|
||||||
|
@echo "Recommended: \"distrib\" or \"source-only\", then \"install\""
|
||||||
|
@echo
|
||||||
|
@echo Known build environment options:
|
||||||
|
@echo "=========================================="
|
||||||
|
@echo STATIC - compile AFL++ static
|
||||||
|
@echo ASAN_BUILD - compiles with memory sanitizer for debug purposes
|
||||||
|
@echo PROFILING - compile afl-fuzz with profiling information
|
||||||
|
@echo AFL_NO_X86 - if compiling on non-intel/amd platforms
|
||||||
|
@echo "=========================================="
|
||||||
|
@echo e.g.: make ASAN_BUILD=1
|
||||||
|
|
||||||
|
ifndef AFL_NO_X86
|
||||||
|
|
||||||
|
test_x86:
|
||||||
|
@echo "[*] Checking for the default compiler cc..."
|
||||||
|
@type $(CC) >/dev/null || ( echo; echo "Oops, looks like there is no compiler '"$(CC)"' in your path."; echo; echo "Don't panic! You can restart with '"$(_)" CC=<yourCcompiler>'."; echo; exit 1 )
|
||||||
|
@echo "[*] Checking for the ability to compile x86 code..."
|
||||||
|
@echo 'main() { __asm__("xorb %al, %al"); }' | $(CC) $(CFLAGS) -w -x c - -o .test1 || ( echo; echo "Oops, looks like your compiler can't generate x86 code."; echo; echo "Don't panic! You can use the LLVM or QEMU mode, but see docs/INSTALL first."; echo "(To ignore this error, set AFL_NO_X86=1 and try again.)"; echo; exit 1 )
|
||||||
|
@rm -f .test1
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
test_x86:
|
||||||
|
@echo "[!] Note: skipping x86 compilation checks (AFL_NO_X86 set)."
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ifeq "$(SHMAT_OK)" "1"
|
||||||
|
|
||||||
|
test_shm:
|
||||||
|
@echo "[+] shmat seems to be working."
|
||||||
|
@rm -f .test2
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
test_shm:
|
||||||
|
@echo "[-] shmat seems not to be working, switching to mmap implementation"
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ifeq "$(PYTHON_OK)" "1"
|
||||||
|
|
||||||
|
test_python:
|
||||||
|
@rm -f .test 2> /dev/null
|
||||||
|
@echo "[+] $(PYTHON_VERSION) support seems to be working."
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
test_python:
|
||||||
|
@echo "[-] You seem to need to install the package python3-dev or python2-dev (and perhaps python[23]-apt), but it is optional so we continue"
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ready:
|
||||||
|
@echo "[+] Everything seems to be working, ready to compile."
|
||||||
|
|
||||||
|
afl-gcc: src/afl-gcc.c $(COMM_HDR) | test_x86
|
||||||
|
$(CC) $(CFLAGS) src/$@.c -o $@ $(LDFLAGS)
|
||||||
|
set -e; for i in afl-g++ afl-clang afl-clang++; do ln -sf afl-gcc $$i; done
|
||||||
|
|
||||||
|
afl-as: src/afl-as.c include/afl-as.h $(COMM_HDR) | test_x86
|
||||||
|
$(CC) $(CFLAGS) src/$@.c -o $@ $(LDFLAGS)
|
||||||
|
ln -sf afl-as as
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
src/afl-forkserver.o : $(COMM_HDR) src/afl-forkserver.c include/forkserver.h
|
||||||
|
$(CC) $(CFLAGS) $(CFLAGS_FLTO) -c src/afl-forkserver.c -o src/afl-forkserver.o
|
||||||
|
|
||||||
|
src/afl-sharedmem.o : $(COMM_HDR) src/afl-sharedmem.c include/sharedmem.h
|
||||||
|
$(CC) $(CFLAGS) $(CFLAGS_FLTO) -c src/afl-sharedmem.c -o src/afl-sharedmem.o
|
||||||
|
|
||||||
|
radamsa: src/third_party/libradamsa/libradamsa.so
|
||||||
|
cp src/third_party/libradamsa/libradamsa.so .
|
||||||
|
|
||||||
|
src/third_party/libradamsa/libradamsa.so: src/third_party/libradamsa/libradamsa.c src/third_party/libradamsa/radamsa.h
|
||||||
|
$(MAKE) -C src/third_party/libradamsa/ CFLAGS="$(CFLAGS)"
|
||||||
|
|
||||||
|
afl-fuzz: $(COMM_HDR) include/afl-fuzz.h $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o | test_x86
|
||||||
|
$(CC) $(CFLAGS) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(PYFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
|
afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o $(COMM_HDR) | test_x86
|
||||||
|
$(CC) $(CFLAGS) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
afl-tmin: src/afl-tmin.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o $(COMM_HDR) | test_x86
|
||||||
|
$(CC) $(CFLAGS) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
afl-analyze: src/afl-analyze.c src/afl-common.o src/afl-sharedmem.o $(COMM_HDR) | test_x86
|
||||||
|
$(CC) $(CFLAGS) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
afl-gotcpu: src/afl-gotcpu.c src/afl-common.o $(COMM_HDR) | test_x86
|
||||||
|
$(CC) $(CFLAGS) src/$@.c src/afl-common.o -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# document all mutations and only do one run (use with only one input file!)
|
||||||
|
document: $(COMM_HDR) include/afl-fuzz.h $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o | test_x86
|
||||||
|
$(CC) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o afl-fuzz-document $(PYFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
|
test/unittests/unit_maybe_alloc.o : $(COMM_HDR) include/alloc-inl.h test/unittests/unit_maybe_alloc.c $(AFL_FUZZ_FILES)
|
||||||
|
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -c test/unittests/unit_maybe_alloc.c -o test/unittests/unit_maybe_alloc.o
|
||||||
|
|
||||||
|
test/unittests/unit_preallocable.o : $(COMM_HDR) include/alloc-inl.h test/unittests/unit_preallocable.c $(AFL_FUZZ_FILES)
|
||||||
|
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -c test/unittests/unit_preallocable.c -o test/unittests/unit_preallocable.o
|
||||||
|
|
||||||
|
unit_maybe_alloc: test/unittests/unit_maybe_alloc.o
|
||||||
|
$(CC) $(CFLAGS) -Wl,--wrap=exit -Wl,--wrap=printf test/unittests/unit_maybe_alloc.o -o test/unittests/unit_maybe_alloc $(LDFLAGS) $(ASAN_LDFLAGS) -lcmocka
|
||||||
|
./test/unittests/unit_maybe_alloc
|
||||||
|
|
||||||
|
test/unittests/unit_list.o : $(COMM_HDR) include/list.h test/unittests/unit_list.c $(AFL_FUZZ_FILES)
|
||||||
|
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -c test/unittests/unit_list.c -o test/unittests/unit_list.o
|
||||||
|
|
||||||
|
unit_list: test/unittests/unit_list.o
|
||||||
|
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -Wl,--wrap=exit -Wl,--wrap=printf test/unittests/unit_list.o -o test/unittests/unit_list $(LDFLAGS) $(ASAN_LDFLAGS) -lcmocka
|
||||||
|
./test/unittests/unit_list
|
||||||
|
|
||||||
|
test/unittests/preallocable.o : $(COMM_HDR) include/afl-prealloc.h test/unittests/preallocable.c $(AFL_FUZZ_FILES)
|
||||||
|
$(CC) $(CFLAGS) $(ASAN_CFLAGS) $(CFLAGS_FLTO) -c test/unittests/preallocable.c -o test/unittests/preallocable.o
|
||||||
|
|
||||||
|
unit_preallocable: test/unittests/unit_preallocable.o
|
||||||
|
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -Wl,--wrap=exit -Wl,--wrap=printf test/unittests/unit_preallocable.o -o test/unittests/unit_preallocable $(LDFLAGS) $(ASAN_LDFLAGS) -lcmocka
|
||||||
|
./test/unittests/unit_preallocable
|
||||||
|
|
||||||
|
unit: unit_maybe_alloc unit_preallocable unit_list
|
||||||
|
|
||||||
|
code-format:
|
||||||
|
./.custom-format.py -i src/*.c
|
||||||
|
./.custom-format.py -i include/*.h
|
||||||
|
./.custom-format.py -i libdislocator/*.c
|
||||||
|
./.custom-format.py -i libtokencap/*.c
|
||||||
|
./.custom-format.py -i llvm_mode/*.c
|
||||||
|
./.custom-format.py -i llvm_mode/*.h
|
||||||
|
./.custom-format.py -i llvm_mode/*.cc
|
||||||
|
./.custom-format.py -i gcc_plugin/*.c
|
||||||
|
#./.custom-format.py -i gcc_plugin/*.h
|
||||||
|
./.custom-format.py -i gcc_plugin/*.cc
|
||||||
|
./.custom-format.py -i examples/*/*.c
|
||||||
|
./.custom-format.py -i examples/*/*.h
|
||||||
|
./.custom-format.py -i qemu_mode/patches/*.h
|
||||||
|
./.custom-format.py -i qemu_mode/libcompcov/*.c
|
||||||
|
./.custom-format.py -i qemu_mode/libcompcov/*.cc
|
||||||
|
./.custom-format.py -i qemu_mode/libcompcov/*.h
|
||||||
|
./.custom-format.py -i qbdi_mode/*.c
|
||||||
|
./.custom-format.py -i qbdi_mode/*.cpp
|
||||||
|
./.custom-format.py -i *.h
|
||||||
|
./.custom-format.py -i *.c
|
||||||
|
|
||||||
|
|
||||||
|
ifndef AFL_NO_X86
|
||||||
|
|
||||||
|
test_build: afl-gcc afl-as afl-showmap
|
||||||
|
@echo "[*] Testing the CC wrapper and instrumentation output..."
|
||||||
|
@unset AFL_USE_ASAN AFL_USE_MSAN AFL_CC; AFL_DEBUG=1 AFL_INST_RATIO=100 AFL_PATH=. ./$(TEST_CC) $(CFLAGS) test-instr.c -o test-instr $(LDFLAGS) 2>&1 | grep 'afl-as' >/dev/null || (echo "Oops, afl-as did not get called from "$(TEST_CC)". This is normally achieved by "$(CC)" honoring the -B option."; 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
|
||||||
|
@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please post to https://github.com/AFLplusplus/AFLplusplus/issues to troubleshoot the issue."; echo; exit 1; fi
|
||||||
|
@echo "[+] All right, the instrumentation seems to be working!"
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
test_build: afl-gcc afl-as afl-showmap
|
||||||
|
@echo "[!] Note: skipping build tests (you may need to use LLVM or QEMU mode)."
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
all_done: test_build
|
||||||
|
@if [ ! "`type clang 2>/dev/null`" = "" ]; then echo "[+] LLVM users: see llvm_mode/README.md for a faster alternative to afl-gcc."; fi
|
||||||
|
@echo "[+] All done! Be sure to review the README.md - it's pretty short and useful."
|
||||||
|
@if [ "`uname`" = "Darwin" ]; then printf "\nWARNING: Fuzzing on MacOS X is slow because of the unusually high overhead of\nfork() on this OS. Consider using Linux or *BSD. You can also use VirtualBox\n(virtualbox.org) to put AFL inside a Linux or *BSD VM.\n\n"; fi
|
||||||
|
@! tty <&1 >/dev/null || printf "\033[0;30mNOTE: If you can read this, your terminal probably uses white background.\nThis will make the UI hard to read. See docs/status_screen.md for advice.\033[0m\n" 2>/dev/null
|
||||||
|
|
||||||
|
.NOTPARALLEL: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(PROGS) libradamsa.so afl-fuzz-document afl-as as afl-g++ afl-clang afl-clang++ *.o src/*.o *~ a.out core core.[1-9][0-9]* *.stackdump .test .test1 .test2 test-instr .test-instr0 .test-instr1 qemu_mode/qemu-3.1.1.tar.xz afl-qemu-trace afl-gcc-fast afl-gcc-pass.so afl-gcc-rt.o afl-g++-fast ld *.so *.8 test/unittests/*.o test/unittests/unit_maybe_alloc test/unittests/preallocable
|
||||||
|
rm -rf out_dir qemu_mode/qemu-3.1.1 *.dSYM */*.dSYM
|
||||||
|
-$(MAKE) -C llvm_mode clean
|
||||||
|
-$(MAKE) -C gcc_plugin clean
|
||||||
|
$(MAKE) -C libdislocator clean
|
||||||
|
$(MAKE) -C libtokencap clean
|
||||||
|
$(MAKE) -C examples/socket_fuzzing clean
|
||||||
|
$(MAKE) -C examples/argv_fuzzing clean
|
||||||
|
$(MAKE) -C qemu_mode/unsigaction clean
|
||||||
|
$(MAKE) -C qemu_mode/libcompcov clean
|
||||||
|
$(MAKE) -C src/third_party/libradamsa/ clean
|
||||||
|
-rm -rf unicorn_mode/unicornafl
|
||||||
|
|
||||||
|
distrib: all radamsa
|
||||||
|
-$(MAKE) -C llvm_mode
|
||||||
|
-$(MAKE) -C gcc_plugin
|
||||||
|
$(MAKE) -C libdislocator
|
||||||
|
$(MAKE) -C libtokencap
|
||||||
|
$(MAKE) -C examples/socket_fuzzing
|
||||||
|
$(MAKE) -C examples/argv_fuzzing
|
||||||
|
cd qemu_mode && sh ./build_qemu_support.sh
|
||||||
|
cd unicorn_mode && sh ./build_unicorn_support.sh
|
||||||
|
|
||||||
|
binary-only: all radamsa
|
||||||
|
$(MAKE) -C libdislocator
|
||||||
|
$(MAKE) -C libtokencap
|
||||||
|
$(MAKE) -C examples/socket_fuzzing
|
||||||
|
$(MAKE) -C examples/argv_fuzzing
|
||||||
|
cd qemu_mode && sh ./build_qemu_support.sh
|
||||||
|
cd unicorn_mode && sh ./build_unicorn_support.sh
|
||||||
|
|
||||||
|
source-only: all radamsa
|
||||||
|
-$(MAKE) -C llvm_mode
|
||||||
|
-$(MAKE) -C gcc_plugin
|
||||||
|
$(MAKE) -C libdislocator
|
||||||
|
$(MAKE) -C libtokencap
|
||||||
|
|
||||||
|
%.8: %
|
||||||
|
@echo .TH $* 8 $(BUILD_DATE) "afl++" > $@
|
||||||
|
@echo .SH NAME >> $@
|
||||||
|
@echo .B $* >> $@
|
||||||
|
@echo >> $@
|
||||||
|
@echo .SH SYNOPSIS >> $@
|
||||||
|
@./$* -h 2>&1 | head -n 3 | tail -n 1 | sed 's/^\.\///' >> $@
|
||||||
|
@echo >> $@
|
||||||
|
@echo .SH OPTIONS >> $@
|
||||||
|
@echo .nf >> $@
|
||||||
|
@./$* -hh 2>&1 | tail -n +4 >> $@
|
||||||
|
@echo >> $@
|
||||||
|
@echo .SH AUTHOR >> $@
|
||||||
|
@echo "afl++ was written by Michal \"lcamtuf\" Zalewski and is maintained by Marc \"van Hauser\" Heuse <mh@mh-sec.de>, Heiko \"hexcoder-\" Eissfeldt <heiko.eissfeldt@hexco.de>, Andrea Fioraldi <andreafioraldi@gmail.com> and Dominik Maier <domenukk@gmail.com>" >> $@
|
||||||
|
@echo The homepage of afl++ is: https://github.com/AFLplusplus/AFLplusplus >> $@
|
||||||
|
@echo >> $@
|
||||||
|
@echo .SH LICENSE >> $@
|
||||||
|
@echo Apache License Version 2.0, January 2004 >> $@
|
||||||
|
|
||||||
|
install: all $(MANPAGES)
|
||||||
|
install -d -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(HELPER_PATH) $${DESTDIR}$(DOC_PATH) $${DESTDIR}$(MISC_PATH)
|
||||||
|
rm -f $${DESTDIR}$(BIN_PATH)/afl-plot.sh
|
||||||
|
install -m 755 $(PROGS) $(SH_PROGS) $${DESTDIR}$(BIN_PATH)
|
||||||
|
rm -f $${DESTDIR}$(BIN_PATH)/afl-as
|
||||||
|
if [ -f afl-qemu-trace ]; then install -m 755 afl-qemu-trace $${DESTDIR}$(BIN_PATH); fi
|
||||||
|
if [ -f afl-gcc-fast ]; then set e; install -m 755 afl-gcc-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-gcc-fast $${DESTDIR}$(BIN_PATH)/afl-g++-fast; install -m 755 afl-gcc-pass.so afl-gcc-rt.o $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
$(MAKE) -C llvm_mode install
|
||||||
|
if [ -f libdislocator.so ]; then set -e; install -m 755 libdislocator.so $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f libtokencap.so ]; then set -e; install -m 755 libtokencap.so $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f libcompcov.so ]; then set -e; install -m 755 libcompcov.so $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f libradamsa.so ]; then set -e; install -m 755 libradamsa.so $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f afl-fuzz-document ]; then set -e; install -m 755 afl-fuzz-document $${DESTDIR}$(BIN_PATH); fi
|
||||||
|
$(MAKE) -C examples/socket_fuzzing install
|
||||||
|
$(MAKE) -C examples/argv_fuzzing install
|
||||||
|
|
||||||
|
set -e; ln -sf afl-gcc $${DESTDIR}$(BIN_PATH)/afl-g++
|
||||||
|
set -e; if [ -f afl-clang-fast ] ; then ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang ; ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang++ ; else ln -sf afl-gcc $${DESTDIR}$(BIN_PATH)/afl-clang ; ln -sf afl-gcc $${DESTDIR}$(BIN_PATH)/afl-clang++; fi
|
||||||
|
|
||||||
|
mkdir -m 0755 -p ${DESTDIR}$(MAN_PATH)
|
||||||
|
install -m0644 *.8 ${DESTDIR}$(MAN_PATH)
|
||||||
|
|
||||||
|
install -m 755 afl-as $${DESTDIR}$(HELPER_PATH)
|
||||||
|
ln -sf afl-as $${DESTDIR}$(HELPER_PATH)/as
|
||||||
|
install -m 644 docs/*.md $${DESTDIR}$(DOC_PATH)
|
||||||
|
cp -r testcases/ $${DESTDIR}$(MISC_PATH)
|
||||||
|
cp -r dictionaries/ $${DESTDIR}$(MISC_PATH)
|
479
Makefile
479
Makefile
@ -1,477 +1,2 @@
|
|||||||
#
|
all:
|
||||||
# american fuzzy lop++ - makefile
|
@echo please use GNU make, thanks!
|
||||||
# -----------------------------
|
|
||||||
#
|
|
||||||
# Originally written by Michal Zalewski
|
|
||||||
#
|
|
||||||
# Copyright 2013, 2014, 2015, 2016, 2017 Google Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at:
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
# For Heiko:
|
|
||||||
#TEST_MMAP=1
|
|
||||||
# the hash character is treated differently in different make versions
|
|
||||||
# so use a variable for '#'
|
|
||||||
HASH=\#
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
BIN_PATH = $(PREFIX)/bin
|
|
||||||
HELPER_PATH = $(PREFIX)/lib/afl
|
|
||||||
DOC_PATH = $(PREFIX)/share/doc/afl
|
|
||||||
MISC_PATH = $(PREFIX)/share/afl
|
|
||||||
MAN_PATH = $(PREFIX)/man/man8
|
|
||||||
|
|
||||||
PROGNAME = afl
|
|
||||||
VERSION = $(shell grep '^$(HASH)define VERSION ' ../config.h | cut -d '"' -f2)
|
|
||||||
|
|
||||||
# PROGS intentionally omit afl-as, which gets installed elsewhere.
|
|
||||||
|
|
||||||
PROGS = afl-gcc afl-fuzz afl-showmap afl-tmin afl-gotcpu afl-analyze
|
|
||||||
SH_PROGS = afl-plot afl-cmin afl-cmin.bash afl-whatsup afl-system-config
|
|
||||||
MANPAGES=$(foreach p, $(PROGS) $(SH_PROGS), $(p).8) afl-as.8
|
|
||||||
ASAN_OPTIONS=detect_leaks=0
|
|
||||||
|
|
||||||
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -x c - -flto=full -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
|
||||||
CFLAGS_FLTO ?= -flto=full
|
|
||||||
else
|
|
||||||
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -x c - -flto=thin -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
|
||||||
CFLAGS_FLTO ?= -flto=thin
|
|
||||||
else
|
|
||||||
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -x c - -flto -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
|
||||||
CFLAGS_FLTO ?= -flto
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(shell uname)" "Darwin"
|
|
||||||
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -x c - -march=native -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
|
||||||
CFLAGS_OPT = -march=native
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(shell uname -m)" "x86_64"
|
|
||||||
ifneq "$(shell uname -m)" "i386"
|
|
||||||
ifneq "$(shell uname -m)" "amd64"
|
|
||||||
ifneq "$(shell uname -m)" "i86pc"
|
|
||||||
AFL_NO_X86=1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS ?= -O3 -funroll-loops $(CFLAGS_OPT) -D_FORTIFY_SOURCE=2
|
|
||||||
override CFLAGS += -Wall -g -Wno-pointer-sign \
|
|
||||||
-I include/ -Werror -DAFL_PATH=\"$(HELPER_PATH)\" \
|
|
||||||
-DBIN_PATH=\"$(BIN_PATH)\" -DDOC_PATH=\"$(DOC_PATH)\"
|
|
||||||
|
|
||||||
AFL_FUZZ_FILES = $(wildcard src/afl-fuzz*.c)
|
|
||||||
|
|
||||||
ifneq "$(shell type python3m 2>/dev/null)" ""
|
|
||||||
ifneq "$(shell type python3m-config 2>/dev/null)" ""
|
|
||||||
PYTHON_INCLUDE ?= $(shell python3m-config --includes)
|
|
||||||
PYTHON_VERSION ?= $(strip $(shell python3m --version 2>&1))
|
|
||||||
# Starting with python3.8, we need to pass the `embed` flag. Earier versions didn't know this flag.
|
|
||||||
ifeq "$(shell python3m-config --embed --libs 2>/dev/null | grep -q lpython && echo 1 )" "1"
|
|
||||||
PYTHON_LIB ?= $(shell python3m-config --libs --embed)
|
|
||||||
else
|
|
||||||
PYTHON_LIB ?= $(shell python3m-config --ldflags)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(shell type python3 2>/dev/null)" ""
|
|
||||||
ifneq "$(shell type python3-config 2>/dev/null)" ""
|
|
||||||
PYTHON_INCLUDE ?= $(shell python3-config --includes)
|
|
||||||
PYTHON_VERSION ?= $(strip $(shell python3 --version 2>&1))
|
|
||||||
# Starting with python3.8, we need to pass the `embed` flag. Earier versions didn't know this flag.
|
|
||||||
ifeq "$(shell python3-config --embed --libs 2>/dev/null | grep -q lpython && echo 1 )" "1"
|
|
||||||
PYTHON_LIB ?= $(shell python3-config --libs --embed)
|
|
||||||
else
|
|
||||||
PYTHON_LIB ?= $(shell python3-config --ldflags)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(shell type python 2>/dev/null)" ""
|
|
||||||
ifneq "$(shell type python-config 2>/dev/null)" ""
|
|
||||||
PYTHON_INCLUDE ?= $(shell python-config --includes)
|
|
||||||
PYTHON_LIB ?= $(shell python-config --ldflags)
|
|
||||||
PYTHON_VERSION ?= $(strip $(shell python --version 2>&1))
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef SOURCE_DATE_EPOCH
|
|
||||||
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+%Y-%m-%d" 2>/dev/null || date -u "+%Y-%m-%d")
|
|
||||||
else
|
|
||||||
BUILD_DATE ?= $(shell date "+%Y-%m-%d")
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(filter Linux GNU%,$(shell uname))" ""
|
|
||||||
LDFLAGS += -ldl
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(findstring FreeBSD, $(shell uname))" ""
|
|
||||||
CFLAGS += -pthread
|
|
||||||
LDFLAGS += -lpthread
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(findstring NetBSD, $(shell uname))" ""
|
|
||||||
CFLAGS += -pthread
|
|
||||||
LDFLAGS += -lpthread
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(findstring clang, $(shell $(CC) --version 2>/dev/null))" ""
|
|
||||||
TEST_CC = afl-gcc
|
|
||||||
else
|
|
||||||
TEST_CC = afl-clang
|
|
||||||
endif
|
|
||||||
|
|
||||||
COMM_HDR = include/alloc-inl.h include/config.h include/debug.h include/types.h
|
|
||||||
|
|
||||||
ifeq "$(shell echo '$(HASH)include <Python.h>@int main() {return 0; }' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test $(PYTHON_INCLUDE) $(LDFLAGS) $(PYTHON_LIB) 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
|
||||||
PYTHON_OK=1
|
|
||||||
PYFLAGS=-DUSE_PYTHON $(PYTHON_INCLUDE) $(LDFLAGS) $(PYTHON_LIB) -DPYTHON_VERSION="\"$(PYTHON_VERSION)\""
|
|
||||||
else
|
|
||||||
PYTHON_OK=0
|
|
||||||
PYFLAGS=
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef STATIC
|
|
||||||
$(info Compiling static version of binaries)
|
|
||||||
# Disable python for static compilation to simplify things
|
|
||||||
PYTHON_OK=0
|
|
||||||
PYFLAGS=
|
|
||||||
|
|
||||||
CFLAGS += -static
|
|
||||||
LDFLAGS += -lm -lpthread -lz -lutil
|
|
||||||
endif
|
|
||||||
|
|
||||||
ASAN_CFLAGS=-fsanitize=address -fstack-protector-all -fno-omit-frame-pointer
|
|
||||||
ASAN_LDFLAGS+=-fsanitize=address -fstack-protector-all -fno-omit-frame-pointer
|
|
||||||
|
|
||||||
ifdef ASAN_BUILD
|
|
||||||
$(info Compiling ASAN version of binaries)
|
|
||||||
CFLAGS+=$(ASAN_CFLAGS)
|
|
||||||
LDFLAGS+=$(ASAN_LDFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef PROFILING
|
|
||||||
$(info Compiling profiling version of binaries)
|
|
||||||
CFLAGS+=-pg
|
|
||||||
LDFLAGS+=-pg
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(shell echo '$(HASH)include <sys/ipc.h>@$(HASH)include <sys/shm.h>@int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1"
|
|
||||||
SHMAT_OK=1
|
|
||||||
else
|
|
||||||
SHMAT_OK=0
|
|
||||||
CFLAGS+=-DUSEMMAP=1
|
|
||||||
LDFLAGS+=-Wno-deprecated-declarations
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(TEST_MMAP)" "1"
|
|
||||||
SHMAT_OK=0
|
|
||||||
CFLAGS+=-DUSEMMAP=1
|
|
||||||
LDFLAGS+=-Wno-deprecated-declarations
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: test_x86 test_shm test_python ready $(PROGS) afl-as test_build all_done
|
|
||||||
|
|
||||||
man: $(MANPAGES)
|
|
||||||
-$(MAKE) -C llvm_mode
|
|
||||||
-$(MAKE) -C gcc_plugin
|
|
||||||
|
|
||||||
tests: source-only
|
|
||||||
@cd test ; ./test.sh
|
|
||||||
@rm -f test/errors
|
|
||||||
|
|
||||||
performance-tests: performance-test
|
|
||||||
test-performance: performance-test
|
|
||||||
|
|
||||||
performance-test: source-only
|
|
||||||
@cd test ; ./test-performance.sh
|
|
||||||
|
|
||||||
|
|
||||||
help:
|
|
||||||
@echo "HELP --- the following make targets exist:"
|
|
||||||
@echo "=========================================="
|
|
||||||
@echo "all: just the main afl++ binaries"
|
|
||||||
@echo "binary-only: everything for binary-only fuzzing: qemu_mode, unicorn_mode, libdislocator, libtokencap, radamsa"
|
|
||||||
@echo "source-only: everything for source code fuzzing: llvm_mode, gcc_plugin, libdislocator, libtokencap, radamsa"
|
|
||||||
@echo "distrib: everything (for both binary-only and source code fuzzing)"
|
|
||||||
@echo "man: creates simple man pages from the help option of the programs"
|
|
||||||
@echo "install: installs everything you have compiled with the build option above"
|
|
||||||
@echo "clean: cleans everything. for qemu_mode it means it deletes all downloads as well"
|
|
||||||
@echo "code-format: format the code, do this before you commit and send a PR please!"
|
|
||||||
@echo "tests: this runs the test framework. It is more catered for the developers, but if you run into problems this helps pinpointing the problem"
|
|
||||||
@echo "unit: perform unit tests (based on cmocka)"
|
|
||||||
@echo "document: creates afl-fuzz-document which will only do one run and save all manipulated inputs into out/queue/mutations"
|
|
||||||
@echo "help: shows these build options :-)"
|
|
||||||
@echo "=========================================="
|
|
||||||
@echo "Recommended: \"distrib\" or \"source-only\", then \"install\""
|
|
||||||
@echo
|
|
||||||
@echo Known build environment options:
|
|
||||||
@echo "=========================================="
|
|
||||||
@echo STATIC - compile AFL++ static
|
|
||||||
@echo ASAN_BUILD - compiles with memory sanitizer for debug purposes
|
|
||||||
@echo PROFILING - compile afl-fuzz with profiling information
|
|
||||||
@echo AFL_NO_X86 - if compiling on non-intel/amd platforms
|
|
||||||
@echo "=========================================="
|
|
||||||
@echo e.g.: make ASAN_BUILD=1
|
|
||||||
|
|
||||||
ifndef AFL_NO_X86
|
|
||||||
|
|
||||||
test_x86:
|
|
||||||
@echo "[*] Checking for the default compiler cc..."
|
|
||||||
@type $(CC) >/dev/null || ( echo; echo "Oops, looks like there is no compiler '"$(CC)"' in your path."; echo; echo "Don't panic! You can restart with '"$(_)" CC=<yourCcompiler>'."; echo; exit 1 )
|
|
||||||
@echo "[*] Checking for the ability to compile x86 code..."
|
|
||||||
@echo 'main() { __asm__("xorb %al, %al"); }' | $(CC) $(CFLAGS) -w -x c - -o .test1 || ( echo; echo "Oops, looks like your compiler can't generate x86 code."; echo; echo "Don't panic! You can use the LLVM or QEMU mode, but see docs/INSTALL first."; echo "(To ignore this error, set AFL_NO_X86=1 and try again.)"; echo; exit 1 )
|
|
||||||
@rm -f .test1
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
test_x86:
|
|
||||||
@echo "[!] Note: skipping x86 compilation checks (AFL_NO_X86 set)."
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
ifeq "$(SHMAT_OK)" "1"
|
|
||||||
|
|
||||||
test_shm:
|
|
||||||
@echo "[+] shmat seems to be working."
|
|
||||||
@rm -f .test2
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
test_shm:
|
|
||||||
@echo "[-] shmat seems not to be working, switching to mmap implementation"
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
ifeq "$(PYTHON_OK)" "1"
|
|
||||||
|
|
||||||
test_python:
|
|
||||||
@rm -f .test 2> /dev/null
|
|
||||||
@echo "[+] $(PYTHON_VERSION) support seems to be working."
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
test_python:
|
|
||||||
@echo "[-] You seem to need to install the package python3-dev or python2-dev (and perhaps python[23]-apt), but it is optional so we continue"
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
ready:
|
|
||||||
@echo "[+] Everything seems to be working, ready to compile."
|
|
||||||
|
|
||||||
afl-gcc: src/afl-gcc.c $(COMM_HDR) | test_x86
|
|
||||||
$(CC) $(CFLAGS) src/$@.c -o $@ $(LDFLAGS)
|
|
||||||
set -e; for i in afl-g++ afl-clang afl-clang++; do ln -sf afl-gcc $$i; done
|
|
||||||
|
|
||||||
afl-as: src/afl-as.c include/afl-as.h $(COMM_HDR) | test_x86
|
|
||||||
$(CC) $(CFLAGS) src/$@.c -o $@ $(LDFLAGS)
|
|
||||||
ln -sf afl-as as
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
src/afl-forkserver.o : $(COMM_HDR) src/afl-forkserver.c include/forkserver.h
|
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_FLTO) -c src/afl-forkserver.c -o src/afl-forkserver.o
|
|
||||||
|
|
||||||
src/afl-sharedmem.o : $(COMM_HDR) src/afl-sharedmem.c include/sharedmem.h
|
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_FLTO) -c src/afl-sharedmem.c -o src/afl-sharedmem.o
|
|
||||||
|
|
||||||
radamsa: src/third_party/libradamsa/libradamsa.so
|
|
||||||
cp src/third_party/libradamsa/libradamsa.so .
|
|
||||||
|
|
||||||
src/third_party/libradamsa/libradamsa.so: src/third_party/libradamsa/libradamsa.c src/third_party/libradamsa/radamsa.h
|
|
||||||
$(MAKE) -C src/third_party/libradamsa/ CFLAGS="$(CFLAGS)"
|
|
||||||
|
|
||||||
afl-fuzz: $(COMM_HDR) include/afl-fuzz.h $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o | test_x86
|
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(PYFLAGS) $(LDFLAGS)
|
|
||||||
|
|
||||||
afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o $(COMM_HDR) | test_x86
|
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(LDFLAGS)
|
|
||||||
|
|
||||||
afl-tmin: src/afl-tmin.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o $(COMM_HDR) | test_x86
|
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(LDFLAGS)
|
|
||||||
|
|
||||||
afl-analyze: src/afl-analyze.c src/afl-common.o src/afl-sharedmem.o $(COMM_HDR) | test_x86
|
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o -o $@ $(LDFLAGS)
|
|
||||||
|
|
||||||
afl-gotcpu: src/afl-gotcpu.c src/afl-common.o $(COMM_HDR) | test_x86
|
|
||||||
$(CC) $(CFLAGS) src/$@.c src/afl-common.o -o $@ $(LDFLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
# document all mutations and only do one run (use with only one input file!)
|
|
||||||
document: $(COMM_HDR) include/afl-fuzz.h $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o | test_x86
|
|
||||||
$(CC) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o afl-fuzz-document $(PYFLAGS) $(LDFLAGS)
|
|
||||||
|
|
||||||
test/unittests/unit_maybe_alloc.o : $(COMM_HDR) include/alloc-inl.h test/unittests/unit_maybe_alloc.c $(AFL_FUZZ_FILES)
|
|
||||||
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -c test/unittests/unit_maybe_alloc.c -o test/unittests/unit_maybe_alloc.o
|
|
||||||
|
|
||||||
test/unittests/unit_preallocable.o : $(COMM_HDR) include/alloc-inl.h test/unittests/unit_preallocable.c $(AFL_FUZZ_FILES)
|
|
||||||
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -c test/unittests/unit_preallocable.c -o test/unittests/unit_preallocable.o
|
|
||||||
|
|
||||||
unit_maybe_alloc: test/unittests/unit_maybe_alloc.o
|
|
||||||
$(CC) $(CFLAGS) -Wl,--wrap=exit -Wl,--wrap=printf test/unittests/unit_maybe_alloc.o -o test/unittests/unit_maybe_alloc $(LDFLAGS) $(ASAN_LDFLAGS) -lcmocka
|
|
||||||
./test/unittests/unit_maybe_alloc
|
|
||||||
|
|
||||||
test/unittests/unit_list.o : $(COMM_HDR) include/list.h test/unittests/unit_list.c $(AFL_FUZZ_FILES)
|
|
||||||
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -c test/unittests/unit_list.c -o test/unittests/unit_list.o
|
|
||||||
|
|
||||||
unit_list: test/unittests/unit_list.o
|
|
||||||
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -Wl,--wrap=exit -Wl,--wrap=printf test/unittests/unit_list.o -o test/unittests/unit_list $(LDFLAGS) $(ASAN_LDFLAGS) -lcmocka
|
|
||||||
./test/unittests/unit_list
|
|
||||||
|
|
||||||
test/unittests/preallocable.o : $(COMM_HDR) include/afl-prealloc.h test/unittests/preallocable.c $(AFL_FUZZ_FILES)
|
|
||||||
$(CC) $(CFLAGS) $(ASAN_CFLAGS) $(CFLAGS_FLTO) -c test/unittests/preallocable.c -o test/unittests/preallocable.o
|
|
||||||
|
|
||||||
unit_preallocable: test/unittests/unit_preallocable.o
|
|
||||||
$(CC) $(CFLAGS) $(ASAN_CFLAGS) -Wl,--wrap=exit -Wl,--wrap=printf test/unittests/unit_preallocable.o -o test/unittests/unit_preallocable $(LDFLAGS) $(ASAN_LDFLAGS) -lcmocka
|
|
||||||
./test/unittests/unit_preallocable
|
|
||||||
|
|
||||||
unit: unit_maybe_alloc unit_preallocable unit_list
|
|
||||||
|
|
||||||
code-format:
|
|
||||||
./.custom-format.py -i src/*.c
|
|
||||||
./.custom-format.py -i include/*.h
|
|
||||||
./.custom-format.py -i libdislocator/*.c
|
|
||||||
./.custom-format.py -i libtokencap/*.c
|
|
||||||
./.custom-format.py -i llvm_mode/*.c
|
|
||||||
./.custom-format.py -i llvm_mode/*.h
|
|
||||||
./.custom-format.py -i llvm_mode/*.cc
|
|
||||||
./.custom-format.py -i gcc_plugin/*.c
|
|
||||||
#./.custom-format.py -i gcc_plugin/*.h
|
|
||||||
./.custom-format.py -i gcc_plugin/*.cc
|
|
||||||
./.custom-format.py -i examples/*/*.c
|
|
||||||
./.custom-format.py -i examples/*/*.h
|
|
||||||
./.custom-format.py -i qemu_mode/patches/*.h
|
|
||||||
./.custom-format.py -i qemu_mode/libcompcov/*.c
|
|
||||||
./.custom-format.py -i qemu_mode/libcompcov/*.cc
|
|
||||||
./.custom-format.py -i qemu_mode/libcompcov/*.h
|
|
||||||
./.custom-format.py -i qbdi_mode/*.c
|
|
||||||
./.custom-format.py -i qbdi_mode/*.cpp
|
|
||||||
./.custom-format.py -i *.h
|
|
||||||
./.custom-format.py -i *.c
|
|
||||||
|
|
||||||
|
|
||||||
ifndef AFL_NO_X86
|
|
||||||
|
|
||||||
test_build: afl-gcc afl-as afl-showmap
|
|
||||||
@echo "[*] Testing the CC wrapper and instrumentation output..."
|
|
||||||
@unset AFL_USE_ASAN AFL_USE_MSAN AFL_CC; AFL_DEBUG=1 AFL_INST_RATIO=100 AFL_PATH=. ./$(TEST_CC) $(CFLAGS) test-instr.c -o test-instr $(LDFLAGS) 2>&1 | grep 'afl-as' >/dev/null || (echo "Oops, afl-as did not get called from "$(TEST_CC)". This is normally achieved by "$(CC)" honoring the -B option."; 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
|
|
||||||
@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please post to https://github.com/AFLplusplus/AFLplusplus/issues to troubleshoot the issue."; echo; exit 1; fi
|
|
||||||
@echo "[+] All right, the instrumentation seems to be working!"
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
test_build: afl-gcc afl-as afl-showmap
|
|
||||||
@echo "[!] Note: skipping build tests (you may need to use LLVM or QEMU mode)."
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
all_done: test_build
|
|
||||||
@if [ ! "`type clang 2>/dev/null`" = "" ]; then echo "[+] LLVM users: see llvm_mode/README.md for a faster alternative to afl-gcc."; fi
|
|
||||||
@echo "[+] All done! Be sure to review the README.md - it's pretty short and useful."
|
|
||||||
@if [ "`uname`" = "Darwin" ]; then printf "\nWARNING: Fuzzing on MacOS X is slow because of the unusually high overhead of\nfork() on this OS. Consider using Linux or *BSD. You can also use VirtualBox\n(virtualbox.org) to put AFL inside a Linux or *BSD VM.\n\n"; fi
|
|
||||||
@! tty <&1 >/dev/null || printf "\033[0;30mNOTE: If you can read this, your terminal probably uses white background.\nThis will make the UI hard to read. See docs/status_screen.md for advice.\033[0m\n" 2>/dev/null
|
|
||||||
|
|
||||||
.NOTPARALLEL: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(PROGS) libradamsa.so afl-fuzz-document afl-as as afl-g++ afl-clang afl-clang++ *.o src/*.o *~ a.out core core.[1-9][0-9]* *.stackdump .test .test1 .test2 test-instr .test-instr0 .test-instr1 qemu_mode/qemu-3.1.1.tar.xz afl-qemu-trace afl-gcc-fast afl-gcc-pass.so afl-gcc-rt.o afl-g++-fast ld *.so *.8 test/unittests/*.o test/unittests/unit_maybe_alloc test/unittests/preallocable
|
|
||||||
rm -rf out_dir qemu_mode/qemu-3.1.1 *.dSYM */*.dSYM
|
|
||||||
-$(MAKE) -C llvm_mode clean
|
|
||||||
-$(MAKE) -C gcc_plugin clean
|
|
||||||
$(MAKE) -C libdislocator clean
|
|
||||||
$(MAKE) -C libtokencap clean
|
|
||||||
$(MAKE) -C examples/socket_fuzzing clean
|
|
||||||
$(MAKE) -C examples/argv_fuzzing clean
|
|
||||||
$(MAKE) -C qemu_mode/unsigaction clean
|
|
||||||
$(MAKE) -C qemu_mode/libcompcov clean
|
|
||||||
$(MAKE) -C src/third_party/libradamsa/ clean
|
|
||||||
-rm -rf unicorn_mode/unicornafl
|
|
||||||
|
|
||||||
distrib: all radamsa
|
|
||||||
-$(MAKE) -C llvm_mode
|
|
||||||
-$(MAKE) -C gcc_plugin
|
|
||||||
$(MAKE) -C libdislocator
|
|
||||||
$(MAKE) -C libtokencap
|
|
||||||
$(MAKE) -C examples/socket_fuzzing
|
|
||||||
$(MAKE) -C examples/argv_fuzzing
|
|
||||||
cd qemu_mode && sh ./build_qemu_support.sh
|
|
||||||
cd unicorn_mode && sh ./build_unicorn_support.sh
|
|
||||||
|
|
||||||
binary-only: all radamsa
|
|
||||||
$(MAKE) -C libdislocator
|
|
||||||
$(MAKE) -C libtokencap
|
|
||||||
$(MAKE) -C examples/socket_fuzzing
|
|
||||||
$(MAKE) -C examples/argv_fuzzing
|
|
||||||
cd qemu_mode && sh ./build_qemu_support.sh
|
|
||||||
cd unicorn_mode && sh ./build_unicorn_support.sh
|
|
||||||
|
|
||||||
source-only: all radamsa
|
|
||||||
-$(MAKE) -C llvm_mode
|
|
||||||
-$(MAKE) -C gcc_plugin
|
|
||||||
$(MAKE) -C libdislocator
|
|
||||||
$(MAKE) -C libtokencap
|
|
||||||
|
|
||||||
%.8: %
|
|
||||||
@echo .TH $* 8 $(BUILD_DATE) "afl++" > $@
|
|
||||||
@echo .SH NAME >> $@
|
|
||||||
@echo .B $* >> $@
|
|
||||||
@echo >> $@
|
|
||||||
@echo .SH SYNOPSIS >> $@
|
|
||||||
@./$* -h 2>&1 | head -n 3 | tail -n 1 | sed 's/^\.\///' >> $@
|
|
||||||
@echo >> $@
|
|
||||||
@echo .SH OPTIONS >> $@
|
|
||||||
@echo .nf >> $@
|
|
||||||
@./$* -hh 2>&1 | tail -n +4 >> $@
|
|
||||||
@echo >> $@
|
|
||||||
@echo .SH AUTHOR >> $@
|
|
||||||
@echo "afl++ was written by Michal \"lcamtuf\" Zalewski and is maintained by Marc \"van Hauser\" Heuse <mh@mh-sec.de>, Heiko \"hexcoder-\" Eissfeldt <heiko.eissfeldt@hexco.de>, Andrea Fioraldi <andreafioraldi@gmail.com> and Dominik Maier <domenukk@gmail.com>" >> $@
|
|
||||||
@echo The homepage of afl++ is: https://github.com/AFLplusplus/AFLplusplus >> $@
|
|
||||||
@echo >> $@
|
|
||||||
@echo .SH LICENSE >> $@
|
|
||||||
@echo Apache License Version 2.0, January 2004 >> $@
|
|
||||||
|
|
||||||
install: all $(MANPAGES)
|
|
||||||
install -d -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(HELPER_PATH) $${DESTDIR}$(DOC_PATH) $${DESTDIR}$(MISC_PATH)
|
|
||||||
rm -f $${DESTDIR}$(BIN_PATH)/afl-plot.sh
|
|
||||||
install -m 755 $(PROGS) $(SH_PROGS) $${DESTDIR}$(BIN_PATH)
|
|
||||||
rm -f $${DESTDIR}$(BIN_PATH)/afl-as
|
|
||||||
if [ -f afl-qemu-trace ]; then install -m 755 afl-qemu-trace $${DESTDIR}$(BIN_PATH); fi
|
|
||||||
if [ -f afl-gcc-fast ]; then set e; install -m 755 afl-gcc-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-gcc-fast $${DESTDIR}$(BIN_PATH)/afl-g++-fast; install -m 755 afl-gcc-pass.so afl-gcc-rt.o $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
$(MAKE) -C llvm_mode install
|
|
||||||
if [ -f libdislocator.so ]; then set -e; install -m 755 libdislocator.so $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f libtokencap.so ]; then set -e; install -m 755 libtokencap.so $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f libcompcov.so ]; then set -e; install -m 755 libcompcov.so $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f libradamsa.so ]; then set -e; install -m 755 libradamsa.so $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f afl-fuzz-document ]; then set -e; install -m 755 afl-fuzz-document $${DESTDIR}$(BIN_PATH); fi
|
|
||||||
$(MAKE) -C examples/socket_fuzzing install
|
|
||||||
$(MAKE) -C examples/argv_fuzzing install
|
|
||||||
|
|
||||||
set -e; ln -sf afl-gcc $${DESTDIR}$(BIN_PATH)/afl-g++
|
|
||||||
set -e; if [ -f afl-clang-fast ] ; then ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang ; ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang++ ; else ln -sf afl-gcc $${DESTDIR}$(BIN_PATH)/afl-clang ; ln -sf afl-gcc $${DESTDIR}$(BIN_PATH)/afl-clang++; fi
|
|
||||||
|
|
||||||
mkdir -m 0755 -p ${DESTDIR}$(MAN_PATH)
|
|
||||||
install -m0644 *.8 ${DESTDIR}$(MAN_PATH)
|
|
||||||
|
|
||||||
install -m 755 afl-as $${DESTDIR}$(HELPER_PATH)
|
|
||||||
ln -sf afl-as $${DESTDIR}$(HELPER_PATH)/as
|
|
||||||
install -m 644 docs/*.md $${DESTDIR}$(DOC_PATH)
|
|
||||||
cp -r testcases/ $${DESTDIR}$(MISC_PATH)
|
|
||||||
cp -r dictionaries/ $${DESTDIR}$(MISC_PATH)
|
|
||||||
|
51
examples/argv_fuzzing/GNUmakefile
Normal file
51
examples/argv_fuzzing/GNUmakefile
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#
|
||||||
|
# american fuzzy lop++ - argvfuzz
|
||||||
|
# --------------------------------
|
||||||
|
#
|
||||||
|
# Copyright 2019-2020 Kjell Braden <afflux@pentabarf.de>
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
.PHONY: all install clean
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
BIN_PATH = $(PREFIX)/bin
|
||||||
|
HELPER_PATH = $(PREFIX)/lib/afl
|
||||||
|
|
||||||
|
CFLAGS = -fPIC -Wall -Wextra
|
||||||
|
LDFLAGS = -shared
|
||||||
|
|
||||||
|
ifneq "$(filter Linux GNU%,$(shell uname))" ""
|
||||||
|
LDFLAGS += -ldl
|
||||||
|
endif
|
||||||
|
|
||||||
|
# on gcc for arm there is no -m32, but -mbe32
|
||||||
|
M32FLAG = -m32
|
||||||
|
M64FLAG = -m64
|
||||||
|
ifeq "$(findstring clang, $(shell $(CC) --version 2>/dev/null))" ""
|
||||||
|
ifneq (,$(findstring arm, "$(shell $(CC) -v 2>&1 >/dev/null)"))
|
||||||
|
M32FLAG = -mbe32
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
all: argvfuzz32.so argvfuzz64.so
|
||||||
|
|
||||||
|
argvfuzz32.so: argvfuzz.c
|
||||||
|
-$(CC) $(M32FLAG) $(CFLAGS) $^ $(LDFLAGS) -o $@ || echo "argvfuzz32 build failure (that's fine)"
|
||||||
|
|
||||||
|
argvfuzz64.so: argvfuzz.c
|
||||||
|
-$(CC) $(M64FLAG) $(CFLAGS) $^ $(LDFLAGS) -o $@ || echo "argvfuzz64 build failure (that's fine)"
|
||||||
|
|
||||||
|
install: argvfuzz32.so argvfuzz64.so
|
||||||
|
install -d -m 755 $(DESTDIR)$(HELPER_PATH)/
|
||||||
|
if [ -f argvfuzz32.so ]; then set -e; install -m 755 argvfuzz32.so $(DESTDIR)$(HELPER_PATH)/; fi
|
||||||
|
if [ -f argvfuzz64.so ]; then set -e; install -m 755 argvfuzz64.so $(DESTDIR)$(HELPER_PATH)/; fi
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f argvfuzz32.so argvfuzz64.so
|
@ -1,51 +1,2 @@
|
|||||||
#
|
all:
|
||||||
# american fuzzy lop++ - argvfuzz
|
@echo please use GNU make, thanks!
|
||||||
# --------------------------------
|
|
||||||
#
|
|
||||||
# Copyright 2019-2020 Kjell Braden <afflux@pentabarf.de>
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at:
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
.PHONY: all install clean
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
BIN_PATH = $(PREFIX)/bin
|
|
||||||
HELPER_PATH = $(PREFIX)/lib/afl
|
|
||||||
|
|
||||||
CFLAGS = -fPIC -Wall -Wextra
|
|
||||||
LDFLAGS = -shared
|
|
||||||
|
|
||||||
ifneq "$(filter Linux GNU%,$(shell uname))" ""
|
|
||||||
LDFLAGS += -ldl
|
|
||||||
endif
|
|
||||||
|
|
||||||
# on gcc for arm there is no -m32, but -mbe32
|
|
||||||
M32FLAG = -m32
|
|
||||||
M64FLAG = -m64
|
|
||||||
ifeq "$(findstring clang, $(shell $(CC) --version 2>/dev/null))" ""
|
|
||||||
ifneq (,$(findstring arm, "$(shell $(CC) -v 2>&1 >/dev/null)"))
|
|
||||||
M32FLAG = -mbe32
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
all: argvfuzz32.so argvfuzz64.so
|
|
||||||
|
|
||||||
argvfuzz32.so: argvfuzz.c
|
|
||||||
-$(CC) $(M32FLAG) $(CFLAGS) $^ $(LDFLAGS) -o $@ || echo "argvfuzz32 build failure (that's fine)"
|
|
||||||
|
|
||||||
argvfuzz64.so: argvfuzz.c
|
|
||||||
-$(CC) $(M64FLAG) $(CFLAGS) $^ $(LDFLAGS) -o $@ || echo "argvfuzz64 build failure (that's fine)"
|
|
||||||
|
|
||||||
install: argvfuzz32.so argvfuzz64.so
|
|
||||||
install -d -m 755 $(DESTDIR)$(HELPER_PATH)/
|
|
||||||
if [ -f argvfuzz32.so ]; then set -e; install -m 755 argvfuzz32.so $(DESTDIR)$(HELPER_PATH)/; fi
|
|
||||||
if [ -f argvfuzz64.so ]; then set -e; install -m 755 argvfuzz64.so $(DESTDIR)$(HELPER_PATH)/; fi
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f argvfuzz32.so argvfuzz64.so
|
|
||||||
|
7
examples/custom_mutators/GNUmakefile
Normal file
7
examples/custom_mutators/GNUmakefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
all: libexamplemutator.so
|
||||||
|
|
||||||
|
libexamplemutator.so:
|
||||||
|
$(CC) $(CFLAGS) -D_FORTIFY_SOURCE=2 -O3 -fPIC -shared -g -I ../../include example.c -o libexamplemutator.so
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf libexamplemutator.so
|
@ -1,7 +1,2 @@
|
|||||||
all: libexamplemutator.so
|
all:
|
||||||
|
@echo please use GNU make, thanks!
|
||||||
libexamplemutator.so:
|
|
||||||
$(CC) $(CFLAGS) -D_FORTIFY_SOURCE=2 -O3 -fPIC -shared -g -I ../../include example.c -o libexamplemutator.so
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf libexamplemutator.so
|
|
||||||
|
48
examples/socket_fuzzing/GNUmakefile
Normal file
48
examples/socket_fuzzing/GNUmakefile
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#
|
||||||
|
# american fuzzy lop++ - socket_fuzz
|
||||||
|
# ----------------------------------
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
.PHONY: all install clean
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
BIN_PATH = $(PREFIX)/bin
|
||||||
|
HELPER_PATH = $(PREFIX)/lib/afl
|
||||||
|
|
||||||
|
CFLAGS = -fPIC -Wall -Wextra
|
||||||
|
LDFLAGS = -shared
|
||||||
|
|
||||||
|
ifneq "$(filter Linux GNU%,$(shell uname))" ""
|
||||||
|
LDFLAGS += -ldl
|
||||||
|
endif
|
||||||
|
|
||||||
|
# on gcc for arm there is no -m32, but -mbe32
|
||||||
|
M32FLAG = -m32
|
||||||
|
M64FLAG = -m64
|
||||||
|
ifeq "$(findstring clang, $(shell $(CC) --version 2>/dev/null))" ""
|
||||||
|
ifneq (,$(findstring arm, "$(shell $(CC) -v 2>&1 >/dev/null)"))
|
||||||
|
M32FLAG = -mbe32
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: socketfuzz32.so socketfuzz64.so
|
||||||
|
|
||||||
|
socketfuzz32.so: socketfuzz.c
|
||||||
|
-$(CC) $(M32FLAG) $(CFLAGS) $^ $(LDFLAGS) -o $@ || echo "socketfuzz32 build failure (that's fine)"
|
||||||
|
|
||||||
|
socketfuzz64.so: socketfuzz.c
|
||||||
|
-$(CC) $(M64FLAG) $(CFLAGS) $^ $(LDFLAGS) -o $@ || echo "socketfuzz64 build failure (that's fine)"
|
||||||
|
|
||||||
|
install: socketfuzz32.so socketfuzz64.so
|
||||||
|
install -d -m 755 $(DESTDIR)$(HELPER_PATH)/
|
||||||
|
if [ -f socketfuzz32.so ]; then set -e; install -m 755 socketfuzz32.so $(DESTDIR)$(HELPER_PATH)/; fi
|
||||||
|
if [ -f socketfuzz64.so ]; then set -e; install -m 755 socketfuzz64.so $(DESTDIR)$(HELPER_PATH)/; fi
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f socketfuzz32.so socketfuzz64.so
|
@ -1,48 +1,2 @@
|
|||||||
#
|
all:
|
||||||
# american fuzzy lop++ - socket_fuzz
|
@echo please use GNU make, thanks!
|
||||||
# ----------------------------------
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at:
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
.PHONY: all install clean
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
BIN_PATH = $(PREFIX)/bin
|
|
||||||
HELPER_PATH = $(PREFIX)/lib/afl
|
|
||||||
|
|
||||||
CFLAGS = -fPIC -Wall -Wextra
|
|
||||||
LDFLAGS = -shared
|
|
||||||
|
|
||||||
ifneq "$(filter Linux GNU%,$(shell uname))" ""
|
|
||||||
LDFLAGS += -ldl
|
|
||||||
endif
|
|
||||||
|
|
||||||
# on gcc for arm there is no -m32, but -mbe32
|
|
||||||
M32FLAG = -m32
|
|
||||||
M64FLAG = -m64
|
|
||||||
ifeq "$(findstring clang, $(shell $(CC) --version 2>/dev/null))" ""
|
|
||||||
ifneq (,$(findstring arm, "$(shell $(CC) -v 2>&1 >/dev/null)"))
|
|
||||||
M32FLAG = -mbe32
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: socketfuzz32.so socketfuzz64.so
|
|
||||||
|
|
||||||
socketfuzz32.so: socketfuzz.c
|
|
||||||
-$(CC) $(M32FLAG) $(CFLAGS) $^ $(LDFLAGS) -o $@ || echo "socketfuzz32 build failure (that's fine)"
|
|
||||||
|
|
||||||
socketfuzz64.so: socketfuzz.c
|
|
||||||
-$(CC) $(M64FLAG) $(CFLAGS) $^ $(LDFLAGS) -o $@ || echo "socketfuzz64 build failure (that's fine)"
|
|
||||||
|
|
||||||
install: socketfuzz32.so socketfuzz64.so
|
|
||||||
install -d -m 755 $(DESTDIR)$(HELPER_PATH)/
|
|
||||||
if [ -f socketfuzz32.so ]; then set -e; install -m 755 socketfuzz32.so $(DESTDIR)$(HELPER_PATH)/; fi
|
|
||||||
if [ -f socketfuzz64.so ]; then set -e; install -m 755 socketfuzz64.so $(DESTDIR)$(HELPER_PATH)/; fi
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f socketfuzz32.so socketfuzz64.so
|
|
||||||
|
160
gcc_plugin/GNUmakefile
Normal file
160
gcc_plugin/GNUmakefile
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
#
|
||||||
|
# american fuzzy lop++ - GCC plugin instrumentation
|
||||||
|
# -----------------------------------------------
|
||||||
|
#
|
||||||
|
# Written by Austin Seipp <aseipp@pobox.com> and
|
||||||
|
# Laszlo Szekeres <lszekeres@google.com> and
|
||||||
|
# Michal Zalewski and
|
||||||
|
# Heiko Eißfeldt <heiko@hexco.de>
|
||||||
|
#
|
||||||
|
# GCC integration design is based on the LLVM design, which comes
|
||||||
|
# from Laszlo Szekeres.
|
||||||
|
#
|
||||||
|
# Copyright 2015 Google Inc. All rights reserved.
|
||||||
|
# Copyright 2019-2020 AFLplusplus Project. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
HELPER_PATH ?= $(PREFIX)/lib/afl
|
||||||
|
BIN_PATH ?= $(PREFIX)/bin
|
||||||
|
DOC_PATH ?= $(PREFIX)/share/doc/afl
|
||||||
|
MAN_PATH ?= $(PREFIX)/man/man8
|
||||||
|
|
||||||
|
VERSION = $(shell grep '^$(HASH)define VERSION ' ../config.h | cut -d '"' -f2)
|
||||||
|
|
||||||
|
CFLAGS ?= -O3 -g -funroll-loops -D_FORTIFY_SOURCE=2
|
||||||
|
override CFLAGS = -Wall -I../include -Wno-pointer-sign \
|
||||||
|
-DAFL_PATH=\"$(HELPER_PATH)\" -DBIN_PATH=\"$(BIN_PATH)\" \
|
||||||
|
-DGCC_VERSION=\"$(GCCVER)\" -DGCC_BINDIR=\"$(GCCBINDIR)\" \
|
||||||
|
-Wno-unused-function
|
||||||
|
|
||||||
|
CXXFLAGS ?= -O3 -g -funroll-loops -D_FORTIFY_SOURCE=2
|
||||||
|
CXXEFLAGS := $(CXXFLAGS) -Wall
|
||||||
|
|
||||||
|
CC ?= gcc
|
||||||
|
CXX ?= g++
|
||||||
|
|
||||||
|
ifeq "clang" "$(CC)"
|
||||||
|
CC = gcc
|
||||||
|
CXX = g++
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "clang++" "$(CXX)"
|
||||||
|
CC = gcc
|
||||||
|
CXX = g++
|
||||||
|
endif
|
||||||
|
|
||||||
|
PLUGIN_FLAGS = -fPIC -fno-rtti -I"$(shell $(CC) -print-file-name=plugin)/include"
|
||||||
|
HASH=\#
|
||||||
|
|
||||||
|
GCCVER = $(shell $(CC) --version 2>/dev/null | awk 'NR == 1 {print $$NF}')
|
||||||
|
GCCBINDIR = $(shell dirname `command -v $(CC)` 2>/dev/null )
|
||||||
|
|
||||||
|
ifeq "$(shell echo '$(HASH)include <sys/ipc.h>@$(HASH)include <sys/shm.h>@int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1"
|
||||||
|
SHMAT_OK=1
|
||||||
|
else
|
||||||
|
SHMAT_OK=0
|
||||||
|
CFLAGS+=-DUSEMMAP=1
|
||||||
|
LDFLAGS += -lrt
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(TEST_MMAP)" "1"
|
||||||
|
SHMAT_OK=0
|
||||||
|
CFLAGS+=-DUSEMMAP=1
|
||||||
|
LDFLAGS += -lrt
|
||||||
|
endif
|
||||||
|
|
||||||
|
PROGS = ../afl-gcc-fast ../afl-gcc-pass.so ../afl-gcc-rt.o
|
||||||
|
|
||||||
|
|
||||||
|
all: test_shm test_deps $(PROGS) afl-gcc-fast.8 test_build all_done
|
||||||
|
|
||||||
|
ifeq "$(SHMAT_OK)" "1"
|
||||||
|
|
||||||
|
test_shm:
|
||||||
|
@echo "[+] shmat seems to be working."
|
||||||
|
@rm -f .test2
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
test_shm:
|
||||||
|
@echo "[-] shmat seems not to be working, switching to mmap implementation"
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
test_deps:
|
||||||
|
@echo "[*] Checking for working '$(CC)'..."
|
||||||
|
@type $(CC) >/dev/null 2>&1 || ( echo "[-] Oops, can't find '$(CC)'. Make sure that it's in your \$$PATH (or set \$$CC and \$$CXX)."; exit 1 )
|
||||||
|
# @echo "[*] Checking for gcc for plugin support..."
|
||||||
|
# @$(CC) -v 2>&1 | grep -q -- --enable-plugin || ( echo "[-] Oops, this gcc has not been configured with plugin support."; exit 1 )
|
||||||
|
@echo "[*] Checking for gcc plugin development header files..."
|
||||||
|
@test -d `$(CC) -print-file-name=plugin`/include || ( echo "[-] Oops, can't find gcc header files. Be sure to install 'gcc-X-plugin-dev'."; exit 1 )
|
||||||
|
@echo "[*] Checking for '../afl-showmap'..."
|
||||||
|
@test -f ../afl-showmap || ( echo "[-] Oops, can't find '../afl-showmap'. Be sure to compile AFL first."; exit 1 )
|
||||||
|
@echo "[+] All set and ready to build."
|
||||||
|
|
||||||
|
afl-common.o: ../src/afl-common.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
../afl-gcc-fast: afl-gcc-fast.c afl-common.o | test_deps
|
||||||
|
$(CC) -DAFL_GCC_CC=\"$(CC)\" -DAFL_GCC_CXX=\"$(CXX)\" $(CFLAGS) $< afl-common.o -o $@ $(LDFLAGS)
|
||||||
|
ln -sf afl-gcc-fast ../afl-g++-fast
|
||||||
|
|
||||||
|
../afl-gcc-pass.so: afl-gcc-pass.so.cc | test_deps
|
||||||
|
$(CXX) $(CXXEFLAGS) $(PLUGIN_FLAGS) -shared $< -o $@
|
||||||
|
|
||||||
|
../afl-gcc-rt.o: afl-gcc-rt.o.c | test_deps
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
||||||
|
|
||||||
|
test_build: $(PROGS)
|
||||||
|
@echo "[*] Testing the CC wrapper and instrumentation output..."
|
||||||
|
unset AFL_USE_ASAN AFL_USE_MSAN; AFL_QUIET=1 AFL_INST_RATIO=100 AFL_PATH=. AFL_CC=$(CC) ../afl-gcc-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
|
||||||
|
# unset AFL_USE_ASAN AFL_USE_MSAN; AFL_INST_RATIO=100 AFL_PATH=. AFL_CC=$(CC) ../afl-gcc-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
|
||||||
|
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
|
||||||
|
@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please post to https://github.com/AFLplusplus/AFLplusplus/issues to troubleshoot the issue."; echo; exit 1; fi
|
||||||
|
@echo "[+] All right, the instrumentation seems to be working!"
|
||||||
|
|
||||||
|
all_done: test_build
|
||||||
|
@echo "[+] All done! You can now use '../afl-gcc-fast' to compile programs."
|
||||||
|
|
||||||
|
.NOTPARALLEL: clean
|
||||||
|
|
||||||
|
vpath % ..
|
||||||
|
%.8: %
|
||||||
|
@echo .TH $* 8 `date "+%Y-%m-%d"` "afl++" > ../$@
|
||||||
|
@echo .SH NAME >> ../$@
|
||||||
|
@echo .B $* >> ../$@
|
||||||
|
@echo >> ../$@
|
||||||
|
@echo .SH SYNOPSIS >> ../$@
|
||||||
|
@../$* -h 2>&1 | head -n 3 | tail -n 1 | sed 's/^\.\///' >> ../$@
|
||||||
|
@echo >> ../$@
|
||||||
|
@echo .SH OPTIONS >> ../$@
|
||||||
|
@echo .nf >> ../$@
|
||||||
|
@../$* -h 2>&1 | tail -n +4 >> ../$@
|
||||||
|
@echo >> ../$@
|
||||||
|
@echo .SH AUTHOR >> ../$@
|
||||||
|
@echo "afl++ was written by Michal \"lcamtuf\" Zalewski and is maintained by Marc \"van Hauser\" Heuse <mh@mh-sec.de>, Heiko \"hexcoder-\" Eissfeldt <heiko.eissfeldt@hexco.de>, Andrea Fioraldi <andreafioraldi@gmail.com> and Dominik Maier <domenukk@gmail.com>" >> ../$@
|
||||||
|
@echo The homepage of afl++ is: https://github.com/AFLplusplus/AFLplusplus >> ../$@
|
||||||
|
@echo >> ../$@
|
||||||
|
@echo .SH LICENSE >> ../$@
|
||||||
|
@echo Apache License Version 2.0, January 2004 >> ../$@
|
||||||
|
ln -sf afl-gcc-fast.8 ../afl-g++-fast.8
|
||||||
|
|
||||||
|
install: all
|
||||||
|
install -m 755 ../afl-gcc-fast $${DESTDIR}$(BIN_PATH)
|
||||||
|
install -m 755 ../afl-gcc-pass.so ../afl-gcc-rt.o $${DESTDIR}$(HELPER_PATH)
|
||||||
|
install -m 644 -T README.md $${DESTDIR}$(DOC_PATH)/README.gcc_plugin.md
|
||||||
|
install -m 644 -T README.whitelist.md $${DESTDIR}$(DOC_PATH)/README.gcc_plugin.whitelist.md
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.so *~ a.out core core.[1-9][0-9]* test-instr .test-instr0 .test-instr1 .test2
|
||||||
|
rm -f $(PROGS) afl-common.o ../afl-g++-fast ../afl-g*-fast.8
|
@ -1,160 +1,2 @@
|
|||||||
#
|
all:
|
||||||
# american fuzzy lop++ - GCC plugin instrumentation
|
@echo please use GNU make, thanks!
|
||||||
# -----------------------------------------------
|
|
||||||
#
|
|
||||||
# Written by Austin Seipp <aseipp@pobox.com> and
|
|
||||||
# Laszlo Szekeres <lszekeres@google.com> and
|
|
||||||
# Michal Zalewski and
|
|
||||||
# Heiko Eißfeldt <heiko@hexco.de>
|
|
||||||
#
|
|
||||||
# GCC integration design is based on the LLVM design, which comes
|
|
||||||
# from Laszlo Szekeres.
|
|
||||||
#
|
|
||||||
# Copyright 2015 Google Inc. All rights reserved.
|
|
||||||
# Copyright 2019-2020 AFLplusplus Project. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at:
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
HELPER_PATH ?= $(PREFIX)/lib/afl
|
|
||||||
BIN_PATH ?= $(PREFIX)/bin
|
|
||||||
DOC_PATH ?= $(PREFIX)/share/doc/afl
|
|
||||||
MAN_PATH ?= $(PREFIX)/man/man8
|
|
||||||
|
|
||||||
VERSION = $(shell grep '^$(HASH)define VERSION ' ../config.h | cut -d '"' -f2)
|
|
||||||
|
|
||||||
CFLAGS ?= -O3 -g -funroll-loops -D_FORTIFY_SOURCE=2
|
|
||||||
override CFLAGS = -Wall -I../include -Wno-pointer-sign \
|
|
||||||
-DAFL_PATH=\"$(HELPER_PATH)\" -DBIN_PATH=\"$(BIN_PATH)\" \
|
|
||||||
-DGCC_VERSION=\"$(GCCVER)\" -DGCC_BINDIR=\"$(GCCBINDIR)\" \
|
|
||||||
-Wno-unused-function
|
|
||||||
|
|
||||||
CXXFLAGS ?= -O3 -g -funroll-loops -D_FORTIFY_SOURCE=2
|
|
||||||
CXXEFLAGS := $(CXXFLAGS) -Wall
|
|
||||||
|
|
||||||
CC ?= gcc
|
|
||||||
CXX ?= g++
|
|
||||||
|
|
||||||
ifeq "clang" "$(CC)"
|
|
||||||
CC = gcc
|
|
||||||
CXX = g++
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "clang++" "$(CXX)"
|
|
||||||
CC = gcc
|
|
||||||
CXX = g++
|
|
||||||
endif
|
|
||||||
|
|
||||||
PLUGIN_FLAGS = -fPIC -fno-rtti -I"$(shell $(CC) -print-file-name=plugin)/include"
|
|
||||||
HASH=\#
|
|
||||||
|
|
||||||
GCCVER = $(shell $(CC) --version 2>/dev/null | awk 'NR == 1 {print $$NF}')
|
|
||||||
GCCBINDIR = $(shell dirname `command -v $(CC)` 2>/dev/null )
|
|
||||||
|
|
||||||
ifeq "$(shell echo '$(HASH)include <sys/ipc.h>@$(HASH)include <sys/shm.h>@int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1"
|
|
||||||
SHMAT_OK=1
|
|
||||||
else
|
|
||||||
SHMAT_OK=0
|
|
||||||
CFLAGS+=-DUSEMMAP=1
|
|
||||||
LDFLAGS += -lrt
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(TEST_MMAP)" "1"
|
|
||||||
SHMAT_OK=0
|
|
||||||
CFLAGS+=-DUSEMMAP=1
|
|
||||||
LDFLAGS += -lrt
|
|
||||||
endif
|
|
||||||
|
|
||||||
PROGS = ../afl-gcc-fast ../afl-gcc-pass.so ../afl-gcc-rt.o
|
|
||||||
|
|
||||||
|
|
||||||
all: test_shm test_deps $(PROGS) afl-gcc-fast.8 test_build all_done
|
|
||||||
|
|
||||||
ifeq "$(SHMAT_OK)" "1"
|
|
||||||
|
|
||||||
test_shm:
|
|
||||||
@echo "[+] shmat seems to be working."
|
|
||||||
@rm -f .test2
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
test_shm:
|
|
||||||
@echo "[-] shmat seems not to be working, switching to mmap implementation"
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
test_deps:
|
|
||||||
@echo "[*] Checking for working '$(CC)'..."
|
|
||||||
@type $(CC) >/dev/null 2>&1 || ( echo "[-] Oops, can't find '$(CC)'. Make sure that it's in your \$$PATH (or set \$$CC and \$$CXX)."; exit 1 )
|
|
||||||
# @echo "[*] Checking for gcc for plugin support..."
|
|
||||||
# @$(CC) -v 2>&1 | grep -q -- --enable-plugin || ( echo "[-] Oops, this gcc has not been configured with plugin support."; exit 1 )
|
|
||||||
@echo "[*] Checking for gcc plugin development header files..."
|
|
||||||
@test -d `$(CC) -print-file-name=plugin`/include || ( echo "[-] Oops, can't find gcc header files. Be sure to install 'gcc-X-plugin-dev'."; exit 1 )
|
|
||||||
@echo "[*] Checking for '../afl-showmap'..."
|
|
||||||
@test -f ../afl-showmap || ( echo "[-] Oops, can't find '../afl-showmap'. Be sure to compile AFL first."; exit 1 )
|
|
||||||
@echo "[+] All set and ready to build."
|
|
||||||
|
|
||||||
afl-common.o: ../src/afl-common.c
|
|
||||||
$(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
|
|
||||||
|
|
||||||
../afl-gcc-fast: afl-gcc-fast.c afl-common.o | test_deps
|
|
||||||
$(CC) -DAFL_GCC_CC=\"$(CC)\" -DAFL_GCC_CXX=\"$(CXX)\" $(CFLAGS) $< afl-common.o -o $@ $(LDFLAGS)
|
|
||||||
ln -sf afl-gcc-fast ../afl-g++-fast
|
|
||||||
|
|
||||||
../afl-gcc-pass.so: afl-gcc-pass.so.cc | test_deps
|
|
||||||
$(CXX) $(CXXEFLAGS) $(PLUGIN_FLAGS) -shared $< -o $@
|
|
||||||
|
|
||||||
../afl-gcc-rt.o: afl-gcc-rt.o.c | test_deps
|
|
||||||
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
|
||||||
|
|
||||||
test_build: $(PROGS)
|
|
||||||
@echo "[*] Testing the CC wrapper and instrumentation output..."
|
|
||||||
unset AFL_USE_ASAN AFL_USE_MSAN; AFL_QUIET=1 AFL_INST_RATIO=100 AFL_PATH=. AFL_CC=$(CC) ../afl-gcc-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
|
|
||||||
# unset AFL_USE_ASAN AFL_USE_MSAN; AFL_INST_RATIO=100 AFL_PATH=. AFL_CC=$(CC) ../afl-gcc-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
|
|
||||||
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
|
|
||||||
@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please post to https://github.com/AFLplusplus/AFLplusplus/issues to troubleshoot the issue."; echo; exit 1; fi
|
|
||||||
@echo "[+] All right, the instrumentation seems to be working!"
|
|
||||||
|
|
||||||
all_done: test_build
|
|
||||||
@echo "[+] All done! You can now use '../afl-gcc-fast' to compile programs."
|
|
||||||
|
|
||||||
.NOTPARALLEL: clean
|
|
||||||
|
|
||||||
vpath % ..
|
|
||||||
%.8: %
|
|
||||||
@echo .TH $* 8 `date "+%Y-%m-%d"` "afl++" > ../$@
|
|
||||||
@echo .SH NAME >> ../$@
|
|
||||||
@echo .B $* >> ../$@
|
|
||||||
@echo >> ../$@
|
|
||||||
@echo .SH SYNOPSIS >> ../$@
|
|
||||||
@../$* -h 2>&1 | head -n 3 | tail -n 1 | sed 's/^\.\///' >> ../$@
|
|
||||||
@echo >> ../$@
|
|
||||||
@echo .SH OPTIONS >> ../$@
|
|
||||||
@echo .nf >> ../$@
|
|
||||||
@../$* -h 2>&1 | tail -n +4 >> ../$@
|
|
||||||
@echo >> ../$@
|
|
||||||
@echo .SH AUTHOR >> ../$@
|
|
||||||
@echo "afl++ was written by Michal \"lcamtuf\" Zalewski and is maintained by Marc \"van Hauser\" Heuse <mh@mh-sec.de>, Heiko \"hexcoder-\" Eissfeldt <heiko.eissfeldt@hexco.de>, Andrea Fioraldi <andreafioraldi@gmail.com> and Dominik Maier <domenukk@gmail.com>" >> ../$@
|
|
||||||
@echo The homepage of afl++ is: https://github.com/AFLplusplus/AFLplusplus >> ../$@
|
|
||||||
@echo >> ../$@
|
|
||||||
@echo .SH LICENSE >> ../$@
|
|
||||||
@echo Apache License Version 2.0, January 2004 >> ../$@
|
|
||||||
ln -sf afl-gcc-fast.8 ../afl-g++-fast.8
|
|
||||||
|
|
||||||
install: all
|
|
||||||
install -m 755 ../afl-gcc-fast $${DESTDIR}$(BIN_PATH)
|
|
||||||
install -m 755 ../afl-gcc-pass.so ../afl-gcc-rt.o $${DESTDIR}$(HELPER_PATH)
|
|
||||||
install -m 644 -T README.md $${DESTDIR}$(DOC_PATH)/README.gcc_plugin.md
|
|
||||||
install -m 644 -T README.whitelist.md $${DESTDIR}$(DOC_PATH)/README.gcc_plugin.whitelist.md
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o *.so *~ a.out core core.[1-9][0-9]* test-instr .test-instr0 .test-instr1 .test2
|
|
||||||
rm -f $(PROGS) afl-common.o ../afl-g++-fast ../afl-g*-fast.8
|
|
||||||
|
44
libdislocator/GNUmakefile
Normal file
44
libdislocator/GNUmakefile
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#
|
||||||
|
# american fuzzy lop++ - libdislocator
|
||||||
|
# ----------------------------------
|
||||||
|
#
|
||||||
|
# Originally written by Michal Zalewski
|
||||||
|
#
|
||||||
|
# Copyright 2016 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
HELPER_PATH = $(PREFIX)/lib/afl
|
||||||
|
|
||||||
|
VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
|
||||||
|
|
||||||
|
CFLAGS ?= -O3 -funroll-loops
|
||||||
|
override CFLAGS += -I ../include/ -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
|
||||||
|
|
||||||
|
ifdef USEHUGEPAGE
|
||||||
|
CFLAGS += -DUSEHUGEPAGE
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: libdislocator.so
|
||||||
|
|
||||||
|
VPATH = ..
|
||||||
|
libdislocator.so: libdislocator.so.c ../config.h
|
||||||
|
$(CC) $(CFLAGS) -shared -fPIC $< -o ../$@ $(LDFLAGS)
|
||||||
|
|
||||||
|
.NOTPARALLEL: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
|
||||||
|
rm -f ../libdislocator.so
|
||||||
|
|
||||||
|
install: all
|
||||||
|
install -m 755 -d $${DESTDIR}$(HELPER_PATH)
|
||||||
|
install -m 755 ../libdislocator.so $${DESTDIR}$(HELPER_PATH)
|
||||||
|
install -m 644 README.dislocator.md $${DESTDIR}$(HELPER_PATH)
|
||||||
|
|
@ -1,44 +1,2 @@
|
|||||||
#
|
all:
|
||||||
# american fuzzy lop++ - libdislocator
|
@echo please use GNU make, thanks!
|
||||||
# ----------------------------------
|
|
||||||
#
|
|
||||||
# Originally written by Michal Zalewski
|
|
||||||
#
|
|
||||||
# Copyright 2016 Google Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at:
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
HELPER_PATH = $(PREFIX)/lib/afl
|
|
||||||
|
|
||||||
VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
|
|
||||||
|
|
||||||
CFLAGS ?= -O3 -funroll-loops
|
|
||||||
override CFLAGS += -I ../include/ -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
|
|
||||||
|
|
||||||
ifdef USEHUGEPAGE
|
|
||||||
CFLAGS += -DUSEHUGEPAGE
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: libdislocator.so
|
|
||||||
|
|
||||||
VPATH = ..
|
|
||||||
libdislocator.so: libdislocator.so.c ../config.h
|
|
||||||
$(CC) $(CFLAGS) -shared -fPIC $< -o ../$@ $(LDFLAGS)
|
|
||||||
|
|
||||||
.NOTPARALLEL: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
|
|
||||||
rm -f ../libdislocator.so
|
|
||||||
|
|
||||||
install: all
|
|
||||||
install -m 755 -d $${DESTDIR}$(HELPER_PATH)
|
|
||||||
install -m 755 ../libdislocator.so $${DESTDIR}$(HELPER_PATH)
|
|
||||||
install -m 644 README.dislocator.md $${DESTDIR}$(HELPER_PATH)
|
|
||||||
|
|
||||||
|
63
libtokencap/GNUmakefile
Normal file
63
libtokencap/GNUmakefile
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#
|
||||||
|
# american fuzzy lop++ - libtokencap
|
||||||
|
# --------------------------------
|
||||||
|
#
|
||||||
|
# Originally written by Michal Zalewski
|
||||||
|
#
|
||||||
|
# Copyright 2016 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
HELPER_PATH = $(PREFIX)/lib/afl
|
||||||
|
DOC_PATH ?= $(PREFIX)/share/doc/afl
|
||||||
|
MAN_PATH ?= $(PREFIX)/man/man8
|
||||||
|
|
||||||
|
VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
|
||||||
|
|
||||||
|
CFLAGS ?= -O3 -funroll-loops
|
||||||
|
override CFLAGS += -I ../include/ -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
|
||||||
|
|
||||||
|
ifeq "$(shell uname)" "Linux"
|
||||||
|
TARGETS = libtokencap.so
|
||||||
|
LDFLAGS += -ldl
|
||||||
|
endif
|
||||||
|
ifeq "$(shell uname)" "Darwin"
|
||||||
|
TARGETS = libtokencap.so
|
||||||
|
LDFLAGS += -ldl
|
||||||
|
endif
|
||||||
|
ifeq "$(shell uname)" "FreeBSD"
|
||||||
|
TARGETS = libtokencap.so
|
||||||
|
endif
|
||||||
|
ifeq "$(shell uname)" "OpenBSD"
|
||||||
|
TARGETS = libtokencap.so
|
||||||
|
endif
|
||||||
|
ifeq "$(shell uname)" "NetBSD"
|
||||||
|
TARGETS = libtokencap.so
|
||||||
|
endif
|
||||||
|
ifeq "$(shell uname)" "DragonFly"
|
||||||
|
TARGETS = libtokencap.so
|
||||||
|
LDFLAGS += -ldl
|
||||||
|
endif
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
VPATH = ..
|
||||||
|
libtokencap.so: libtokencap.so.c ../config.h
|
||||||
|
$(CC) $(CFLAGS) -shared -fPIC $< -o ../$@ $(LDFLAGS)
|
||||||
|
|
||||||
|
.NOTPARALLEL: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
|
||||||
|
rm -f ../libtokencap.so
|
||||||
|
|
||||||
|
install: all
|
||||||
|
install -m 755 -d $${DESTDIR}$(HELPER_PATH)
|
||||||
|
install -m 755 ../libtokencap.so $${DESTDIR}$(HELPER_PATH)
|
||||||
|
install -m 644 -T README.md $${DESTDIR}$(DOC_PATH)/README.tokencap.md
|
||||||
|
|
@ -1,63 +1,2 @@
|
|||||||
#
|
all:
|
||||||
# american fuzzy lop++ - libtokencap
|
@echo please use GNU make, thanks!
|
||||||
# --------------------------------
|
|
||||||
#
|
|
||||||
# Originally written by Michal Zalewski
|
|
||||||
#
|
|
||||||
# Copyright 2016 Google Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at:
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
HELPER_PATH = $(PREFIX)/lib/afl
|
|
||||||
DOC_PATH ?= $(PREFIX)/share/doc/afl
|
|
||||||
MAN_PATH ?= $(PREFIX)/man/man8
|
|
||||||
|
|
||||||
VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
|
|
||||||
|
|
||||||
CFLAGS ?= -O3 -funroll-loops
|
|
||||||
override CFLAGS += -I ../include/ -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
|
|
||||||
|
|
||||||
ifeq "$(shell uname)" "Linux"
|
|
||||||
TARGETS = libtokencap.so
|
|
||||||
LDFLAGS += -ldl
|
|
||||||
endif
|
|
||||||
ifeq "$(shell uname)" "Darwin"
|
|
||||||
TARGETS = libtokencap.so
|
|
||||||
LDFLAGS += -ldl
|
|
||||||
endif
|
|
||||||
ifeq "$(shell uname)" "FreeBSD"
|
|
||||||
TARGETS = libtokencap.so
|
|
||||||
endif
|
|
||||||
ifeq "$(shell uname)" "OpenBSD"
|
|
||||||
TARGETS = libtokencap.so
|
|
||||||
endif
|
|
||||||
ifeq "$(shell uname)" "NetBSD"
|
|
||||||
TARGETS = libtokencap.so
|
|
||||||
endif
|
|
||||||
ifeq "$(shell uname)" "DragonFly"
|
|
||||||
TARGETS = libtokencap.so
|
|
||||||
LDFLAGS += -ldl
|
|
||||||
endif
|
|
||||||
all: $(TARGETS)
|
|
||||||
|
|
||||||
VPATH = ..
|
|
||||||
libtokencap.so: libtokencap.so.c ../config.h
|
|
||||||
$(CC) $(CFLAGS) -shared -fPIC $< -o ../$@ $(LDFLAGS)
|
|
||||||
|
|
||||||
.NOTPARALLEL: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
|
|
||||||
rm -f ../libtokencap.so
|
|
||||||
|
|
||||||
install: all
|
|
||||||
install -m 755 -d $${DESTDIR}$(HELPER_PATH)
|
|
||||||
install -m 755 ../libtokencap.so $${DESTDIR}$(HELPER_PATH)
|
|
||||||
install -m 644 -T README.md $${DESTDIR}$(DOC_PATH)/README.tokencap.md
|
|
||||||
|
|
||||||
|
375
llvm_mode/GNUmakefile
Normal file
375
llvm_mode/GNUmakefile
Normal file
@ -0,0 +1,375 @@
|
|||||||
|
#
|
||||||
|
# american fuzzy lop++ - LLVM instrumentation
|
||||||
|
# -----------------------------------------
|
||||||
|
#
|
||||||
|
# Written by Laszlo Szekeres <lszekeres@google.com> and
|
||||||
|
# Michal Zalewski
|
||||||
|
#
|
||||||
|
# LLVM integration design comes from Laszlo Szekeres.
|
||||||
|
#
|
||||||
|
# Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
# For Heiko:
|
||||||
|
#TEST_MMAP=1
|
||||||
|
HASH=\#
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
HELPER_PATH ?= $(PREFIX)/lib/afl
|
||||||
|
BIN_PATH ?= $(PREFIX)/bin
|
||||||
|
DOC_PATH ?= $(PREFIX)/share/doc/afl
|
||||||
|
MISC_PATH ?= $(PREFIX)/share/afl
|
||||||
|
MAN_PATH ?= $(PREFIX)/man/man8
|
||||||
|
|
||||||
|
VERSION = $(shell grep '^$(HASH)define VERSION ' ../config.h | cut -d '"' -f2)
|
||||||
|
|
||||||
|
ifeq "$(shell uname)" "OpenBSD"
|
||||||
|
LLVM_CONFIG ?= $(BIN_PATH)/llvm-config
|
||||||
|
HAS_OPT = $(shell test -x $(BIN_PATH)/opt && echo 0 || echo 1)
|
||||||
|
ifeq "$(HAS_OPT)" "1"
|
||||||
|
$(error llvm_mode needs a complete llvm installation (versions 3.8.0 up to 11) -> e.g. "pkg_add llvm-7.0.1p9")
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
LLVM_CONFIG ?= llvm-config
|
||||||
|
endif
|
||||||
|
|
||||||
|
LLVMVER = $(shell $(LLVM_CONFIG) --version 2>/dev/null )
|
||||||
|
LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^3\.[0-7]|^1[2-9]' && echo 1 || echo 0 )
|
||||||
|
LLVM_NEW_API = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[0-9]' && echo 1 || echo 0 )
|
||||||
|
LLVM_MAJOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/\..*//')
|
||||||
|
LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null)
|
||||||
|
LLVM_STDCXX = gnu++11
|
||||||
|
LLVM_APPLE = $(shell clang -v 2>&1 | grep -iq apple && echo 1 || echo 0)
|
||||||
|
LLVM_LTO = 0
|
||||||
|
|
||||||
|
ifeq "$(LLVMVER)" ""
|
||||||
|
$(warning [!] llvm_mode needs llvm-config, which was not found)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(LLVM_UNSUPPORTED)" "1"
|
||||||
|
$(warning llvm_mode only supports llvm versions 3.8.0 up to 11)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(LLVM_MAJOR)" "9"
|
||||||
|
$(info [+] llvm_mode detected llvm 9, enabling neverZero implementation)
|
||||||
|
$(info [+] llvm_mode detected llvm 9, enabling afl-clang-lto LTO implementation)
|
||||||
|
LLVM_LTO = 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(LLVM_NEW_API)" "1"
|
||||||
|
$(info [+] llvm_mode detected llvm 10+, enabling neverZero implementation and c++14)
|
||||||
|
$(info [+] llvm_mode detected llvm 9, enabling afl-clang-lto LTO implementation)
|
||||||
|
LLVM_STDCXX = c++14
|
||||||
|
LLVM_LTO = 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(LLVM_LTO)" "0"
|
||||||
|
$(info [+] llvm_mode detected llvm < 9, afl-clang-lto LTO will not be build.)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(LLVM_APPLE)" "1"
|
||||||
|
$(warning llvm_mode will not compile with Xcode clang...)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# We were using llvm-config --bindir to get the location of clang, but
|
||||||
|
# this seems to be busted on some distros, so using the one in $PATH is
|
||||||
|
# probably better.
|
||||||
|
|
||||||
|
CC = $(LLVM_BINDIR)/clang
|
||||||
|
CXX = $(LLVM_BINDIR)/clang++
|
||||||
|
|
||||||
|
ifeq "$(shell test -e $(CC) || echo 1 )" "1"
|
||||||
|
# llvm-config --bindir may not providing a valid path, so ...
|
||||||
|
ifeq "$(shell test -e '$(BIN_DIR)/clang' && echo 1)" "1"
|
||||||
|
# we found one in the local install directory, lets use these
|
||||||
|
CC = $(BIN_DIR)/clang
|
||||||
|
CXX = $(BIN_DIR)/clang++
|
||||||
|
else
|
||||||
|
# hope for the best
|
||||||
|
$(warning we have trouble finding clang/clang++ - llvm-config is not helping us)
|
||||||
|
CC = clang
|
||||||
|
CXX = clang++
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# sanity check.
|
||||||
|
# Are versions of clang --version and llvm-config --version equal?
|
||||||
|
CLANGVER = $(shell $(CC) --version | sed -E -ne '/^.*version\ ([0-9]\.[0-9]\.[0-9]).*/s//\1/p')
|
||||||
|
|
||||||
|
ifneq "$(CLANGVER)" "$(LLVMVER)"
|
||||||
|
CC = $(shell $(LLVM_CONFIG) --bindir)/clang
|
||||||
|
CXX = $(shell $(LLVM_CONFIG) --bindir)/clang++
|
||||||
|
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 - -flto=full -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
||||||
|
AFL_CLANG_FLTO ?= -flto=full
|
||||||
|
else
|
||||||
|
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -flto=thin -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
||||||
|
AFL_CLANG_FLTO ?= -flto=thin
|
||||||
|
else
|
||||||
|
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -flto -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
||||||
|
AFL_CLANG_FLTO ?= -flto
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(AFL_CLANG_FLTO)" ""
|
||||||
|
ifeq "$(AFL_REAL_LD)" ""
|
||||||
|
AFL_REAL_LD = $(shell readlink /bin/ld 2>/dev/null)
|
||||||
|
ifeq "$(AFL_REAL_LD)" ""
|
||||||
|
AFL_REAL_LD = $(shell readlink /usr/bin/ld 2>/dev/null)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
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)\" \
|
||||||
|
-DLLVM_BINDIR=\"$(LLVM_BINDIR)\" -DVERSION=\"$(VERSION)\" \
|
||||||
|
-DLLVM_VERSION=\"$(LLVMVER)\" -DAFL_CLANG_FLTO=\"$(AFL_CLANG_FLTO)\" \
|
||||||
|
-DAFL_REAL_LD=\"$(AFL_REAL_LD)\" -Wno-unused-function
|
||||||
|
ifdef AFL_TRACE_PC
|
||||||
|
CFLAGS += -DUSE_TRACE_PC=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
CXXFLAGS ?= -O3 -funroll-loops -D_FORTIFY_SOURCE=2
|
||||||
|
override CXXFLAGS += -Wall -g -I ../include/ \
|
||||||
|
-DVERSION=\"$(VERSION)\" -Wno-variadic-macros
|
||||||
|
|
||||||
|
CLANG_CFL = `$(LLVM_CONFIG) --cxxflags` -Wl,-znodelete -fno-rtti -fpic $(CXXFLAGS)
|
||||||
|
CLANG_LFL = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
# User teor2345 reports that this is required to make things work on MacOS X.
|
||||||
|
ifeq "$(shell uname)" "Darwin"
|
||||||
|
CLANG_LFL += -Wl,-flat_namespace -Wl,-undefined,suppress
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(shell uname)" "OpenBSD"
|
||||||
|
CLANG_LFL += `$(LLVM_CONFIG) --libdir`/libLLVM.so
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -fuse-ld=`command -v ld` -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
||||||
|
CFLAGS += -DAFL_CLANG_FUSELD=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(shell echo '$(HASH)include <sys/ipc.h>@$(HASH)include <sys/shm.h>@int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1"
|
||||||
|
SHMAT_OK=1
|
||||||
|
else
|
||||||
|
SHMAT_OK=0
|
||||||
|
CFLAGS+=-DUSEMMAP=1
|
||||||
|
LDFLAGS += -lrt
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(TEST_MMAP)" "1"
|
||||||
|
SHMAT_OK=0
|
||||||
|
CFLAGS+=-DUSEMMAP=1
|
||||||
|
LDFLAGS += -lrt
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef AFL_TRACE_PC
|
||||||
|
PROGS = ../afl-clang-fast ../afl-ld ../afl-llvm-pass.so ../afl-llvm-lto-whitelist.so ../afl-llvm-lto-instrumentation.so ../libLLVMInsTrim.so ../afl-llvm-rt.o ../afl-llvm-rt-32.o ../afl-llvm-rt-64.o ../compare-transform-pass.so ../split-compares-pass.so ../split-switches-pass.so ../cmplog-routines-pass.so ../cmplog-instructions-pass.so
|
||||||
|
else
|
||||||
|
PROGS = ../afl-clang-fast ../afl-llvm-rt.o ../afl-llvm-rt-32.o ../afl-llvm-rt-64.o ../compare-transform-pass.so ../split-compares-pass.so ../split-switches-pass.so ../cmplog-routines-pass.so ../cmplog-instructions-pass.so
|
||||||
|
endif
|
||||||
|
|
||||||
|
# If prerequisites are not given, warn, do not build anything, and exit with code 0
|
||||||
|
ifeq "$(LLVMVER)" ""
|
||||||
|
NO_BUILD = 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(LLVM_UNSUPPORTED)$(LLVM_APPLE)" "00"
|
||||||
|
NO_BUILD = 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq "$(NO_BUILD)" "1"
|
||||||
|
TARGETS = no_build
|
||||||
|
else
|
||||||
|
TARGETS = test_shm test_deps $(PROGS) afl-clang-fast.8 test_build all_done
|
||||||
|
endif
|
||||||
|
|
||||||
|
LLVM_MIN_4_0_1 = $(shell awk 'function tonum(ver, a) {split(ver,a,"."); return a[1]*1000000+a[2]*1000+a[3]} BEGIN { exit tonum(ARGV[1]) >= tonum(ARGV[2]) }' $(LLVMVER) 4.0.1; echo $$?)
|
||||||
|
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
ifeq "$(SHMAT_OK)" "1"
|
||||||
|
|
||||||
|
test_shm:
|
||||||
|
@echo "[+] shmat seems to be working."
|
||||||
|
@rm -f .test2
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
test_shm:
|
||||||
|
@echo "[-] shmat seems not to be working, switching to mmap implementation"
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
no_build:
|
||||||
|
@printf "%b\\n" "\\033[0;31mPrerequisites are not met, skipping build llvm_mode\\033[0m"
|
||||||
|
|
||||||
|
test_deps:
|
||||||
|
ifndef AFL_TRACE_PC
|
||||||
|
@echo "[*] Checking for working 'llvm-config'..."
|
||||||
|
ifneq "$(LLVM_APPLE)" "1"
|
||||||
|
@type $(LLVM_CONFIG) >/dev/null 2>&1 || ( echo "[-] Oops, can't find 'llvm-config'. Install clang or set \$$LLVM_CONFIG or \$$PATH beforehand."; echo " (Sometimes, the binary will be named llvm-config-3.5 or something like that.)"; exit 1 )
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
@echo "[!] Note: using -fsanitize=trace-pc mode (this will fail with older LLVM)."
|
||||||
|
endif
|
||||||
|
@echo "[*] Checking for working '$(CC)'..."
|
||||||
|
@type $(CC) >/dev/null 2>&1 || ( echo "[-] Oops, can't find '$(CC)'. Make sure that it's in your \$$PATH (or set \$$CC and \$$CXX)."; exit 1 )
|
||||||
|
@echo "[*] Checking for matching versions of '$(CC)' and '$(LLVM_CONFIG)'"
|
||||||
|
ifneq "$(CLANGVER)" "$(LLVMVER)"
|
||||||
|
@echo "[!] WARNING: we have llvm-config version $(LLVMVER) and a clang version $(CLANGVER)"
|
||||||
|
@echo "[!] Retrying with the clang compiler from llvm: CC=`llvm-config --bindir`/clang"
|
||||||
|
else
|
||||||
|
@echo "[*] We have llvm-config version $(LLVMVER) with a clang version $(CLANGVER), good."
|
||||||
|
endif
|
||||||
|
@echo "[*] Checking for '../afl-showmap'..."
|
||||||
|
@test -f ../afl-showmap || ( echo "[-] Oops, can't find '../afl-showmap'. Be sure to compile AFL first."; exit 1 )
|
||||||
|
@echo "[+] All set and ready to build."
|
||||||
|
|
||||||
|
afl-common.o: ../src/afl-common.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
../afl-clang-fast: afl-clang-fast.c afl-common.o | test_deps
|
||||||
|
$(CC) $(CFLAGS) $< afl-common.o -o $@ $(LDFLAGS) -DCFLAGS_OPT=\"$(CFLAGS_OPT)\"
|
||||||
|
ln -sf afl-clang-fast ../afl-clang-fast++
|
||||||
|
ifneq "$(AFL_CLANG_FLTO)" ""
|
||||||
|
ifeq "$(LLVM_LTO)" "1"
|
||||||
|
ln -sf afl-clang-fast ../afl-clang-lto
|
||||||
|
ln -sf afl-clang-fast ../afl-clang-lto++
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
../afl-ld: afl-ld.c
|
||||||
|
ifneq "$(AFL_CLANG_FLTO)" ""
|
||||||
|
ifeq "$(LLVM_LTO)" "1"
|
||||||
|
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
|
||||||
|
ln -sf afl-ld ../ld
|
||||||
|
@rm -f .test-instr
|
||||||
|
@-export AFL_QUIET=1 AFL_PATH=.. PATH="..:$(PATH)" ; ../afl-clang-lto -Wl,--afl -o .test-instr ../test-instr.c && echo "[+] afl-clang-lto and afl-ld seem to work fine :)" || echo "[!] WARNING: clang seems to have a hardcoded "'/bin/ld'" - check README.lto"
|
||||||
|
@rm -f .test-instr
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
../libLLVMInsTrim.so: LLVMInsTrim.so.cc MarkNodes.cc | test_deps
|
||||||
|
-$(CXX) $(CLANG_CFL) -DLLVMInsTrim_EXPORTS -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< MarkNodes.cc -o $@ $(CLANG_LFL)
|
||||||
|
|
||||||
|
../afl-llvm-pass.so: afl-llvm-pass.so.cc | test_deps
|
||||||
|
ifeq "$(LLVM_MIN_4_0_1)" "0"
|
||||||
|
$(info [!] N-gram branch coverage instrumentation is not available for llvm version $(LLVMVER))
|
||||||
|
endif
|
||||||
|
$(CXX) $(CLANG_CFL) -DLLVMInsTrim_EXPORTS -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< -o $@ $(CLANG_LFL)
|
||||||
|
|
||||||
|
../afl-llvm-lto-whitelist.so: afl-llvm-lto-whitelist.so.cc
|
||||||
|
ifeq "$(LLVM_LTO)" "1"
|
||||||
|
$(CXX) $(CLANG_CFL) -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< -o $@ $(CLANG_LFL)
|
||||||
|
endif
|
||||||
|
|
||||||
|
../afl-llvm-lto-instrumentation.so: afl-llvm-lto-instrumentation.so.cc MarkNodes.cc
|
||||||
|
ifeq "$(LLVM_LTO)" "1"
|
||||||
|
$(CXX) $(CLANG_CFL) -Wno-writable-strings -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< MarkNodes.cc -o $@ $(CLANG_LFL)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# laf
|
||||||
|
../split-switches-pass.so: split-switches-pass.so.cc | test_deps
|
||||||
|
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
||||||
|
../compare-transform-pass.so: compare-transform-pass.so.cc | test_deps
|
||||||
|
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
||||||
|
../split-compares-pass.so: split-compares-pass.so.cc | test_deps
|
||||||
|
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
||||||
|
# /laf
|
||||||
|
|
||||||
|
../cmplog-routines-pass.so: cmplog-routines-pass.cc | test_deps
|
||||||
|
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
||||||
|
|
||||||
|
../cmplog-instructions-pass.so: cmplog-instructions-pass.cc | test_deps
|
||||||
|
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
||||||
|
|
||||||
|
../afl-llvm-rt.o: afl-llvm-rt.o.c | test_deps
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
||||||
|
|
||||||
|
../afl-llvm-rt-32.o: afl-llvm-rt.o.c | test_deps
|
||||||
|
@printf "[*] Building 32-bit variant of the runtime (-m32)... "
|
||||||
|
@$(CC) $(CFLAGS) -m32 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
||||||
|
|
||||||
|
../afl-llvm-rt-64.o: afl-llvm-rt.o.c | test_deps
|
||||||
|
@printf "[*] Building 64-bit variant of the runtime (-m64)... "
|
||||||
|
@$(CC) $(CFLAGS) -m64 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
||||||
|
|
||||||
|
test_build: $(PROGS)
|
||||||
|
@echo "[*] Testing the CC wrapper and instrumentation output..."
|
||||||
|
unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; AFL_QUIET=1 AFL_PATH=. AFL_CC=$(CC) AFL_LLVM_LAF_SPLIT_SWITCHES=1 AFL_LLVM_LAF_TRANSFORM_COMPARES=1 AFL_LLVM_LAF_SPLIT_COMPARES=1 ../afl-clang-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
|
||||||
|
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
|
||||||
|
@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please post to https://github.com/AFLplusplus/AFLplusplus/issues to troubleshoot the issue."; echo; exit 1; fi
|
||||||
|
@echo "[+] All right, the instrumentation seems to be working!"
|
||||||
|
|
||||||
|
all_done: test_build
|
||||||
|
@echo "[+] All done! You can now use '../afl-clang-fast' to compile programs."
|
||||||
|
|
||||||
|
.NOTPARALLEL: clean
|
||||||
|
|
||||||
|
install: all
|
||||||
|
install -d -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(HELPER_PATH) $${DESTDIR}$(DOC_PATH) $${DESTDIR}$(MISC_PATH)
|
||||||
|
ifndef AFL_TRACE_PC
|
||||||
|
if [ -f ../afl-clang-fast -a -f ../libLLVMInsTrim.so -a -f ../afl-llvm-rt.o ]; then set -e; install -m 755 ../afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; install -m 755 ../libLLVMInsTrim.so ../afl-llvm-pass.so ../afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f afl-clang-lto -a -f afl-ld ]; then set -e; install -m 755 afl-clang-lto $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-lto++; install -m 755 afl-ld $${DESTDIR}$(HELPER_PATH); ln -sf afl-ld $${DESTDIR}$(HELPER_PATH)/ld; install -m 755 afl-llvm-lto-instrumentation.so $${DESTDIR}$(HELPER_PATH); install -m 755 afl-llvm-lto-whitelist.so $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
else
|
||||||
|
if [ -f ../afl-clang-fast -a -f ../afl-llvm-rt.o ]; then set -e; install -m 755 ../afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; install -m 755 ../afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
endif
|
||||||
|
if [ -f ../afl-llvm-rt-32.o ]; then set -e; install -m 755 ../afl-llvm-rt-32.o $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f ../afl-llvm-rt-64.o ]; then set -e; install -m 755 ../afl-llvm-rt-64.o $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f ../compare-transform-pass.so ]; then set -e; install -m 755 ../compare-transform-pass.so $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f ../split-compares-pass.so ]; then set -e; install -m 755 ../split-compares-pass.so $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f ../split-switches-pass.so ]; then set -e; install -m 755 ../split-switches-pass.so $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
if [ -f ../cmplog-instructions-pass.so ]; then set -e; install -m 755 ../cmplog-*-pass.so $${DESTDIR}$(HELPER_PATH); fi
|
||||||
|
set -e; if [ -f ../afl-clang-fast ] ; then ln -sf ../afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang ; ln -sf ../afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang++ ; else ln -sf ../afl-gcc $${DESTDIR}$(BIN_PATH)/afl-clang ; ln -sf ../afl-gcc $${DESTDIR}$(BIN_PATH)/afl-clang++; fi
|
||||||
|
install -m 644 README.*.md $${DESTDIR}$(DOC_PATH)/
|
||||||
|
install -m 644 -T README.md $${DESTDIR}$(DOC_PATH)/README.llvm_mode.md
|
||||||
|
|
||||||
|
vpath % ..
|
||||||
|
%.8: %
|
||||||
|
@echo .TH $* 8 `date "+%Y-%m-%d"` "afl++" > ../$@
|
||||||
|
@echo .SH NAME >> ../$@
|
||||||
|
@echo .B $* >> ../$@
|
||||||
|
@echo >> ../$@
|
||||||
|
@echo .SH SYNOPSIS >> ../$@
|
||||||
|
@../$* -h 2>&1 | head -n 3 | tail -n 1 | sed 's/^\.\///' >> ../$@
|
||||||
|
@echo >> ../$@
|
||||||
|
@echo .SH OPTIONS >> ../$@
|
||||||
|
@echo .nf >> ../$@
|
||||||
|
@../$* -h 2>&1 | tail -n +4 >> ../$@
|
||||||
|
@echo >> ../$@
|
||||||
|
@echo .SH AUTHOR >> ../$@
|
||||||
|
@echo "afl++ was written by Michal \"lcamtuf\" Zalewski and is maintained by Marc \"van Hauser\" Heuse <mh@mh-sec.de>, Heiko \"hexcoder-\" Eissfeldt <heiko.eissfeldt@hexco.de>, Andrea Fioraldi <andreafioraldi@gmail.com> and Dominik Maier <domenukk@gmail.com>" >> ../$@
|
||||||
|
@echo The homepage of afl++ is: https://github.com/AFLplusplus/AFLplusplus >> ../$@
|
||||||
|
@echo >> ../$@
|
||||||
|
@echo .SH LICENSE >> ../$@
|
||||||
|
@echo Apache License Version 2.0, January 2004 >> ../$@
|
||||||
|
ln -sf afl-clang-fast.8 ../afl-clang-fast++.8
|
||||||
|
ifneq "$(AFL_CLANG_FLTO)" ""
|
||||||
|
ifeq "$(LLVM_LTO)" "1"
|
||||||
|
ln -sf afl-clang-fast.8 ../afl-clang-lto.8
|
||||||
|
ln -sf afl-clang-fast.8 ../afl-clang-lto++.8
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.so *~ a.out core core.[1-9][0-9]* .test2 test-instr .test-instr0 .test-instr1 *.dwo
|
||||||
|
rm -f $(PROGS) afl-common.o ../afl-clang-fast++ ../afl-clang-lto ../afl-clang-lto++ ../afl-clang*.8 ../ld
|
@ -1,375 +1,2 @@
|
|||||||
#
|
all:
|
||||||
# american fuzzy lop++ - LLVM instrumentation
|
@echo please use GNU make, thanks!
|
||||||
# -----------------------------------------
|
|
||||||
#
|
|
||||||
# Written by Laszlo Szekeres <lszekeres@google.com> and
|
|
||||||
# Michal Zalewski
|
|
||||||
#
|
|
||||||
# LLVM integration design comes from Laszlo Szekeres.
|
|
||||||
#
|
|
||||||
# Copyright 2015, 2016 Google Inc. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at:
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
# For Heiko:
|
|
||||||
#TEST_MMAP=1
|
|
||||||
HASH=\#
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
HELPER_PATH ?= $(PREFIX)/lib/afl
|
|
||||||
BIN_PATH ?= $(PREFIX)/bin
|
|
||||||
DOC_PATH ?= $(PREFIX)/share/doc/afl
|
|
||||||
MISC_PATH ?= $(PREFIX)/share/afl
|
|
||||||
MAN_PATH ?= $(PREFIX)/man/man8
|
|
||||||
|
|
||||||
VERSION = $(shell grep '^$(HASH)define VERSION ' ../config.h | cut -d '"' -f2)
|
|
||||||
|
|
||||||
ifeq "$(shell uname)" "OpenBSD"
|
|
||||||
LLVM_CONFIG ?= $(BIN_PATH)/llvm-config
|
|
||||||
HAS_OPT = $(shell test -x $(BIN_PATH)/opt && echo 0 || echo 1)
|
|
||||||
ifeq "$(HAS_OPT)" "1"
|
|
||||||
$(error llvm_mode needs a complete llvm installation (versions 3.8.0 up to 11) -> e.g. "pkg_add llvm-7.0.1p9")
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
LLVM_CONFIG ?= llvm-config
|
|
||||||
endif
|
|
||||||
|
|
||||||
LLVMVER = $(shell $(LLVM_CONFIG) --version 2>/dev/null )
|
|
||||||
LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^3\.[0-7]|^1[2-9]' && echo 1 || echo 0 )
|
|
||||||
LLVM_NEW_API = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[0-9]' && echo 1 || echo 0 )
|
|
||||||
LLVM_MAJOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/\..*//')
|
|
||||||
LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null)
|
|
||||||
LLVM_STDCXX = gnu++11
|
|
||||||
LLVM_APPLE = $(shell clang -v 2>&1 | grep -iq apple && echo 1 || echo 0)
|
|
||||||
LLVM_LTO = 0
|
|
||||||
|
|
||||||
ifeq "$(LLVMVER)" ""
|
|
||||||
$(warning [!] llvm_mode needs llvm-config, which was not found)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(LLVM_UNSUPPORTED)" "1"
|
|
||||||
$(warning llvm_mode only supports llvm versions 3.8.0 up to 11)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(LLVM_MAJOR)" "9"
|
|
||||||
$(info [+] llvm_mode detected llvm 9, enabling neverZero implementation)
|
|
||||||
$(info [+] llvm_mode detected llvm 9, enabling afl-clang-lto LTO implementation)
|
|
||||||
LLVM_LTO = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(LLVM_NEW_API)" "1"
|
|
||||||
$(info [+] llvm_mode detected llvm 10+, enabling neverZero implementation and c++14)
|
|
||||||
$(info [+] llvm_mode detected llvm 9, enabling afl-clang-lto LTO implementation)
|
|
||||||
LLVM_STDCXX = c++14
|
|
||||||
LLVM_LTO = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(LLVM_LTO)" "0"
|
|
||||||
$(info [+] llvm_mode detected llvm < 9, afl-clang-lto LTO will not be build.)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(LLVM_APPLE)" "1"
|
|
||||||
$(warning llvm_mode will not compile with Xcode clang...)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# We were using llvm-config --bindir to get the location of clang, but
|
|
||||||
# this seems to be busted on some distros, so using the one in $PATH is
|
|
||||||
# probably better.
|
|
||||||
|
|
||||||
CC = $(LLVM_BINDIR)/clang
|
|
||||||
CXX = $(LLVM_BINDIR)/clang++
|
|
||||||
|
|
||||||
ifeq "$(shell test -e $(CC) || echo 1 )" "1"
|
|
||||||
# llvm-config --bindir may not providing a valid path, so ...
|
|
||||||
ifeq "$(shell test -e '$(BIN_DIR)/clang' && echo 1)" "1"
|
|
||||||
# we found one in the local install directory, lets use these
|
|
||||||
CC = $(BIN_DIR)/clang
|
|
||||||
CXX = $(BIN_DIR)/clang++
|
|
||||||
else
|
|
||||||
# hope for the best
|
|
||||||
$(warning we have trouble finding clang/clang++ - llvm-config is not helping us)
|
|
||||||
CC = clang
|
|
||||||
CXX = clang++
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# sanity check.
|
|
||||||
# Are versions of clang --version and llvm-config --version equal?
|
|
||||||
CLANGVER = $(shell $(CC) --version | sed -E -ne '/^.*version\ ([0-9]\.[0-9]\.[0-9]).*/s//\1/p')
|
|
||||||
|
|
||||||
ifneq "$(CLANGVER)" "$(LLVMVER)"
|
|
||||||
CC = $(shell $(LLVM_CONFIG) --bindir)/clang
|
|
||||||
CXX = $(shell $(LLVM_CONFIG) --bindir)/clang++
|
|
||||||
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 - -flto=full -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
|
||||||
AFL_CLANG_FLTO ?= -flto=full
|
|
||||||
else
|
|
||||||
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -flto=thin -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
|
||||||
AFL_CLANG_FLTO ?= -flto=thin
|
|
||||||
else
|
|
||||||
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -flto -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
|
||||||
AFL_CLANG_FLTO ?= -flto
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(AFL_CLANG_FLTO)" ""
|
|
||||||
ifeq "$(AFL_REAL_LD)" ""
|
|
||||||
AFL_REAL_LD = $(shell readlink /bin/ld 2>/dev/null)
|
|
||||||
ifeq "$(AFL_REAL_LD)" ""
|
|
||||||
AFL_REAL_LD = $(shell readlink /usr/bin/ld 2>/dev/null)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
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)\" \
|
|
||||||
-DLLVM_BINDIR=\"$(LLVM_BINDIR)\" -DVERSION=\"$(VERSION)\" \
|
|
||||||
-DLLVM_VERSION=\"$(LLVMVER)\" -DAFL_CLANG_FLTO=\"$(AFL_CLANG_FLTO)\" \
|
|
||||||
-DAFL_REAL_LD=\"$(AFL_REAL_LD)\" -Wno-unused-function
|
|
||||||
ifdef AFL_TRACE_PC
|
|
||||||
CFLAGS += -DUSE_TRACE_PC=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
CXXFLAGS ?= -O3 -funroll-loops -D_FORTIFY_SOURCE=2
|
|
||||||
override CXXFLAGS += -Wall -g -I ../include/ \
|
|
||||||
-DVERSION=\"$(VERSION)\" -Wno-variadic-macros
|
|
||||||
|
|
||||||
CLANG_CFL = `$(LLVM_CONFIG) --cxxflags` -Wl,-znodelete -fno-rtti -fpic $(CXXFLAGS)
|
|
||||||
CLANG_LFL = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
# User teor2345 reports that this is required to make things work on MacOS X.
|
|
||||||
ifeq "$(shell uname)" "Darwin"
|
|
||||||
CLANG_LFL += -Wl,-flat_namespace -Wl,-undefined,suppress
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(shell uname)" "OpenBSD"
|
|
||||||
CLANG_LFL += `$(LLVM_CONFIG) --libdir`/libLLVM.so
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -fuse-ld=`command -v ld` -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
|
||||||
CFLAGS += -DAFL_CLANG_FUSELD=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(shell echo '$(HASH)include <sys/ipc.h>@$(HASH)include <sys/shm.h>@int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1"
|
|
||||||
SHMAT_OK=1
|
|
||||||
else
|
|
||||||
SHMAT_OK=0
|
|
||||||
CFLAGS+=-DUSEMMAP=1
|
|
||||||
LDFLAGS += -lrt
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(TEST_MMAP)" "1"
|
|
||||||
SHMAT_OK=0
|
|
||||||
CFLAGS+=-DUSEMMAP=1
|
|
||||||
LDFLAGS += -lrt
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef AFL_TRACE_PC
|
|
||||||
PROGS = ../afl-clang-fast ../afl-ld ../afl-llvm-pass.so ../afl-llvm-lto-whitelist.so ../afl-llvm-lto-instrumentation.so ../libLLVMInsTrim.so ../afl-llvm-rt.o ../afl-llvm-rt-32.o ../afl-llvm-rt-64.o ../compare-transform-pass.so ../split-compares-pass.so ../split-switches-pass.so ../cmplog-routines-pass.so ../cmplog-instructions-pass.so
|
|
||||||
else
|
|
||||||
PROGS = ../afl-clang-fast ../afl-llvm-rt.o ../afl-llvm-rt-32.o ../afl-llvm-rt-64.o ../compare-transform-pass.so ../split-compares-pass.so ../split-switches-pass.so ../cmplog-routines-pass.so ../cmplog-instructions-pass.so
|
|
||||||
endif
|
|
||||||
|
|
||||||
# If prerequisites are not given, warn, do not build anything, and exit with code 0
|
|
||||||
ifeq "$(LLVMVER)" ""
|
|
||||||
NO_BUILD = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(LLVM_UNSUPPORTED)$(LLVM_APPLE)" "00"
|
|
||||||
NO_BUILD = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(NO_BUILD)" "1"
|
|
||||||
TARGETS = no_build
|
|
||||||
else
|
|
||||||
TARGETS = test_shm test_deps $(PROGS) afl-clang-fast.8 test_build all_done
|
|
||||||
endif
|
|
||||||
|
|
||||||
LLVM_MIN_4_0_1 = $(shell awk 'function tonum(ver, a) {split(ver,a,"."); return a[1]*1000000+a[2]*1000+a[3]} BEGIN { exit tonum(ARGV[1]) >= tonum(ARGV[2]) }' $(LLVMVER) 4.0.1; echo $$?)
|
|
||||||
|
|
||||||
all: $(TARGETS)
|
|
||||||
|
|
||||||
ifeq "$(SHMAT_OK)" "1"
|
|
||||||
|
|
||||||
test_shm:
|
|
||||||
@echo "[+] shmat seems to be working."
|
|
||||||
@rm -f .test2
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
test_shm:
|
|
||||||
@echo "[-] shmat seems not to be working, switching to mmap implementation"
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
no_build:
|
|
||||||
@printf "%b\\n" "\\033[0;31mPrerequisites are not met, skipping build llvm_mode\\033[0m"
|
|
||||||
|
|
||||||
test_deps:
|
|
||||||
ifndef AFL_TRACE_PC
|
|
||||||
@echo "[*] Checking for working 'llvm-config'..."
|
|
||||||
ifneq "$(LLVM_APPLE)" "1"
|
|
||||||
@type $(LLVM_CONFIG) >/dev/null 2>&1 || ( echo "[-] Oops, can't find 'llvm-config'. Install clang or set \$$LLVM_CONFIG or \$$PATH beforehand."; echo " (Sometimes, the binary will be named llvm-config-3.5 or something like that.)"; exit 1 )
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
@echo "[!] Note: using -fsanitize=trace-pc mode (this will fail with older LLVM)."
|
|
||||||
endif
|
|
||||||
@echo "[*] Checking for working '$(CC)'..."
|
|
||||||
@type $(CC) >/dev/null 2>&1 || ( echo "[-] Oops, can't find '$(CC)'. Make sure that it's in your \$$PATH (or set \$$CC and \$$CXX)."; exit 1 )
|
|
||||||
@echo "[*] Checking for matching versions of '$(CC)' and '$(LLVM_CONFIG)'"
|
|
||||||
ifneq "$(CLANGVER)" "$(LLVMVER)"
|
|
||||||
@echo "[!] WARNING: we have llvm-config version $(LLVMVER) and a clang version $(CLANGVER)"
|
|
||||||
@echo "[!] Retrying with the clang compiler from llvm: CC=`llvm-config --bindir`/clang"
|
|
||||||
else
|
|
||||||
@echo "[*] We have llvm-config version $(LLVMVER) with a clang version $(CLANGVER), good."
|
|
||||||
endif
|
|
||||||
@echo "[*] Checking for '../afl-showmap'..."
|
|
||||||
@test -f ../afl-showmap || ( echo "[-] Oops, can't find '../afl-showmap'. Be sure to compile AFL first."; exit 1 )
|
|
||||||
@echo "[+] All set and ready to build."
|
|
||||||
|
|
||||||
afl-common.o: ../src/afl-common.c
|
|
||||||
$(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
|
|
||||||
|
|
||||||
../afl-clang-fast: afl-clang-fast.c afl-common.o | test_deps
|
|
||||||
$(CC) $(CFLAGS) $< afl-common.o -o $@ $(LDFLAGS) -DCFLAGS_OPT=\"$(CFLAGS_OPT)\"
|
|
||||||
ln -sf afl-clang-fast ../afl-clang-fast++
|
|
||||||
ifneq "$(AFL_CLANG_FLTO)" ""
|
|
||||||
ifeq "$(LLVM_LTO)" "1"
|
|
||||||
ln -sf afl-clang-fast ../afl-clang-lto
|
|
||||||
ln -sf afl-clang-fast ../afl-clang-lto++
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
../afl-ld: afl-ld.c
|
|
||||||
ifneq "$(AFL_CLANG_FLTO)" ""
|
|
||||||
ifeq "$(LLVM_LTO)" "1"
|
|
||||||
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
|
|
||||||
ln -sf afl-ld ../ld
|
|
||||||
@rm -f .test-instr
|
|
||||||
@-export AFL_QUIET=1 AFL_PATH=.. PATH="..:$(PATH)" ; ../afl-clang-lto -Wl,--afl -o .test-instr ../test-instr.c && echo "[+] afl-clang-lto and afl-ld seem to work fine :)" || echo "[!] WARNING: clang seems to have a hardcoded "'/bin/ld'" - check README.lto"
|
|
||||||
@rm -f .test-instr
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
../libLLVMInsTrim.so: LLVMInsTrim.so.cc MarkNodes.cc | test_deps
|
|
||||||
-$(CXX) $(CLANG_CFL) -DLLVMInsTrim_EXPORTS -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< MarkNodes.cc -o $@ $(CLANG_LFL)
|
|
||||||
|
|
||||||
../afl-llvm-pass.so: afl-llvm-pass.so.cc | test_deps
|
|
||||||
ifeq "$(LLVM_MIN_4_0_1)" "0"
|
|
||||||
$(info [!] N-gram branch coverage instrumentation is not available for llvm version $(LLVMVER))
|
|
||||||
endif
|
|
||||||
$(CXX) $(CLANG_CFL) -DLLVMInsTrim_EXPORTS -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< -o $@ $(CLANG_LFL)
|
|
||||||
|
|
||||||
../afl-llvm-lto-whitelist.so: afl-llvm-lto-whitelist.so.cc
|
|
||||||
ifeq "$(LLVM_LTO)" "1"
|
|
||||||
$(CXX) $(CLANG_CFL) -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< -o $@ $(CLANG_LFL)
|
|
||||||
endif
|
|
||||||
|
|
||||||
../afl-llvm-lto-instrumentation.so: afl-llvm-lto-instrumentation.so.cc MarkNodes.cc
|
|
||||||
ifeq "$(LLVM_LTO)" "1"
|
|
||||||
$(CXX) $(CLANG_CFL) -Wno-writable-strings -fno-rtti -fPIC -std=$(LLVM_STDCXX) -shared $< MarkNodes.cc -o $@ $(CLANG_LFL)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# laf
|
|
||||||
../split-switches-pass.so: split-switches-pass.so.cc | test_deps
|
|
||||||
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
|
||||||
../compare-transform-pass.so: compare-transform-pass.so.cc | test_deps
|
|
||||||
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
|
||||||
../split-compares-pass.so: split-compares-pass.so.cc | test_deps
|
|
||||||
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
|
||||||
# /laf
|
|
||||||
|
|
||||||
../cmplog-routines-pass.so: cmplog-routines-pass.cc | test_deps
|
|
||||||
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
|
||||||
|
|
||||||
../cmplog-instructions-pass.so: cmplog-instructions-pass.cc | test_deps
|
|
||||||
$(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
|
|
||||||
|
|
||||||
../afl-llvm-rt.o: afl-llvm-rt.o.c | test_deps
|
|
||||||
$(CC) $(CFLAGS) -fPIC -c $< -o $@
|
|
||||||
|
|
||||||
../afl-llvm-rt-32.o: afl-llvm-rt.o.c | test_deps
|
|
||||||
@printf "[*] Building 32-bit variant of the runtime (-m32)... "
|
|
||||||
@$(CC) $(CFLAGS) -m32 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
||||||
|
|
||||||
../afl-llvm-rt-64.o: afl-llvm-rt.o.c | test_deps
|
|
||||||
@printf "[*] Building 64-bit variant of the runtime (-m64)... "
|
|
||||||
@$(CC) $(CFLAGS) -m64 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
|
|
||||||
|
|
||||||
test_build: $(PROGS)
|
|
||||||
@echo "[*] Testing the CC wrapper and instrumentation output..."
|
|
||||||
unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; AFL_QUIET=1 AFL_PATH=. AFL_CC=$(CC) AFL_LLVM_LAF_SPLIT_SWITCHES=1 AFL_LLVM_LAF_TRANSFORM_COMPARES=1 AFL_LLVM_LAF_SPLIT_COMPARES=1 ../afl-clang-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
|
|
||||||
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
|
|
||||||
@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please post to https://github.com/AFLplusplus/AFLplusplus/issues to troubleshoot the issue."; echo; exit 1; fi
|
|
||||||
@echo "[+] All right, the instrumentation seems to be working!"
|
|
||||||
|
|
||||||
all_done: test_build
|
|
||||||
@echo "[+] All done! You can now use '../afl-clang-fast' to compile programs."
|
|
||||||
|
|
||||||
.NOTPARALLEL: clean
|
|
||||||
|
|
||||||
install: all
|
|
||||||
install -d -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(HELPER_PATH) $${DESTDIR}$(DOC_PATH) $${DESTDIR}$(MISC_PATH)
|
|
||||||
ifndef AFL_TRACE_PC
|
|
||||||
if [ -f ../afl-clang-fast -a -f ../libLLVMInsTrim.so -a -f ../afl-llvm-rt.o ]; then set -e; install -m 755 ../afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; install -m 755 ../libLLVMInsTrim.so ../afl-llvm-pass.so ../afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f afl-clang-lto -a -f afl-ld ]; then set -e; install -m 755 afl-clang-lto $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-lto++; install -m 755 afl-ld $${DESTDIR}$(HELPER_PATH); ln -sf afl-ld $${DESTDIR}$(HELPER_PATH)/ld; install -m 755 afl-llvm-lto-instrumentation.so $${DESTDIR}$(HELPER_PATH); install -m 755 afl-llvm-lto-whitelist.so $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
else
|
|
||||||
if [ -f ../afl-clang-fast -a -f ../afl-llvm-rt.o ]; then set -e; install -m 755 ../afl-clang-fast $${DESTDIR}$(BIN_PATH); ln -sf afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang-fast++; install -m 755 ../afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
endif
|
|
||||||
if [ -f ../afl-llvm-rt-32.o ]; then set -e; install -m 755 ../afl-llvm-rt-32.o $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f ../afl-llvm-rt-64.o ]; then set -e; install -m 755 ../afl-llvm-rt-64.o $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f ../compare-transform-pass.so ]; then set -e; install -m 755 ../compare-transform-pass.so $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f ../split-compares-pass.so ]; then set -e; install -m 755 ../split-compares-pass.so $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f ../split-switches-pass.so ]; then set -e; install -m 755 ../split-switches-pass.so $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
if [ -f ../cmplog-instructions-pass.so ]; then set -e; install -m 755 ../cmplog-*-pass.so $${DESTDIR}$(HELPER_PATH); fi
|
|
||||||
set -e; if [ -f ../afl-clang-fast ] ; then ln -sf ../afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang ; ln -sf ../afl-clang-fast $${DESTDIR}$(BIN_PATH)/afl-clang++ ; else ln -sf ../afl-gcc $${DESTDIR}$(BIN_PATH)/afl-clang ; ln -sf ../afl-gcc $${DESTDIR}$(BIN_PATH)/afl-clang++; fi
|
|
||||||
install -m 644 README.*.md $${DESTDIR}$(DOC_PATH)/
|
|
||||||
install -m 644 -T README.md $${DESTDIR}$(DOC_PATH)/README.llvm_mode.md
|
|
||||||
|
|
||||||
vpath % ..
|
|
||||||
%.8: %
|
|
||||||
@echo .TH $* 8 `date "+%Y-%m-%d"` "afl++" > ../$@
|
|
||||||
@echo .SH NAME >> ../$@
|
|
||||||
@echo .B $* >> ../$@
|
|
||||||
@echo >> ../$@
|
|
||||||
@echo .SH SYNOPSIS >> ../$@
|
|
||||||
@../$* -h 2>&1 | head -n 3 | tail -n 1 | sed 's/^\.\///' >> ../$@
|
|
||||||
@echo >> ../$@
|
|
||||||
@echo .SH OPTIONS >> ../$@
|
|
||||||
@echo .nf >> ../$@
|
|
||||||
@../$* -h 2>&1 | tail -n +4 >> ../$@
|
|
||||||
@echo >> ../$@
|
|
||||||
@echo .SH AUTHOR >> ../$@
|
|
||||||
@echo "afl++ was written by Michal \"lcamtuf\" Zalewski and is maintained by Marc \"van Hauser\" Heuse <mh@mh-sec.de>, Heiko \"hexcoder-\" Eissfeldt <heiko.eissfeldt@hexco.de>, Andrea Fioraldi <andreafioraldi@gmail.com> and Dominik Maier <domenukk@gmail.com>" >> ../$@
|
|
||||||
@echo The homepage of afl++ is: https://github.com/AFLplusplus/AFLplusplus >> ../$@
|
|
||||||
@echo >> ../$@
|
|
||||||
@echo .SH LICENSE >> ../$@
|
|
||||||
@echo Apache License Version 2.0, January 2004 >> ../$@
|
|
||||||
ln -sf afl-clang-fast.8 ../afl-clang-fast++.8
|
|
||||||
ifneq "$(AFL_CLANG_FLTO)" ""
|
|
||||||
ifeq "$(LLVM_LTO)" "1"
|
|
||||||
ln -sf afl-clang-fast.8 ../afl-clang-lto.8
|
|
||||||
ln -sf afl-clang-fast.8 ../afl-clang-lto++.8
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o *.so *~ a.out core core.[1-9][0-9]* .test2 test-instr .test-instr0 .test-instr1 *.dwo
|
|
||||||
rm -f $(PROGS) afl-common.o ../afl-clang-fast++ ../afl-clang-lto ../afl-clang-lto++ ../afl-clang*.8 ../ld
|
|
||||||
|
44
qemu_mode/libcompcov/GNUmakefile
Normal file
44
qemu_mode/libcompcov/GNUmakefile
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#
|
||||||
|
# american fuzzy lop++ - libcompcov
|
||||||
|
# --------------------------------
|
||||||
|
#
|
||||||
|
# Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||||
|
#
|
||||||
|
# Copyright 2019-2020 Andrea Fioraldi. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
HELPER_PATH = $(PREFIX)/lib/afl
|
||||||
|
DOC_PATH ?= $(PREFIX)/share/doc/afl
|
||||||
|
MAN_PATH ?= $(PREFIX)/man/man8
|
||||||
|
|
||||||
|
VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
|
||||||
|
|
||||||
|
CFLAGS ?= -O3 -funroll-loops -I ../../include/
|
||||||
|
CFLAGS += -Wall -Wno-unused-result -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
|
||||||
|
LDFLAGS += -ldl
|
||||||
|
|
||||||
|
all: libcompcov.so
|
||||||
|
|
||||||
|
libcompcov.so: libcompcov.so.c ../../config.h
|
||||||
|
$(CC) $(CFLAGS) -shared -fPIC $< -o ../../$@ $(LDFLAGS)
|
||||||
|
|
||||||
|
.NOTPARALLEL: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
|
||||||
|
rm -f ../../libcompcov.so compcovtest
|
||||||
|
|
||||||
|
compcovtest: compcovtest.cc
|
||||||
|
$(CXX) -std=c++11 $< -o $@
|
||||||
|
|
||||||
|
install: all
|
||||||
|
install -m 755 ../../libcompcov.so $${DESTDIR}$(HELPER_PATH)
|
||||||
|
install -m 644 -T README.md $${DESTDIR}$(DOC_PATH)/README.compcov.md
|
||||||
|
|
@ -1,44 +1,2 @@
|
|||||||
#
|
all:
|
||||||
# american fuzzy lop++ - libcompcov
|
@echo please use GNU make, thanks!
|
||||||
# --------------------------------
|
|
||||||
#
|
|
||||||
# Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
|
||||||
#
|
|
||||||
# Copyright 2019-2020 Andrea Fioraldi. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at:
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
HELPER_PATH = $(PREFIX)/lib/afl
|
|
||||||
DOC_PATH ?= $(PREFIX)/share/doc/afl
|
|
||||||
MAN_PATH ?= $(PREFIX)/man/man8
|
|
||||||
|
|
||||||
VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
|
|
||||||
|
|
||||||
CFLAGS ?= -O3 -funroll-loops -I ../../include/
|
|
||||||
CFLAGS += -Wall -Wno-unused-result -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
|
|
||||||
LDFLAGS += -ldl
|
|
||||||
|
|
||||||
all: libcompcov.so
|
|
||||||
|
|
||||||
libcompcov.so: libcompcov.so.c ../../config.h
|
|
||||||
$(CC) $(CFLAGS) -shared -fPIC $< -o ../../$@ $(LDFLAGS)
|
|
||||||
|
|
||||||
.NOTPARALLEL: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
|
|
||||||
rm -f ../../libcompcov.so compcovtest
|
|
||||||
|
|
||||||
compcovtest: compcovtest.cc
|
|
||||||
$(CXX) -std=c++11 $< -o $@
|
|
||||||
|
|
||||||
install: all
|
|
||||||
install -m 755 ../../libcompcov.so $${DESTDIR}$(HELPER_PATH)
|
|
||||||
install -m 644 -T README.md $${DESTDIR}$(DOC_PATH)/README.compcov.md
|
|
||||||
|
|
||||||
|
34
qemu_mode/unsigaction/GNUmakefile
Normal file
34
qemu_mode/unsigaction/GNUmakefile
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#
|
||||||
|
# american fuzzy lop++ - unsigaction
|
||||||
|
# --------------------------------
|
||||||
|
#
|
||||||
|
# Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||||
|
#
|
||||||
|
# Copyright 2019-2020 Andrea Fioraldi. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at:
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
ifndef AFL_NO_X86
|
||||||
|
|
||||||
|
all: lib_i386 lib_amd64
|
||||||
|
|
||||||
|
lib_i386:
|
||||||
|
@$(CC) -m32 -fPIC -shared unsigaction.c -o unsigaction32.so 2>/dev/null ; if [ "$$?" = "0" ]; then echo "unsigaction32 build success"; else echo "unsigaction32 build failure (that's fine)"; fi
|
||||||
|
|
||||||
|
lib_amd64:
|
||||||
|
$(CC) -fPIC -shared unsigaction.c -o unsigaction64.so
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f unsigaction32.so unsigaction64.so
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo "[!] Note: skipping compilation of unsigaction (AFL_NO_X86 set)."
|
||||||
|
|
||||||
|
endif
|
@ -1,34 +1,2 @@
|
|||||||
#
|
|
||||||
# american fuzzy lop++ - unsigaction
|
|
||||||
# --------------------------------
|
|
||||||
#
|
|
||||||
# Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
|
||||||
#
|
|
||||||
# Copyright 2019-2020 Andrea Fioraldi. All rights reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at:
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
ifndef AFL_NO_X86
|
|
||||||
|
|
||||||
all: lib_i386 lib_amd64
|
|
||||||
|
|
||||||
lib_i386:
|
|
||||||
@$(CC) -m32 -fPIC -shared unsigaction.c -o unsigaction32.so 2>/dev/null ; if [ "$$?" = "0" ]; then echo "unsigaction32 build success"; else echo "unsigaction32 build failure (that's fine)"; fi
|
|
||||||
|
|
||||||
lib_amd64:
|
|
||||||
$(CC) -fPIC -shared unsigaction.c -o unsigaction64.so
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f unsigaction32.so unsigaction64.so
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@echo "[!] Note: skipping compilation of unsigaction (AFL_NO_X86 set)."
|
@echo please use GNU make, thanks!
|
||||||
|
|
||||||
endif
|
|
||||||
|
26
src/third_party/libradamsa/GNUmakefile
vendored
Normal file
26
src/third_party/libradamsa/GNUmakefile
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
all: libradamsa.so
|
||||||
|
|
||||||
|
# These can be overriden:
|
||||||
|
CFLAGS ?= -march=native $(CFLAGS_FLTO)
|
||||||
|
|
||||||
|
# These are required: (otherwise radamsa gets very very slooooow)
|
||||||
|
CFLAGS += -O3 -funroll-loops
|
||||||
|
|
||||||
|
libradamsa.so: libradamsa.a
|
||||||
|
$(CC) $(CFLAGS) -shared libradamsa.a -o libradamsa.so
|
||||||
|
|
||||||
|
libradamsa.a: libradamsa.c radamsa.h
|
||||||
|
@echo " ***************************************************************"
|
||||||
|
@echo " * Compiling libradamsa, wait some minutes (~3 on modern CPUs) *"
|
||||||
|
@echo " ***************************************************************"
|
||||||
|
$(CC) -fPIC $(CFLAGS) -I $(CUR_DIR) -o libradamsa.a -c libradamsa.c
|
||||||
|
|
||||||
|
test: libradamsa.a libradamsa-test.c
|
||||||
|
$(CC) $(CFLAGS) -I $(CUR_DIR) -o libradamsa-test libradamsa-test.c libradamsa.a
|
||||||
|
./libradamsa-test libradamsa-test.c | grep "library test passed"
|
||||||
|
rm /tmp/libradamsa-*.fuzz
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f libradamsa.a libradamsa.so libradamsa-test
|
28
src/third_party/libradamsa/Makefile
vendored
28
src/third_party/libradamsa/Makefile
vendored
@ -1,26 +1,2 @@
|
|||||||
CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
all:
|
||||||
|
@echo please use GNU make, thanks!
|
||||||
all: libradamsa.so
|
|
||||||
|
|
||||||
# These can be overriden:
|
|
||||||
CFLAGS ?= -march=native $(CFLAGS_FLTO)
|
|
||||||
|
|
||||||
# These are required: (otherwise radamsa gets very very slooooow)
|
|
||||||
CFLAGS += -O3 -funroll-loops
|
|
||||||
|
|
||||||
libradamsa.so: libradamsa.a
|
|
||||||
$(CC) $(CFLAGS) -shared libradamsa.a -o libradamsa.so
|
|
||||||
|
|
||||||
libradamsa.a: libradamsa.c radamsa.h
|
|
||||||
@echo " ***************************************************************"
|
|
||||||
@echo " * Compiling libradamsa, wait some minutes (~3 on modern CPUs) *"
|
|
||||||
@echo " ***************************************************************"
|
|
||||||
$(CC) -fPIC $(CFLAGS) -I $(CUR_DIR) -o libradamsa.a -c libradamsa.c
|
|
||||||
|
|
||||||
test: libradamsa.a libradamsa-test.c
|
|
||||||
$(CC) $(CFLAGS) -I $(CUR_DIR) -o libradamsa-test libradamsa-test.c libradamsa.a
|
|
||||||
./libradamsa-test libradamsa-test.c | grep "library test passed"
|
|
||||||
rm /tmp/libradamsa-*.fuzz
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f libradamsa.a libradamsa.so libradamsa-test
|
|
||||||
|
42
unicorn_mode/samples/c/GNUmakefile
Normal file
42
unicorn_mode/samples/c/GNUmakefile
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# UnicornAFL Usage
|
||||||
|
# Original Unicorn Example Makefile by Nguyen Anh Quynh <aquynh@gmail.com>, 2015
|
||||||
|
# Adapted for AFL++ by domenukk <domenukk@gmail.com>, 2020
|
||||||
|
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
|
LIBDIR = ../../unicornafl
|
||||||
|
BIN_EXT =
|
||||||
|
AR_EXT = a
|
||||||
|
|
||||||
|
# Verbose output?
|
||||||
|
V ?= 0
|
||||||
|
|
||||||
|
CFLAGS += -Wall -Werror -I../../unicornafl/include
|
||||||
|
|
||||||
|
LDFLAGS += -L$(LIBDIR) -lpthread -lm
|
||||||
|
ifeq ($(UNAME_S), Linux)
|
||||||
|
LDFLAGS += -lrt
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(CROSS),)
|
||||||
|
CC = $(CROSS)gcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
all: harness
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf *.o harness harness-debug
|
||||||
|
|
||||||
|
harness.o: harness.c ../../unicornafl/include/unicorn/*.h
|
||||||
|
${CC} ${CFLAGS} -O3 -c $<
|
||||||
|
|
||||||
|
harness-debug.o: harness.c ../../unicornafl/include/unicorn/*.h
|
||||||
|
${CC} ${CFLAGS} -g -c $< -o $@
|
||||||
|
|
||||||
|
harness: harness.o
|
||||||
|
${CC} -L${LIBDIR} $< ../../unicornafl/libunicornafl.a $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
debug: harness-debug.o
|
||||||
|
${CC} -L${LIBDIR} $< ../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
|
@ -1,42 +1,2 @@
|
|||||||
# UnicornAFL Usage
|
all:
|
||||||
# Original Unicorn Example Makefile by Nguyen Anh Quynh <aquynh@gmail.com>, 2015
|
@echo please use GNU make, thanks!
|
||||||
# Adapted for AFL++ by domenukk <domenukk@gmail.com>, 2020
|
|
||||||
|
|
||||||
UNAME_S := $(shell uname -s)
|
|
||||||
|
|
||||||
LIBDIR = ../../unicornafl
|
|
||||||
BIN_EXT =
|
|
||||||
AR_EXT = a
|
|
||||||
|
|
||||||
# Verbose output?
|
|
||||||
V ?= 0
|
|
||||||
|
|
||||||
CFLAGS += -Wall -Werror -I../../unicornafl/include
|
|
||||||
|
|
||||||
LDFLAGS += -L$(LIBDIR) -lpthread -lm
|
|
||||||
ifeq ($(UNAME_S), Linux)
|
|
||||||
LDFLAGS += -lrt
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(CROSS),)
|
|
||||||
CC = $(CROSS)gcc
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: all clean
|
|
||||||
|
|
||||||
all: harness
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf *.o harness harness-debug
|
|
||||||
|
|
||||||
harness.o: harness.c ../../unicornafl/include/unicorn/*.h
|
|
||||||
${CC} ${CFLAGS} -O3 -c $<
|
|
||||||
|
|
||||||
harness-debug.o: harness.c ../../unicornafl/include/unicorn/*.h
|
|
||||||
${CC} ${CFLAGS} -g -c $< -o $@
|
|
||||||
|
|
||||||
harness: harness.o
|
|
||||||
${CC} -L${LIBDIR} $< ../../unicornafl/libunicornafl.a $(LDFLAGS) -o $@
|
|
||||||
|
|
||||||
debug: harness-debug.o
|
|
||||||
${CC} -L${LIBDIR} $< ../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
|
|
||||||
|
42
unicorn_mode/samples/persistent/GNUmakefile
Normal file
42
unicorn_mode/samples/persistent/GNUmakefile
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# UnicornAFL Usage
|
||||||
|
# Original Unicorn Example Makefile by Nguyen Anh Quynh <aquynh@gmail.com>, 2015
|
||||||
|
# Adapted for AFL++ by domenukk <domenukk@gmail.com>, 2020
|
||||||
|
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
|
LIBDIR = ../../unicornafl
|
||||||
|
BIN_EXT =
|
||||||
|
AR_EXT = a
|
||||||
|
|
||||||
|
# Verbose output?
|
||||||
|
V ?= 0
|
||||||
|
|
||||||
|
CFLAGS += -Wall -Werror -I../../unicornafl/include
|
||||||
|
|
||||||
|
LDFLAGS += -L$(LIBDIR) -lpthread -lm
|
||||||
|
ifeq ($(UNAME_S), Linux)
|
||||||
|
LDFLAGS += -lrt
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(CROSS),)
|
||||||
|
CC = $(CROSS)gcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
all: harness
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf *.o harness harness-debug
|
||||||
|
|
||||||
|
harness.o: harness.c ../../unicornafl/include/unicorn/*.h
|
||||||
|
${CC} ${CFLAGS} -O3 -c $<
|
||||||
|
|
||||||
|
harness-debug.o: harness.c ../../unicornafl/include/unicorn/*.h
|
||||||
|
${CC} ${CFLAGS} -g -c $< -o $@
|
||||||
|
|
||||||
|
harness: harness.o
|
||||||
|
${CC} -L${LIBDIR} $< ../../unicornafl/libunicornafl.a $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
debug: harness-debug.o
|
||||||
|
${CC} -L${LIBDIR} $< ../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
|
@ -1,42 +1,2 @@
|
|||||||
# UnicornAFL Usage
|
all:
|
||||||
# Original Unicorn Example Makefile by Nguyen Anh Quynh <aquynh@gmail.com>, 2015
|
@echo please use GNU make, thanks!
|
||||||
# Adapted for AFL++ by domenukk <domenukk@gmail.com>, 2020
|
|
||||||
|
|
||||||
UNAME_S := $(shell uname -s)
|
|
||||||
|
|
||||||
LIBDIR = ../../unicornafl
|
|
||||||
BIN_EXT =
|
|
||||||
AR_EXT = a
|
|
||||||
|
|
||||||
# Verbose output?
|
|
||||||
V ?= 0
|
|
||||||
|
|
||||||
CFLAGS += -Wall -Werror -I../../unicornafl/include
|
|
||||||
|
|
||||||
LDFLAGS += -L$(LIBDIR) -lpthread -lm
|
|
||||||
ifeq ($(UNAME_S), Linux)
|
|
||||||
LDFLAGS += -lrt
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(CROSS),)
|
|
||||||
CC = $(CROSS)gcc
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: all clean
|
|
||||||
|
|
||||||
all: harness
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf *.o harness harness-debug
|
|
||||||
|
|
||||||
harness.o: harness.c ../../unicornafl/include/unicorn/*.h
|
|
||||||
${CC} ${CFLAGS} -O3 -c $<
|
|
||||||
|
|
||||||
harness-debug.o: harness.c ../../unicornafl/include/unicorn/*.h
|
|
||||||
${CC} ${CFLAGS} -g -c $< -o $@
|
|
||||||
|
|
||||||
harness: harness.o
|
|
||||||
${CC} -L${LIBDIR} $< ../../unicornafl/libunicornafl.a $(LDFLAGS) -o $@
|
|
||||||
|
|
||||||
debug: harness-debug.o
|
|
||||||
${CC} -L${LIBDIR} $< ../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug
|
|
||||||
|
Reference in New Issue
Block a user