1#!/bin/bash -eu 2# Copyright 2019 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 18export ASAN_OPTIONS="detect_leaks=0" 19 20if [[ $CFLAGS = *sanitize=address* ]] 21then 22 export CXXFLAGS="$CXXFLAGS -DASAN" 23fi 24 25if [[ $CFLAGS = *sanitize=memory* ]] 26then 27 export CXXFLAGS="$CXXFLAGS -DMSAN" 28fi 29 30export CXXFLAGS="$CXXFLAGS -D_GLIBCXX_DEBUG" 31 32# Build libogg 33mkdir $SRC/libogg-install 34cd $SRC/ogg 35./autogen.sh 36./configure --prefix="$SRC/libogg-install" 37make -j$(nproc) 38make install 39 40# Build libflac 41cd $SRC/flac/ 42./autogen.sh 43if [[ $CFLAGS = *sanitize=memory* ]] 44then 45 LD_LIBRARY_PATH="$SRC/libogg-install/lib" ./configure --with-ogg="$SRC/libogg-install" --enable-static --disable-oggtest --disable-examples --disable-xmms-plugin --disable-asm-optimizations --disable-sse 46else 47 LD_LIBRARY_PATH="$SRC/libogg-install/lib" ./configure --with-ogg="$SRC/libogg-install" --enable-static --disable-oggtest --disable-examples --disable-xmms-plugin 48fi 49make -j$(nproc) 50 51cd $SRC/fuzzing-headers 52./install.sh 53 54# Build fuzzers 55cd $SRC/flac-fuzzers/ 56$CXX $CXXFLAGS -I $SRC/flac/include/ -I $SRC/ExoPlayer/extensions/flac/src/main/jni/ -I /usr/lib/jvm/java-11-openjdk-amd64/include/ -I /usr/lib/jvm/java-11-openjdk-amd64/include/linux/ fuzzer_exo.cpp \ 57 $SRC/flac/src/libFLAC++/.libs/libFLAC++.a $SRC/flac/src/libFLAC/.libs/libFLAC.a $SRC/libogg-install/lib/libogg.a $LIB_FUZZING_ENGINE -o $OUT/fuzzer_exo 58$CXX $CXXFLAGS -I $SRC/flac/include/ fuzzer_decoder.cpp $SRC/flac/src/libFLAC++/.libs/libFLAC++.a $SRC/flac/src/libFLAC/.libs/libFLAC.a $SRC/libogg-install/lib/libogg.a $LIB_FUZZING_ENGINE -o $OUT/fuzzer_decoder 59$CXX $CXXFLAGS -I $SRC/flac/include/ fuzzer_encoder.cpp $SRC/flac/src/libFLAC++/.libs/libFLAC++.a $SRC/flac/src/libFLAC/.libs/libFLAC.a $SRC/libogg-install/lib/libogg.a $LIB_FUZZING_ENGINE -o $OUT/fuzzer_encoder 60cp fuzzer_encoder.dict $OUT/ 61