]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: set coverage counters as expected by the fuzz package
authorKhaled Yakdan <yakdan@code-intelligence.com>
Sat, 21 May 2022 10:47:25 +0000 (10:47 +0000)
committerKeith Randall <khr@golang.org>
Mon, 23 May 2022 14:38:06 +0000 (14:38 +0000)
Set _counters and _ecounters to the start and end locations of
libfuzzer's 8-bit counters section

Change-Id: Icadb503af1ba22495b1d88b69aad26d89843baa4
GitHub-Last-Rev: 4ca6216b7600a3187732ae6d0dc7a5ce60cd5655
GitHub-Pull-Request: golang/go#53022
Reviewed-on: https://go-review.googlesource.com/c/go/+/407674
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/link/internal/ld/data.go

index 503a9cd20c8177ec3ecc8d9e3c1a11be52b384a3..f12cb78fb8ecaa9a3d199df09dc8bb32b94a8231 100644 (file)
@@ -1786,6 +1786,8 @@ func (state *dodataState) allocateDataSections(ctxt *Link) {
                sect := state.allocateNamedSectionAndAssignSyms(&Segdata, "__sancov_cntrs", sym.SLIBFUZZER_8BIT_COUNTER, sym.Sxxx, 06)
                ldr.SetSymSect(ldr.LookupOrCreateSym("__start___sancov_cntrs", 0), sect)
                ldr.SetSymSect(ldr.LookupOrCreateSym("__stop___sancov_cntrs", 0), sect)
+               ldr.SetSymSect(ldr.LookupOrCreateSym("internal/fuzz._counters", 0), sect)
+               ldr.SetSymSect(ldr.LookupOrCreateSym("internal/fuzz._ecounters", 0), sect)
        }
 
        if len(state.data[sym.STLSBSS]) > 0 {
@@ -2679,6 +2681,8 @@ func (ctxt *Link) address() []*sym.Segment {
        if fuzzCounters != nil {
                ctxt.xdefine("__start___sancov_cntrs", sym.SLIBFUZZER_8BIT_COUNTER, int64(fuzzCounters.Vaddr))
                ctxt.xdefine("__stop___sancov_cntrs", sym.SLIBFUZZER_8BIT_COUNTER, int64(fuzzCounters.Vaddr+fuzzCounters.Length))
+               ctxt.xdefine("internal/fuzz._counters", sym.SLIBFUZZER_8BIT_COUNTER, int64(fuzzCounters.Vaddr))
+               ctxt.xdefine("internal/fuzz._ecounters", sym.SLIBFUZZER_8BIT_COUNTER, int64(fuzzCounters.Vaddr+fuzzCounters.Length))
        }
 
        if ctxt.IsSolaris() {