|
| 1 | +#/bin/bash -eu |
| 2 | +# Copyright 2020 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 | +# This file is for integration with Google OSS-Fuzz. |
| 19 | +# The following ENV variables are available when executing on OSS-fuzz: |
| 20 | +# |
| 21 | +# /out/ $OUT Directory to store build artifacts (fuzz targets, dictionaries, options files, seed corpus archives). |
| 22 | +# /src/ $SRC Directory to checkout source files. |
| 23 | +# /work/ $WORK Directory to store intermediate files. |
| 24 | +# |
| 25 | +# $CC, $CXX, $CCC The C and C++ compiler binaries. |
| 26 | +# $CFLAGS, $CXXFLAGS C and C++ compiler flags. |
| 27 | +# $LIB_FUZZING_ENGINE C++ compiler argument to link fuzz target against the prebuilt engine library (e.g. libFuzzer). |
| 28 | + |
| 29 | +function compile_fuzzer { |
| 30 | + path=$SRC/go-ethereum/$1 |
| 31 | + func=$2 |
| 32 | + fuzzer=$3 |
| 33 | + echo "Building $fuzzer" |
| 34 | + (cd $path && \ |
| 35 | + go-fuzz -func $func -o $WORK/$fuzzer.a . && \ |
| 36 | + echo "First stage built OK" && \ |
| 37 | + $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $WORK/$fuzzer.a -o $OUT/$fuzzer && \ |
| 38 | + echo "Second stage built ok" ) |
| 39 | + |
| 40 | +} |
| 41 | + |
| 42 | +compile_fuzzer common/bitutil Fuzz fuzzBitutilCompress |
| 43 | +compile_fuzzer crypto/bn256 FuzzAdd fuzzBn256Add |
| 44 | +compile_fuzzer crypto/bn256 FuzzMul fuzzBn256Mul |
| 45 | +compile_fuzzer crypto/bn256 FuzzPair fuzzBn256Pair |
| 46 | +compile_fuzzer core/vm/runtime Fuzz fuzzVmRuntime |
| 47 | +compile_fuzzer crypto/blake2b Fuzz fuzzBlake2b |
| 48 | +compile_fuzzer tests/fuzzers/keystore Fuzz fuzzKeystore |
| 49 | +compile_fuzzer tests/fuzzers/txfetcher Fuzz fuzzTxfetcher |
| 50 | +compile_fuzzer tests/fuzzers/rlp Fuzz fuzzRlp |
| 51 | +compile_fuzzer tests/fuzzers/trie Fuzz fuzzTrie |
| 52 | +compile_fuzzer tests/fuzzers/stacktrie Fuzz fuzzStackTrie |
| 53 | + |
| 54 | +# This doesn't work very well @TODO |
| 55 | +#compile_fuzzertests/fuzzers/abi Fuzz fuzzAbi |
| 56 | + |
0 commit comments