diff options
author | Abhishek Arya <inferno@chromium.org> | 2020-04-13 21:57:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 21:57:30 -0700 |
commit | 892cec4e75feb7e4fb8d4f23302417a5ea508c54 (patch) | |
tree | 2b5b0e37f8e53932df1320250b6860d0a6fa0618 /docs | |
parent | 21c3ee3f1aba92774361550df55970bb12d3d643 (diff) | |
download | oss-fuzz-892cec4e75feb7e4fb8d4f23302417a5ea508c54.tar.gz |
Switch OSS projects to use native go-fuzz. (#3638)
* Switch OSS projects to use native go-fuzz.
* Fix go-json-iterator breakage, put source in package search dir.
* Revert syzkaller change, track bug in #3639
Diffstat (limited to 'docs')
-rw-r--r-- | docs/getting-started/new-project-guide/go_lang.md | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/docs/getting-started/new-project-guide/go_lang.md b/docs/getting-started/new-project-guide/go_lang.md index 939bae739..f58716dfc 100644 --- a/docs/getting-started/new-project-guide/go_lang.md +++ b/docs/getting-started/new-project-guide/go_lang.md @@ -22,13 +22,18 @@ process. The key specifics of integrating a Go project are outlined below. ## Go-fuzz support OSS-Fuzz supports **go-fuzz** in the -[libFuzzer compatible mode](https://github.com/dvyukov/go-fuzz#libfuzzer-support) +[libFuzzer compatible mode](https://github.com/mdempsky/go114-fuzz-build) only. In that mode, fuzz targets for Go use the libFuzzer engine with native Go coverage instrumentation. Binaries compiled in this mode provide the same libFuzzer command line interface as non-Go fuzz targets. ## Project files +First, you need to write a Go fuzz target that accepts a stream of bytes and +calls the program API with that. This fuzz target should reside in your project +repository +([example](https://github.com/golang/go/blob/4ad13555184eb0697c2e92c64c1b0bdb287ccc10/src/html/fuzz.go#L13)). + The structure of the project directory in OSS-Fuzz repository doesn't differ for projects written in Go. The project files have the following Go specific aspects. @@ -66,7 +71,7 @@ RUN go get github.com/ianlancetaylor/demangle ### build.sh -In order to build a Go fuzz target, you need to call `go-fuzz-build -libfuzzer` +In order to build a Go fuzz target, you need to call `go-fuzz` command first, and then link the resulting `.a` file against `$LIB_FUZZING_ENGINE` using the `$CXX $CXXFLAGS ...` command. [Example](https://github.com/google/oss-fuzz/blob/356f2b947670b7eb33a1f535c71bc5c87a60b0d1/projects/syzkaller/build.sh#L19): @@ -78,7 +83,7 @@ function compile_fuzzer { fuzzer=$3 # Instrument all Go files relevant to this fuzzer - go-fuzz-build -libfuzzer -func $function -o $fuzzer.a $path + go-fuzz -func $function -o $fuzzer.a $path # Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer |