diff options
Diffstat (limited to 'src/runtime/type.go')
| -rw-r--r-- | src/runtime/type.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/runtime/type.go b/src/runtime/type.go index 0467c77400..7f7849d5a0 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -257,7 +257,30 @@ func (t *_type) textOff(off textOff) unsafe.Pointer { } return res } - res := md.text + uintptr(off) + res := uintptr(0) + + // The text, or instruction stream is generated as one large buffer. The off (offset) for a method is + // its offset within this buffer. If the total text size gets too large, there can be issues on platforms like ppc64 if + // the target of calls are too far for the call instruction. To resolve the large text issue, the text is split + // into multiple text sections to allow the linker to generate long calls when necessary. When this happens, the vaddr + // for each text section is set to its offset within the text. Each method's offset is compared against the section + // vaddrs and sizes to determine the containing section. Then the section relative offset is added to the section's + // relocated baseaddr to compute the method addess. + + if len(md.textsectmap) > 1 { + for i := range md.textsectmap { + sectaddr := md.textsectmap[i].vaddr + sectlen := md.textsectmap[i].length + if uintptr(off) >= sectaddr && uintptr(off) <= sectaddr+sectlen { + res = md.textsectmap[i].baseaddr + uintptr(off) - uintptr(md.textsectmap[i].vaddr) + break + } + } + } else { + // single text section + res = md.text + uintptr(off) + } + if res > md.etext { println("runtime: textOff", hex(off), "out of range", hex(md.text), "-", hex(md.etext)) throw("runtime: text offset out of range") |
