oss-fuzz.sh 2.3 KB

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