1#!/bin/bash -eu 2# Copyright 2018 Google Inc. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17 18SRC_DIR=$SRC/pffft 19cd $WORK 20 21# Deploy the seed corpus. 22SEED_CORPUS_ZIP_PATH=$OUT/pffft_fuzzers_seed_corpus.zip 23if [ -d seed_corpus_tmp ]; then 24 rm -fr seed_corpus_tmp 25fi 26mkdir seed_corpus_tmp 27python $SRC_DIR/generate_seed_corpus.py seed_corpus_tmp 28cd seed_corpus_tmp 29zip -q $SEED_CORPUS_ZIP_PATH ./* 30cd .. 31rm -fr seed_corpus_tmp 32 33build_fuzzer() { 34 # Aliases for the arguments. 35 fft_transform=$1 36 37 # Fuzzer name. 38 fuzz_target_name=pffft_${fft_transform,,}_fuzzer 39 40 # Add a symbolic link for the seed corpus (same corpus for all the 41 # generated fuzzers). 42 ls -la $OUT/*.zip 43 FUZZER_SEED_CORPUS_PATH=$OUT/${fuzz_target_name}_seed_corpus.zip 44 if [ -e $FUZZER_SEED_CORPUS_PATH ]; then 45 rm $FUZZER_SEED_CORPUS_PATH 46 fi 47 ln -s $SEED_CORPUS_ZIP_PATH $FUZZER_SEED_CORPUS_PATH 48 49 # Compile fuzzer. 50 $CXX $CXXFLAGS -std=c++11 -msse2 \ 51 -DTRANSFORM_${fft_transform} \ 52 $SRC/pffft/pffft.c $SRC/pffft/pffft_fuzzer.cc \ 53 -o $OUT/${fuzz_target_name} \ 54 $LIB_FUZZING_ENGINE 55} 56 57# Build fuzzers. 58build_fuzzer REAL 59build_fuzzer COMPLEX 60