diff options
Diffstat (limited to 'src/runtime/type.go')
-rw-r--r-- | src/runtime/type.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/runtime/type.go b/src/runtime/type.go index 52b6cb30b4..81455f3532 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -217,7 +217,9 @@ func (t *_type) nameOff(off nameOff) name { } func resolveTypeOff(ptrInModule unsafe.Pointer, off typeOff) *_type { - if off == 0 { + if off == 0 || off == -1 { + // -1 is the sentinel value for unreachable code. + // See cmd/link/internal/ld/data.go:relocsym. return nil } base := uintptr(ptrInModule) @@ -257,6 +259,11 @@ func (t *_type) typeOff(off typeOff) *_type { } func (t *_type) textOff(off textOff) unsafe.Pointer { + if off == -1 { + // -1 is the sentinel value for unreachable code. + // See cmd/link/internal/ld/data.go:relocsym. + return unsafe.Pointer(^uintptr(0)) + } base := uintptr(unsafe.Pointer(t)) var md *moduledata for next := &firstmoduledata; next != nil; next = next.next { |