Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: third_party/afl/src/llvm_mode/Makefile

Issue 2075883002: Add American Fuzzy Lop (afl) to third_party/afl/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #
2 # american fuzzy lop - LLVM instrumentation
3 # -----------------------------------------
4 #
5 # Written by Laszlo Szekeres <lszekeres@google.com> and
6 # Michal Zalewski <lcamtuf@google.com>
7 #
8 # LLVM integration design comes from Laszlo Szekeres.
9 #
10 # Copyright 2015, 2016 Google Inc. All rights reserved.
11 #
12 # Licensed under the Apache License, Version 2.0 (the "License");
13 # you may not use this file except in compliance with the License.
14 # You may obtain a copy of the License at:
15 #
16 # http://www.apache.org/licenses/LICENSE-2.0
17 #
18
19 PREFIX ?= /usr/local
20 HELPER_PATH = $(PREFIX)/lib/afl
21 BIN_PATH = $(PREFIX)/bin
22
23 VERSION = $(shell grep ^VERSION ../Makefile | cut -d= -f2 | sed 's/ //')
24
25 LLVM_CONFIG ?= llvm-config
26
27 CFLAGS ?= -O3 -funroll-loops
28 CFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign \
29 -DAFL_PATH=\"$(HELPER_PATH)\" -DBIN_PATH=\"$(BIN_PATH)\" \
30 -DVERSION=\"$(VERSION)\"
31 ifdef AFL_TRACE_PC
32 CFLAGS += -DUSE_TRACE_PC=1
33 endif
34
35 CXXFLAGS ?= -O3 -funroll-loops
36 CXXFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign \
37 -DVERSION=\"$(VERSION)\" -Wno-variadic-macros
38
39 CLANG_CFL = `$(LLVM_CONFIG) --cxxflags` -fno-rtti -fpic $(CXXFLAGS)
40 CLANG_LFL = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)
41
42 # User teor2345 reports that this is required to make things work on MacOS X.
43
44 ifeq "$(shell uname)" "Darwin"
45 CLANG_LFL += -Wl,-flat_namespace -Wl,-undefined,suppress
46 endif
47
48 # We were using llvm-config --bindir to get the location of clang, but
49 # this seems to be busted on some distros, so using the one in $PATH is
50 # probably better.
51
52 ifeq "$(origin CC)" "default"
53 CC = clang
54 CXX = clang++
55 endif
56
57 ifndef AFL_TRACE_PC
58 PROGS = ../afl-clang-fast ../afl-llvm-pass.so ../afl-llvm-rt.o ../afl-llv m-rt-32.o ../afl-llvm-rt-64.o
59 else
60 PROGS = ../afl-clang-fast ../afl-llvm-rt.o ../afl-llvm-rt-32.o ../afl-llv m-rt-64.o
61 endif
62
63 all: test_deps $(PROGS) test_build all_done
64
65 test_deps:
66 ifndef AFL_TRACE_PC
67 @echo "[*] Checking for working 'llvm-config'..."
68 @which $(LLVM_CONFIG) >/dev/null 2>&1 || ( echo "[-] Oops, can't find 'l lvm-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 )
69 else
70 @echo "[!] Note: using -fsanitize=trace-pc mode (this will fail with old er LLVM)."
71 endif
72 @echo "[*] Checking for working '$(CC)'..."
73 @which $(CC) >/dev/null 2>&1 || ( echo "[-] Oops, can't find '$(CC)'. Ma ke sure that it's in your \$$PATH (or set \$$CC and \$$CXX)."; exit 1 )
74 @echo "[*] Checking for '../afl-showmap'..."
75 @test -f ../afl-showmap || ( echo "[-] Oops, can't find '../afl-showmap' . Be sure to compile AFL first."; exit 1 )
76 @echo "[+] All set and ready to build."
77
78 ../afl-clang-fast: afl-clang-fast.c | test_deps
79 $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
80 ln -sf afl-clang-fast ../afl-clang-fast++
81
82 ../afl-llvm-pass.so: afl-llvm-pass.so.cc | test_deps
83 $(CXX) $(CLANG_CFL) -shared $< -o $@ $(CLANG_LFL)
84
85 ../afl-llvm-rt.o: afl-llvm-rt.o.c | test_deps
86 $(CC) $(CFLAGS) -fPIC -c $< -o $@
87
88 ../afl-llvm-rt-32.o: afl-llvm-rt.o.c | test_deps
89 @printf "[*] Building 32-bit variant of the runtime (-m32)... "
90 @$(CC) $(CFLAGS) -m32 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
91
92 ../afl-llvm-rt-64.o: afl-llvm-rt.o.c | test_deps
93 @printf "[*] Building 64-bit variant of the runtime (-m64)... "
94 @$(CC) $(CFLAGS) -m64 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
95
96 test_build: $(PROGS)
97 @echo "[*] Testing the CC wrapper and instrumentation output..."
98 unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; AFL_QUIET=1 AFL_PATH=. A FL_CC=$(CC) ../afl-clang-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
99 echo 0 | ../afl-showmap -m none -q -o .test-instr0 ./test-instr
100 echo 1 | ../afl-showmap -m none -q -o .test-instr1 ./test-instr
101 @rm -f test-instr
102 @cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-in str1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not s eem to be behaving correctly!"; echo; echo "Please ping <lcamtuf@google.com> to troubleshoot the issue."; echo; exit 1; fi
103 @echo "[+] All right, the instrumentation seems to be working!"
104
105 all_done: test_build
106 @echo "[+] All done! You can now use '../afl-clang-fast' to compile prog rams."
107
108 .NOTPARALLEL: clean
109
110 clean:
111 rm -f *.o *.so *~ a.out core core.[1-9][0-9]* test-instr .test-instr0 .t est-instr1
112 rm -f $(PROGS) ../afl-clang-fast++
OLDNEW
« no previous file with comments | « third_party/afl/src/experimental/post_library/post_library_png.so.c ('k') | third_party/afl/src/llvm_mode/README.llvm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698