-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change adds a -libfuzzer flag to go-fuzz-build. When provided, go-fuzz-build generates an archive file that can be used with libFuzzer [1]. Sample usage: $ cd $GOPATH/src/github.com/dvyukov/go-fuzz-corpus/fmt $ go-fuzz-build -libfuzzer # produces fmt.a $ clang -fsanitize=fuzzer fmt.a -o fmt.libfuzzer $ ./fmt.libfuzzer It also adds a new build tag, gofuzz_libfuzzer, that will be provided when building code for use with libFuzzer. [1] https://llvm.org/docs/LibFuzzer.html
- Loading branch information
Showing
3 changed files
with
136 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2015 go-fuzz project authors. All rights reserved. | ||
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. | ||
|
||
// +build gofuzz | ||
// +build gofuzz_libfuzzer | ||
|
||
package gofuzzdep | ||
|
||
import ( | ||
"unsafe" | ||
|
||
. "github.com/dvyukov/go-fuzz/go-fuzz-defs" | ||
) | ||
|
||
// Bool is just a bool. | ||
// It is used by code autogenerated by go-fuzz-build | ||
// to avoid compilation errors when a user's code shadows the built-in bool. | ||
type Bool = bool | ||
|
||
var ( | ||
CoverTab *[CoverSize]byte | ||
sonarRegion []byte | ||
sonarPos uint32 | ||
CoverTabTmp [CoverSize]byte | ||
) | ||
|
||
func init() { | ||
CoverTab = (*[CoverSize]byte)(unsafe.Pointer(&CoverTabTmp[0])) | ||
} | ||
|
||
func Initialize(coverTabPtr unsafe.Pointer, coverTabSize uint64) { | ||
if coverTabSize != CoverSize { | ||
panic("Incorrect cover tab size") | ||
} | ||
CoverTab = (*[CoverSize]byte)(coverTabPtr) | ||
} | ||
|
||
func Main(f func([]byte) int) { | ||
} |