]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix textOff for multiple text sections
authorLynn Boger <laboger@linux.vnet.ibm.com>
Mon, 28 Oct 2019 13:29:40 +0000 (09:29 -0400)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Mon, 28 Oct 2019 15:06:13 +0000 (15:06 +0000)
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 '<'.

Updates #35207

Change-Id: I114633fd734563d38f4e842dd884c6c239f73c95
Reviewed-on: https://go-review.googlesource.com/c/go/+/203817
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/type.go

index af1fa2e1ca961b71f2bb7cfe94eda96f5b632e59..52b6cb30b445ff71de814c1d010aec1ea6e89df5 100644 (file)
@@ -292,7 +292,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
                        }