|
| 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 | + |
| 18 | +# Instrument mruby |
| 19 | +( |
| 20 | +cd $SRC/mruby |
| 21 | +export LD=$CC |
| 22 | +export LDFLAGS="$CFLAGS -fPIE" |
| 23 | + |
| 24 | +# No you cannot overwrite CC/CXX, otherwise afl++, libafl, etc. wont work! |
| 25 | +#LD=/usr/local/bin/clang CC=/usr/local/bin/clang CXX=/usr/local/bin/clang++ rake -m || true |
| 26 | +rake -m || true |
| 27 | + |
| 28 | +test -f $SRC/mruby/build/host/lib/libmruby.a |
| 29 | + |
| 30 | +# build fuzzers |
| 31 | +FUZZ_TARGET=$SRC/mruby_fuzzer.c |
| 32 | +name=$(basename $FUZZ_TARGET .c) |
| 33 | +$CC -c $CFLAGS -Iinclude \ |
| 34 | + ${FUZZ_TARGET} -o $OUT/${name}.o |
| 35 | +$CXX $CXXFLAGS $OUT/${name}.o $LIB_FUZZING_ENGINE -lm \ |
| 36 | + $SRC/mruby/build/host/lib/libmruby.a -o $OUT/${name} |
| 37 | +rm -f $OUT/${name}.o |
| 38 | +) |
| 39 | + |
| 40 | +# dict |
| 41 | +cp $SRC/mruby.dict $OUT/mruby_fuzzer.dict |
| 42 | + |
| 43 | +# seeds |
| 44 | +zip -rq $OUT/mruby_fuzzer_seed_corpus $SRC/mruby_seeds |
0 commit comments