]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: use funcID to identify abort in isAbortPC
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 5 Apr 2021 19:13:34 +0000 (19:13 +0000)
committerMichael Knyszek <mknyszek@google.com>
Tue, 6 Apr 2021 03:31:26 +0000 (03:31 +0000)
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>
src/cmd/internal/objabi/funcid.go
src/runtime/panic.go
src/runtime/symtab.go

index fa28609e4d1cef50376f76f733c81b70e4962d3c..4229ae2c026663b9d62bc15fe1395d32b964134a 100644 (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,
index bbf3ea473a473a645d4fecbcf6f62fa926915160..d33441a0d81334fdac6ae352b6291449149bc811 100644 (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
 }
index 8430ca87ecca61736167530012f1291218627549..3d1f6126a602d56ee2baf3e78cc1f0183697e1c4 100644 (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 {