]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/fuzzing: Use --fuzz-target-ldflags if specified
authorAndrew Bartlett <abartlet@samba.org>
Tue, 5 Nov 2019 23:24:18 +0000 (12:24 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 20 Nov 2019 23:19:35 +0000 (23:19 +0000)
This makes integration with oss-fuzz possible.  Only the fuzzer binaries should be
linked with libFuzzer, not things like asn1_compile, so this can not be done via
the global ADDITIONAL_LDFLAGS.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Uri Simchoni <uri@samba.org>
buildtools/wafsamba/wafsamba.py
buildtools/wafsamba/wscript
lib/fuzzing/wscript_build

index 3e19b832e11e6d52f02a28d0e8ea1b88daaf7923..7460fbae020a657ac9670cd3f1b9de511badd74c 100644 (file)
@@ -377,6 +377,8 @@ def SAMBA_BINARY(bld, binname, source,
 
     if fuzzer:
         install = False
+        if ldflags is None:
+            ldflags = bld.env['FUZZ_TARGET_LDFLAGS']
 
     if not SET_TARGET_TYPE(bld, binname, 'BINARY'):
         return
index b601dd2596dc4ae3c5181371d4edd327c8c0c826..9987c6e4fccb1763a436307c1c67e8cf399500d9 100644 (file)
@@ -130,9 +130,16 @@ def options(opt):
         dest='undefined_sanitizer',
         default=False)
     gr.add_option('--enable-libfuzzer',
-                  help=("Build fuzzing binaries (requires compiler options for libFuzzer or compiler wrapper such as honggfuzz/hfuzz-cc)"),
+                  help=("Build fuzzing binaries (use ADDITIONAL_CFLAGS to specify compiler options for libFuzzer or use a compiler wrapper such as honggfuzz/hfuzz-cc)"),
                   action="store_true", dest='enable_libfuzzer', default=False)
 
+    # Fuzz targets may need additional LDFLAGS that we can't use on
+    # internal binaries like asn1_compile
+
+    gr.add_option('--fuzz-target-ldflags',
+                  help=("Linker flags to be used when building fuzz targets"),
+                  action="store", dest='FUZZ_TARGET_LDFLAGS', default='')
+
     gr.add_option('--abi-check',
                   help=("Check ABI signatures for libraries"),
                   action='store_true', dest='ABI_CHECK', default=False)
@@ -596,6 +603,7 @@ struct foo bar = { .y = 'X', .x = 1 };
     conf.env.enable_libfuzzer = Options.options.enable_libfuzzer
     if conf.env.enable_libfuzzer:
         conf.DEFINE('ENABLE_LIBFUZZER', 1)
+        conf.env.FUZZ_TARGET_LDFLAGS = Options.options.FUZZ_TARGET_LDFLAGS
 
     conf.load('clang_compilation_database')
 
index 00a263ef8774e739ef3bd95b50d3bd0c0dc15977..386145c43b2e51072b4536159d80dd81fe142acb 100644 (file)
@@ -3,7 +3,7 @@
 bld.SAMBA_SUBSYSTEM('fuzzing',
     source='fuzzing.c',
     deps='talloc',
-    enabled=bld.env.enable_libfuzzer,
+    enabled=bld.env.enable_libfuzzer
     )
 
 bld.SAMBA_BINARY('fuzz_tiniparser',