1
0
mirror of https://github.com/golang/go synced 2024-09-30 02:14:29 -06:00

runtime: use funcID to identify abort in isAbortPC

This change eliminates the use of funcPC to determine if an PC is in
abort. Using funcPC for this purpose is problematic when using plugins
because symbols no longer have unique PCs. funcPC also grabs the wrapper
for runtime.abort which isn't what we want for the new register ABI, so
rather than mark runtime.abort as ABIInternal, use funcID.

For #40724.

Change-Id: I2730e99fe6f326d22d64a10384828b94f04d101a
Reviewed-on: https://go-review.googlesource.com/c/go/+/307391
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
Michael Anthony Knyszek 2021-04-05 19:13:34 +00:00 committed by Michael Knyszek
parent b2389ad3ce
commit 298975c634
3 changed files with 20 additions and 1 deletions

View File

@ -24,6 +24,7 @@ type FuncID uint8
// Note: this list must match the list in runtime/symtab.go.
const (
FuncID_normal FuncID = iota // not a special function
FuncID_abort
FuncID_asmcgocall
FuncID_asyncPreempt
FuncID_cgocallback
@ -49,6 +50,7 @@ const (
)
var funcIDs = map[string]FuncID{
"abort": FuncID_abort,
"asmcgocall": FuncID_asmcgocall,
"asyncPreempt": FuncID_asyncPreempt,
"cgocallback": FuncID_cgocallback,

View File

@ -1484,5 +1484,9 @@ func shouldPushSigpanic(gp *g, pc, lr uintptr) bool {
//
//go:nosplit
func isAbortPC(pc uintptr) bool {
return pc == funcPC(abort) || ((GOARCH == "arm" || GOARCH == "arm64") && pc == funcPC(abort)+sys.PCQuantum)
f := findfunc(pc)
if !f.valid() {
return false
}
return f.funcID == funcID_abort
}

View File

@ -310,6 +310,7 @@ type funcID uint8
const (
funcID_normal funcID = iota // not a special function
funcID_abort
funcID_asmcgocall
funcID_asyncPreempt
funcID_cgocallback
@ -669,6 +670,12 @@ func (f *Func) FileLine(pc uintptr) (file string, line int) {
return file, int(line32)
}
// findmoduledatap looks up the moduledata for a PC.
//
// It is nosplit because it's part of the isgoexception
// implementation.
//
//go:nosplit
func findmoduledatap(pc uintptr) *moduledata {
for datap := &firstmoduledata; datap != nil; datap = datap.next {
if datap.minpc <= pc && pc < datap.maxpc {
@ -691,6 +698,12 @@ func (f funcInfo) _Func() *Func {
return (*Func)(unsafe.Pointer(f._func))
}
// findfunc looks up function metadata for a PC.
//
// It is nosplit because it's part of the isgoexception
// implementation.
//
//go:nosplit
func findfunc(pc uintptr) funcInfo {
datap := findmoduledatap(pc)
if datap == nil {