]> Cypherpunks repositories - gostls13.git/commit
[dev.fuzz] internal/fuzz: implement coverage and trace instrumentation
authorMatthew Dempsky <mdempsky@google.com>
Thu, 8 Apr 2021 00:11:48 +0000 (17:11 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 9 Apr 2021 17:19:43 +0000 (17:19 +0000)
commit74f49f3366826f95a464cc15838a0668c92e3357
tree03ac5d12f5973c9c38840a3d1319bb8cfbe1e720
parent2f3bc725fe80e1ba3ef726e412c212d533a43684
[dev.fuzz] internal/fuzz: implement coverage and trace instrumentation

This CL makes two main changes to allow internal/fuzz to support
-d=libfuzzer instrumentation:

1. It extends cmd/link to define _counters and _ecounters symbols so
internal/fuzz can find the coverage counters.

2. It adds "trace" stub functions that implement the ABI expected by
cmd/compile for comparison instrumentation.

N.B., that -tags=libfuzzer should *not* be set, so that
internal/fuzz's trace routines will be used instead of runtime's
libfuzzer trampolines.

Also, the current implementation doesn't support multi-module builds
(i.e., compiling a Go program that spans multiple .so/.dll files).
Presumably this isn't an issue, since "go test -fuzz" will need to
recompile the binary with instrumentation anyway so it can make sure
to always use a single-module build. But we can revisit this if
necessary.

Change-Id: I9b1619119ab7477bebcfd5988b4b60499a7ab0d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/308289
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
src/cmd/link/internal/ld/data.go
src/internal/fuzz/coverage.go
src/internal/fuzz/trace.go [new file with mode: 0644]