diff options
author | Cherry Zhang <cherryyz@google.com> | 2020-02-16 16:18:04 -0500 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-02-18 17:55:23 +0000 |
commit | a9ea91d571b75d27a49e07f3604b8faa7a48525d (patch) | |
tree | 2cecbedadf03184ce0430c131081a7dd1b558aaa /src/runtime/symtab.go | |
parent | 88e564edb13f1596c12ad16d5fd3c7ac7deac855 (diff) | |
download | go-a9ea91d571b75d27a49e07f3604b8faa7a48525d.tar.gz go-a9ea91d571b75d27a49e07f3604b8faa7a48525d.zip |
cmd/link, runtime: skip holes in func table
On PPC64 when external linking, for large binaries we split the
text section to multiple sections, so the external linking may
insert trampolines between sections. These trampolines are within
the address range covered by the func table, but not known by Go.
This causes runtime.findfunc to return a wrong function if the
given PC is from such trampolines.
In this CL, we generate a marker between text sections where
there could potentially be a hole in the func table. At run time,
we skip the hole if we see such a marker.
Fixes #37216.
Change-Id: I95ab3875a84b357dbaa65a4ed339a19282257ce0
Reviewed-on: https://go-review.googlesource.com/c/go/+/219717
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/runtime/symtab.go')
-rw-r--r-- | src/runtime/symtab.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index ddcf231929..a6e08d7214 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -614,7 +614,15 @@ func findfunc(pc uintptr) funcInfo { idx++ } } - return funcInfo{(*_func)(unsafe.Pointer(&datap.pclntable[datap.ftab[idx].funcoff])), datap} + funcoff := datap.ftab[idx].funcoff + if funcoff == ^uintptr(0) { + // With multiple text sections, there may be functions inserted by the external + // linker that are not known by Go. This means there may be holes in the PC + // range covered by the func table. The invalid funcoff value indicates a hole. + // See also cmd/link/internal/ld/pcln.go:pclntab + return funcInfo{} + } + return funcInfo{(*_func)(unsafe.Pointer(&datap.pclntable[funcoff])), datap} } type pcvalueCache struct { |