1
0
mirror of https://github.com/golang/go synced 2024-09-29 08:24:36 -06:00

cmd/link: set coverage counters as expected by the fuzz package

Set _counters and _ecounters to the start and end locations of
libfuzzer's 8-bit counters section
This commit is contained in:
Khaled Yakdan 2022-05-21 12:24:13 +02:00
parent 0a1a092c4b
commit 4ca6216b76

View 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() {