summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorJonathan Rudenberg <jonathan@titanous.com>2018-01-13 19:51:07 -0500
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:50:11 +0200
commit0760f3fc11b4042a0724c9d45fb0d5b6bacf2cb1 (patch)
treee4925fa275609c4045f556c458cf218790541d4a /meson.build
parentcfd51ef3e72fc5d0651dae32f79ccab69bab9569 (diff)
fuzz: add initial fuzzing infrastructure
The fuzzers will be used by oss-fuzz to automatically and continuously fuzz systemd. This commit includes the build tooling necessary to build fuzz targets, and a fuzzer for the DNS packet parser.
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build51
1 files changed, 49 insertions, 2 deletions
diff --git a/meson.build b/meson.build
index abc9fbecf..748438fdb 100644
--- a/meson.build
+++ b/meson.build
@@ -332,6 +332,11 @@ if get_option('tests') != 'false'
endif
endif
+ossfuzz = get_option('oss-fuzz')
+if ossfuzz
+ fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
+endif
+
foreach arg : ['-Wextra',
'-Werror=undef',
'-Wlogical-op',
@@ -366,7 +371,6 @@ foreach arg : ['-Wextra',
'-fvisibility=hidden',
'-fstack-protector',
'-fstack-protector-strong',
- '-fPIE',
'--param=ssp-buffer-size=4',
]
if cc.has_argument(arg)
@@ -374,6 +378,14 @@ foreach arg : ['-Wextra',
endif
endforeach
+# the oss-fuzz fuzzers are not built with -fPIE, so don't
+# enable it when we are linking against them
+if not ossfuzz
+ if cc.has_argument('-fPIE')
+ add_project_arguments('-fPIE', language : 'c')
+ endif
+endif
+
# "negative" arguments: gcc on purpose does not return an error for "-Wno-"
# arguments, just emits a warnings. So test for the "positive" version instead.
foreach arg : ['unused-parameter',
@@ -424,7 +436,7 @@ foreach arg : ['-Wl,-z,relro',
cc.cmd_array(), '-x', 'c', arg,
'-include', link_test_c).returncode() == 0
message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
- if have
+ if have and (arg != '-pie' or not ossfuzz)
add_project_link_arguments(arg, language : 'c')
endif
endforeach
@@ -1336,6 +1348,7 @@ endforeach
want_tests = get_option('tests')
install_tests = get_option('install-tests')
tests = []
+fuzzers = []
conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', get_option('slow-tests'))
@@ -1508,6 +1521,7 @@ subdir('src/shared')
#endif // 0
subdir('src/test')
+subdir('src/fuzz')
#if 0 /// UNNEEDED in elogind
# subdir('rules')
# subdir('test')
@@ -2744,6 +2758,39 @@ endforeach
# install_dir : testsdir)
# test('test-libudev-sym',
# test_libudev_sym)
+#
+# ############################################################
+#
+# fuzzer_exes = []
+#
+# foreach tuple : fuzzers
+# sources = tuple[0]
+# link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
+# dependencies = tuple[2]
+# defs = tuple.length() >= 4 ? tuple[3] : []
+# incs = tuple.length() >= 5 ? tuple[4] : includes
+#
+# if ossfuzz
+# dependencies += fuzzing_engine
+# else
+# sources += 'src/fuzz/fuzz-main.c'
+# endif
+#
+# name = sources[0].split('/')[-1].split('.')[0]
+#
+# fuzzer_exes += executable(
+# name,
+# sources,
+# include_directories : [incs, include_directories('src/fuzz')],
+# link_with : link_with,
+# dependencies : dependencies,
+# c_args : defs,
+# install : false)
+# endforeach
+#
+# run_target('fuzzers',
+# depends : fuzzer_exes,
+# command : ['true'])
#else
test_libelogind_sym = executable(
'test-libelogind-sym',