Index: third_party/afl/BUILD.gn |
diff --git a/third_party/afl/BUILD.gn b/third_party/afl/BUILD.gn |
index c4627c3699468a75d30e9f8fd3af8e9c7f4bd61f..a3278cfcb811f3c39a2a3752c00370c56c206d4e 100644 |
--- a/third_party/afl/BUILD.gn |
+++ b/third_party/afl/BUILD.gn |
@@ -2,6 +2,17 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+group("afl") { |
+ deps = [ |
+ ":afl-cmin", |
+ ":afl-fuzz", |
+ ":afl-showmap", |
+ ":afl-tmin", |
+ ":afl_docs", |
+ ":afl_runtime", |
+ ] |
+} |
+ |
source_set("afl_runtime") { |
# AFL needs this flag to be built with -Werror. This is because it uses u8* |
# and char* types interchangeably in its source code. The AFL Makefiles use |
@@ -25,3 +36,93 @@ source_set("afl_runtime") { |
"src/llvm_mode/afl-llvm-rt.o.c", |
] |
} |
+ |
+copy("afl-cmin") { |
inferno
2016/06/27 04:27:39
copy blocks will look more readable after the conf
Jonathan Metzman
2016/06/27 05:36:07
Done.
|
+ # afl-cmin is a bash script used to minimize the corpus, therefore we can just |
+ # copy it over. |
+ sources = [ |
+ "src/afl-cmin", |
+ ] |
+ outputs = [ |
+ "$root_build_dir/{{source_file_part}}", |
+ ] |
+ deps = [ |
+ ":afl-showmap", |
+ ] |
+} |
+ |
+copy("afl_docs") { |
+ # Copy the docs folder. This is so that we can use a real value for for |
inferno
2016/06/27 04:27:39
s/for for/for
Why are docs even needed for compil
Jonathan Metzman
2016/06/27 04:33:42
When afl-fuzz prints error messages it sometimes i
|
+ # -DDOC_PATH when compiling. |
+ sources = [ |
+ "src/docs", |
+ ] |
+ outputs = [ |
+ "$root_build_dir/afl/{{source_file_part}}", |
+ ] |
+} |
+ |
+afl_headers = [ |
+ "src/config.h", |
inferno
2016/06/27 04:27:39
alpha order
Jonathan Metzman
2016/06/27 05:36:07
Done.
|
+ "src/types.h", |
+ "src/debug.h", |
+ "src/alloc-inl.h", |
+ "src/hash.h", |
+] |
+ |
+config("afl-tool") { |
+ cflags = [ |
+ # Include flags from afl's Makefile. -Wno-pointer-sign is necessary |
+ # to build with -Werror. |
+ "-O3", |
+ "-funroll-loops", |
+ "-Wno-pointer-sign", |
inferno
2016/06/27 04:27:39
Move this near line 83 and remove its comment from
Jonathan Metzman
2016/06/27 05:36:07
Done.
|
+ "-D_FORTIFY_SOURCE=2", |
+ |
+ # This flag is also necessary to build with -Werror. |
+ "-Wno-sign-compare", |
+ |
+ # TODO: Patch afl so the version is defined in source code and not the |
+ # Makefile. |
+ "-DVERSION=\"2.14b\"", |
+ |
+ # afl_docs copies docs/ to this location. |
+ "-DDOC_PATH=\"$root_build_dir/afl/docs/\"", |
+ |
+ # Since we are not running make install, don't |
inferno
2016/06/27 04:27:39
Missing language in comment after "don't"
Jonathan Metzman
2016/06/27 05:36:07
Done.
|
+ # important that afl builds. |
+ "-DBIN_PATH=\"$root_build_dir\"", |
+ "-DMISC_PATH=\"$root_build_dir\"", |
+ ] |
+} |
+ |
+executable("afl-fuzz") { |
+ # Used to fuzz programs. |
+ configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ] |
+ configs += [ ":afl-tool" ] |
+ |
+ sources = [ |
+ "src/afl-fuzz.c", |
+ ] |
+ sources += afl_headers |
+} |
+ |
+executable("afl-tmin") { |
+ configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ] |
+ configs += [ ":afl-tool" ] |
+ |
+ sources = [ |
+ "src/afl-tmin.c", |
+ ] |
+ sources += afl_headers |
+} |
+ |
+executable("afl-showmap") { |
+ configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ] |
+ configs += [ ":afl-tool" ] |
+ |
+ sources = [ |
+ "src/afl-showmap.c", |
+ ] |
+ sources += afl_headers |
+} |