def build(): """Build benchmark.""" afl_fuzzer.prepare_build_environment() utils.build_benchmark() print('[post_build] Copying Ankou to $OUT directory') shutil.copy('/Ankou', os.environ['OUT'])
def build(): """Build fuzzer.""" afl_fuzzer.prepare_build_environment() # Override AFL's FUZZER_LIB with QSYM's. os.environ['FUZZER_LIB'] = '/libQSYM.a' src = os.getenv('SRC') work = os.getenv('WORK') with utils.restore_directory(src), utils.restore_directory(work): # Restore SRC to its initial state so we can build again without any # trouble. For some OSS-Fuzz projects, build_benchmark cannot be run # twice in the same directory without this. utils.build_benchmark() # QSYM requires an uninstrumented build as well. new_env = os.environ.copy() utils.set_no_sanitizer_compilation_flags(new_env) cflags = ['-O2', '-fno-omit-frame-pointer', '-gline-tables-only'] utils.append_flags('CFLAGS', cflags, new_env) utils.append_flags('CXXFLAGS', cflags, new_env) # For uninstrumented build, set the OUT and FUZZ_TARGET environment # variable to point to the new uninstrumented build directory. build_directory = os.environ['OUT'] uninstrumented_build_directory = get_uninstrumented_build_directory( build_directory) os.mkdir(uninstrumented_build_directory) new_env['OUT'] = uninstrumented_build_directory fuzz_target = os.getenv('FUZZ_TARGET') if fuzz_target: new_env['FUZZ_TARGET'] = os.path.join(uninstrumented_build_directory, os.path.basename(fuzz_target)) print('Re-building benchmark for uninstrumented fuzzing target') utils.build_benchmark(env=new_env) print('[post_build] Copying afl-fuzz to $OUT directory') # Copy out the afl-fuzz binary as a build artifact. shutil.copy('/afl/afl-fuzz', build_directory) # QSYM also requires afl-showmap. print('[post_build] Copying afl-showmap to $OUT directory') shutil.copy('/afl/afl-showmap', build_directory)
def build(): """Build benchmark.""" # Backup the environment. new_env = os.environ.copy() # First, build an instrumented binary for AFL. afl_fuzzer.prepare_build_environment() src = os.getenv('SRC') work = os.getenv('WORK') with utils.restore_directory(src), utils.restore_directory(work): # Restore SRC to its initial state so we can build again without any # trouble. For some OSS-Fuzz projects, build_benchmark cannot be run # twice in the same directory without this. utils.build_benchmark() print('[build] Copying afl-fuzz to $OUT directory') shutil.copy('/afl/afl-fuzz', os.environ['OUT']) # Next, build an uninstrumented binary for Eclipser. new_env['CC'] = 'clang' new_env['CXX'] = 'clang++' new_env['FUZZER_LIB'] = '/libStandaloneFuzzTarget.a' # Ensure to compile with NO_SANITIZER_COMPAT* flags even for bug benchmarks, # as QEMU is incompatible with sanitizers. Also, Eclipser prefers clean and # unoptimized binaries. We leave fast random fuzzing as AFL's job. new_env['CFLAGS'] = ' '.join(utils.NO_SANITIZER_COMPAT_CFLAGS) cxxflags = [utils.LIBCPLUSPLUS_FLAG] + utils.NO_SANITIZER_COMPAT_CFLAGS new_env['CXXFLAGS'] = ' '.join(cxxflags) uninstrumented_outdir = get_uninstrumented_outdir(os.environ['OUT']) os.mkdir(uninstrumented_outdir) new_env['OUT'] = uninstrumented_outdir fuzz_target = os.getenv('FUZZ_TARGET') if fuzz_target: targ_name = os.path.basename(fuzz_target) new_env['FUZZ_TARGET'] = os.path.join(uninstrumented_outdir, targ_name) print('[build] Re-building benchmark for uninstrumented fuzzing target') utils.build_benchmark(env=new_env)
def build(): """Build benchmark and copy fuzzer to $OUT.""" afl_fuzzer.prepare_build_environment() utils.build_benchmark() # Move manul base to /out. shutil.move('/manul', os.environ['OUT'])