Add notes on using afl-fuzz to HACKING.
authorNico Weber <nicolasweber@gmx.de>
Tue, 3 Mar 2015 01:11:30 +0000 (17:11 -0800)
committerNico Weber <nicolasweber@gmx.de>
Thu, 19 Mar 2015 17:41:28 +0000 (10:41 -0700)
18 files changed:
HACKING.md
misc/afl-fuzz-tokens/kw_build [new file with mode: 0644]
misc/afl-fuzz-tokens/kw_default [new file with mode: 0644]
misc/afl-fuzz-tokens/kw_include [new file with mode: 0644]
misc/afl-fuzz-tokens/kw_pool [new file with mode: 0644]
misc/afl-fuzz-tokens/kw_rule [new file with mode: 0644]
misc/afl-fuzz-tokens/kw_subninja [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_a [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_b [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_colon [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_cont [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_dollar [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_eq [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_indent [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_pipe [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_pipepipe [new file with mode: 0644]
misc/afl-fuzz-tokens/misc_space [new file with mode: 0644]
misc/afl-fuzz/build.ninja [new file with mode: 0644]

index e3940ff..9c6830f 100644 (file)
@@ -177,3 +177,33 @@ root directory:
     gcov build/*.o
 
 Look at the generated `.gcov` files directly, or use your favorit gcov viewer.
+
+### Using afl-fuzz
+
+Build with afl-clang++:
+
+    CXX=path/to/afl-1.20b/afl-clang++ ./configure.py
+    ninja
+
+Then run afl-fuzz like so:
+
+    afl-fuzz -i misc/afl-fuzz -o /tmp/afl-fuzz-out ./ninja -n -f @@
+
+You can pass `-x misc/afl-fuzz-tokens` to use the token dictionary. In my
+testing, that did not seem more effective though.
+
+#### Using afl-fuzz with asan
+
+If you want to use asan (the `isysroot` bit is only needed on OS X; if clang
+can't find C++ standard headers make sure your LLVM checkout includes a libc++
+checkout and has libc++ installed in the build directory):
+
+    CFLAGS="-fsanitize=address -isysroot $(xcrun -show-sdk-path)" \
+        LDFLAGS=-fsanitize=address CXX=path/to/afl-1.20b/afl-clang++ \
+        ./configure.py
+    AFL_CXX=path/to/clang++ ninja
+
+Make sure ninja can find the asan runtime:
+
+    DYLD_LIBRARY_PATH=path/to//lib/clang/3.7.0/lib/darwin/ \
+        afl-fuzz -i misc/afl-fuzz -o /tmp/afl-fuzz-out ./ninja -n -f @@
diff --git a/misc/afl-fuzz-tokens/kw_build b/misc/afl-fuzz-tokens/kw_build
new file mode 100644 (file)
index 0000000..c795b05
--- /dev/null
@@ -0,0 +1 @@
+build
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/kw_default b/misc/afl-fuzz-tokens/kw_default
new file mode 100644 (file)
index 0000000..331d858
--- /dev/null
@@ -0,0 +1 @@
+default
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/kw_include b/misc/afl-fuzz-tokens/kw_include
new file mode 100644 (file)
index 0000000..2996fba
--- /dev/null
@@ -0,0 +1 @@
+include
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/kw_pool b/misc/afl-fuzz-tokens/kw_pool
new file mode 100644 (file)
index 0000000..e783591
--- /dev/null
@@ -0,0 +1 @@
+pool
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/kw_rule b/misc/afl-fuzz-tokens/kw_rule
new file mode 100644 (file)
index 0000000..841e840
--- /dev/null
@@ -0,0 +1 @@
+rule
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/kw_subninja b/misc/afl-fuzz-tokens/kw_subninja
new file mode 100644 (file)
index 0000000..c4fe0c7
--- /dev/null
@@ -0,0 +1 @@
+subninja
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/misc_a b/misc/afl-fuzz-tokens/misc_a
new file mode 100644 (file)
index 0000000..2e65efe
--- /dev/null
@@ -0,0 +1 @@
+a
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/misc_b b/misc/afl-fuzz-tokens/misc_b
new file mode 100644 (file)
index 0000000..63d8dbd
--- /dev/null
@@ -0,0 +1 @@
+b
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/misc_colon b/misc/afl-fuzz-tokens/misc_colon
new file mode 100644 (file)
index 0000000..22ded55
--- /dev/null
@@ -0,0 +1 @@
+:
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/misc_cont b/misc/afl-fuzz-tokens/misc_cont
new file mode 100644 (file)
index 0000000..857f13a
--- /dev/null
@@ -0,0 +1 @@
+$
diff --git a/misc/afl-fuzz-tokens/misc_dollar b/misc/afl-fuzz-tokens/misc_dollar
new file mode 100644 (file)
index 0000000..6f4f765
--- /dev/null
@@ -0,0 +1 @@
+$
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/misc_eq b/misc/afl-fuzz-tokens/misc_eq
new file mode 100644 (file)
index 0000000..851c75c
--- /dev/null
@@ -0,0 +1 @@
+=
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/misc_indent b/misc/afl-fuzz-tokens/misc_indent
new file mode 100644 (file)
index 0000000..136d063
--- /dev/null
@@ -0,0 +1 @@
+  
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/misc_pipe b/misc/afl-fuzz-tokens/misc_pipe
new file mode 100644 (file)
index 0000000..a3871d4
--- /dev/null
@@ -0,0 +1 @@
+|
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/misc_pipepipe b/misc/afl-fuzz-tokens/misc_pipepipe
new file mode 100644 (file)
index 0000000..27cc728
--- /dev/null
@@ -0,0 +1 @@
+||
\ No newline at end of file
diff --git a/misc/afl-fuzz-tokens/misc_space b/misc/afl-fuzz-tokens/misc_space
new file mode 100644 (file)
index 0000000..0519ecb
--- /dev/null
@@ -0,0 +1 @@
\ No newline at end of file
diff --git a/misc/afl-fuzz/build.ninja b/misc/afl-fuzz/build.ninja
new file mode 100644 (file)
index 0000000..52cd2f1
--- /dev/null
@@ -0,0 +1,5 @@
+rule b
+  command = clang -MMD -MF $out.d -o $out -c $in
+  description = building $out
+
+build a.o: b a.c