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>
// 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
)
var funcIDs = map[string]FuncID{
+ "abort": FuncID_abort,
"asmcgocall": FuncID_asmcgocall,
"asyncPreempt": FuncID_asyncPreempt,
"cgocallback": FuncID_cgocallback,
//
//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
}
const (
funcID_normal funcID = iota // not a special function
+ funcID_abort
funcID_asmcgocall
funcID_asyncPreempt
funcID_cgocallback
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 {
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 {