From: Lynn Boger Date: Mon, 28 Oct 2019 13:29:40 +0000 (-0400) Subject: [release-branch.go1.13] runtime: fix textOff for multiple text sections X-Git-Tag: go1.13.5~5 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6eee9903c7f970defbc0c9770397790b2bed5709;p=gostls13.git [release-branch.go1.13] runtime: fix textOff for multiple text sections If a compilation has multiple text sections, code in textOff must compare the offset argument against the range for each text section to determine which one it is in. The comparison looks like this: if uintptr(off) >= sectaddr && uintptr(off) <= sectaddr+sectlen If the off value being compared is equal to sectaddr+sectlen then it is not within the range of the text section but after it. The comparison should be just '<'. Fixes #35211 Change-Id: I114633fd734563d38f4e842dd884c6c239f73c95 Reviewed-on: https://go-review.googlesource.com/c/go/+/203817 Run-TryBot: Lynn Boger TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Zhang (cherry picked from commit 0ae9389609f23dc905c58fc2ad7bcc16b770f337) Reviewed-on: https://go-review.googlesource.com/c/go/+/203819 Run-TryBot: Carlos Amedee Reviewed-by: Keith Randall --- diff --git a/src/runtime/type.go b/src/runtime/type.go index 660b45ef39..5ae3c4b09e 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -287,7 +287,7 @@ func (t *_type) textOff(off textOff) unsafe.Pointer { for i := range md.textsectmap { sectaddr := md.textsectmap[i].vaddr sectlen := md.textsectmap[i].length - if uintptr(off) >= sectaddr && uintptr(off) <= sectaddr+sectlen { + if uintptr(off) >= sectaddr && uintptr(off) < sectaddr+sectlen { res = md.textsectmap[i].baseaddr + uintptr(off) - uintptr(md.textsectmap[i].vaddr) break }