Commit 0ae93896 authored by Lynn Boger's avatar Lynn Boger

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 '<'.

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: default avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent adef06c7
...@@ -292,7 +292,7 @@ func (t *_type) textOff(off textOff) unsafe.Pointer { ...@@ -292,7 +292,7 @@ func (t *_type) textOff(off textOff) unsafe.Pointer {
for i := range md.textsectmap { for i := range md.textsectmap {
sectaddr := md.textsectmap[i].vaddr sectaddr := md.textsectmap[i].vaddr
sectlen := md.textsectmap[i].length 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) res = md.textsectmap[i].baseaddr + uintptr(off) - uintptr(md.textsectmap[i].vaddr)
break break
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment