1
0
mirror of https://github.com/golang/go synced 2024-11-26 05:07:59 -07:00

[dev.typeparams] runtime: use internal/abi.FuncPCABI0 to reference ABI0 assembly symbols

Use FuncPCABI0 to reference ABI0 assembly symbols. Currently,
they are referenced using funcPC, which will get the ABI wrapper's
address. They don't seem to affect correctness (either the wrapper
is harmless, or, on non-AMD64 architectures, not enabled). They
should have been converted.

This CL does not yet completely eliminate funcPC. But at this
point we should be able to replace all remaining uses of funcPC
to internal/abi.FuncPCABIInternal.

Change-Id: I383a686e11d570f757f185fe46769a42c856ab77
Reviewed-on: https://go-review.googlesource.com/c/go/+/321952
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Cherry Mui 2021-05-20 21:33:01 -04:00
parent 0e0a1f94f3
commit 7d928460a1
16 changed files with 46 additions and 22 deletions

View File

@ -61,4 +61,4 @@ func dumpregs(u *ureg) {
print("gs ", hex(u.gs), "\n")
}
func sigpanictramp() {}
func sigpanictramp()

View File

@ -78,4 +78,4 @@ func dumpregs(u *ureg) {
print("gs ", hex(u.gs), "\n")
}
func sigpanictramp() {}
func sigpanictramp()

View File

@ -99,7 +99,7 @@ func sighandler(_ureg *ureg, note *byte, gp *g) int {
}
}
if usesLR {
c.setpc(funcPC(sigpanictramp))
c.setpc(abi.FuncPCABI0(sigpanictramp))
} else {
c.setpc(abi.FuncPCABI0(sigpanic0))
}

View File

@ -148,14 +148,14 @@ func lwp_start(uintptr)
func newosproc(mp *m) {
stk := unsafe.Pointer(mp.g0.stack.hi)
if false {
print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " lwp_start=", funcPC(lwp_start), " id=", mp.id, " ostk=", &mp, "\n")
print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " lwp_start=", abi.FuncPCABI0(lwp_start), " id=", mp.id, " ostk=", &mp, "\n")
}
var oset sigset
sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
params := lwpparams{
start_func: funcPC(lwp_start),
start_func: abi.FuncPCABI0(lwp_start),
arg: unsafe.Pointer(mp),
stack: uintptr(stk),
tid1: nil, // minit will record tid

View File

@ -5,6 +5,7 @@
package runtime
import (
"internal/abi"
"runtime/internal/sys"
"unsafe"
)
@ -197,11 +198,11 @@ func thr_start()
func newosproc(mp *m) {
stk := unsafe.Pointer(mp.g0.stack.hi)
if false {
print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " thr_start=", funcPC(thr_start), " id=", mp.id, " ostk=", &mp, "\n")
print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " thr_start=", abi.FuncPCABI0(thr_start), " id=", mp.id, " ostk=", &mp, "\n")
}
param := thrparam{
start_func: funcPC(thr_start),
start_func: abi.FuncPCABI0(thr_start),
arg: unsafe.Pointer(mp),
stack_base: mp.g0.stack.lo,
stack_size: uintptr(stk) - mp.g0.stack.lo,

View File

@ -143,7 +143,7 @@ func newosproc(mp *m) {
* note: strace gets confused if we use CLONE_PTRACE here.
*/
if false {
print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " clone=", funcPC(clone), " id=", mp.id, " ostk=", &mp, "\n")
print("newosproc stk=", stk, " m=", mp, " g=", mp.g0, " clone=", abi.FuncPCABI0(clone), " id=", mp.id, " ostk=", &mp, "\n")
}
// Disable signals during clone, so that the new thread starts

View File

@ -5,6 +5,7 @@
package runtime
import (
"internal/abi"
"runtime/internal/atomic"
"runtime/internal/sys"
"unsafe"
@ -215,7 +216,7 @@ func newosproc(mp *m) {
var oset sigset
sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
lwp_mcontext_init(&uc.uc_mcontext, stk, mp, mp.g0, funcPC(netbsdMstart))
lwp_mcontext_init(&uc.uc_mcontext, stk, mp, mp.g0, abi.FuncPCABI0(netbsdMstart))
ret := lwp_create(unsafe.Pointer(&uc), _LWP_DETACHED, unsafe.Pointer(&mp.procid))
sigprocmask(_SIG_SETMASK, &oset, nil)
@ -319,7 +320,7 @@ func setsig(i uint32, fn uintptr) {
sa.sa_flags = _SA_SIGINFO | _SA_ONSTACK | _SA_RESTART
sa.sa_mask = sigset_all
if fn == funcPC(sighandler) {
fn = funcPC(sigtramp)
fn = abi.FuncPCABI0(sigtramp)
}
sa.sa_sigaction = fn
sigaction(i, &sa, nil)

View File

@ -4,11 +4,14 @@
package runtime
import "unsafe"
import (
"internal/abi"
"unsafe"
)
func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintptr) {
// Machine dependent mcontext initialisation for LWP.
mc.__gregs[_REG_EIP] = uint32(funcPC(lwp_tramp))
mc.__gregs[_REG_EIP] = uint32(abi.FuncPCABI0(lwp_tramp))
mc.__gregs[_REG_UESP] = uint32(uintptr(stk))
mc.__gregs[_REG_EBX] = uint32(uintptr(unsafe.Pointer(mp)))
mc.__gregs[_REG_EDX] = uint32(uintptr(unsafe.Pointer(gp)))

View File

@ -4,11 +4,14 @@
package runtime
import "unsafe"
import (
"internal/abi"
"unsafe"
)
func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintptr) {
// Machine dependent mcontext initialisation for LWP.
mc.__gregs[_REG_RIP] = uint64(funcPC(lwp_tramp))
mc.__gregs[_REG_RIP] = uint64(abi.FuncPCABI0(lwp_tramp))
mc.__gregs[_REG_RSP] = uint64(uintptr(stk))
mc.__gregs[_REG_R8] = uint64(uintptr(unsafe.Pointer(mp)))
mc.__gregs[_REG_R9] = uint64(uintptr(unsafe.Pointer(gp)))

View File

@ -4,11 +4,14 @@
package runtime
import "unsafe"
import (
"internal/abi"
"unsafe"
)
func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintptr) {
// Machine dependent mcontext initialisation for LWP.
mc.__gregs[_REG_R15] = uint32(funcPC(lwp_tramp))
mc.__gregs[_REG_R15] = uint32(abi.FuncPCABI0(lwp_tramp))
mc.__gregs[_REG_R13] = uint32(uintptr(stk))
mc.__gregs[_REG_R0] = uint32(uintptr(unsafe.Pointer(mp)))
mc.__gregs[_REG_R1] = uint32(uintptr(unsafe.Pointer(gp)))

View File

@ -4,11 +4,14 @@
package runtime
import "unsafe"
import (
"internal/abi"
"unsafe"
)
func lwp_mcontext_init(mc *mcontextt, stk unsafe.Pointer, mp *m, gp *g, fn uintptr) {
// Machine dependent mcontext initialisation for LWP.
mc.__gregs[_REG_ELR] = uint64(funcPC(lwp_tramp))
mc.__gregs[_REG_ELR] = uint64(abi.FuncPCABI0(lwp_tramp))
mc.__gregs[_REG_X31] = uint64(uintptr(stk))
mc.__gregs[_REG_X0] = uint64(uintptr(unsafe.Pointer(mp)))
mc.__gregs[_REG_X1] = uint64(uintptr(unsafe.Pointer(mp.g0)))

View File

@ -8,6 +8,7 @@
package runtime
import (
"internal/abi"
"runtime/internal/sys"
"unsafe"
)
@ -33,7 +34,7 @@ func newosproc(mp *m) {
var oset sigset
sigprocmask(_SIG_SETMASK, &sigset_all, &oset)
ret := tfork(&param, unsafe.Sizeof(param), mp, mp.g0, funcPC(mstart))
ret := tfork(&param, unsafe.Sizeof(param), mp, mp.g0, abi.FuncPCABI0(mstart))
sigprocmask(_SIG_SETMASK, &oset, nil)
if ret < 0 {

View File

@ -2236,7 +2236,7 @@ func newm1(mp *m) {
}
ts.g.set(mp.g0)
ts.tls = (*uint64)(unsafe.Pointer(&mp.tls[0]))
ts.fn = unsafe.Pointer(funcPC(mstart))
ts.fn = unsafe.Pointer(abi.FuncPCABI0(mstart))
if msanenabled {
msanwrite(unsafe.Pointer(&ts), unsafe.Sizeof(ts))
}

View File

@ -5,6 +5,7 @@
package runtime
import (
"internal/abi"
"runtime/internal/sys"
"unsafe"
)
@ -14,14 +15,14 @@ import (
//go:nosplit
//go:cgo_unsafe_args
func g0_pthread_key_create(k *pthreadkey, destructor uintptr) int32 {
return asmcgocall(unsafe.Pointer(funcPC(pthread_key_create_trampoline)), unsafe.Pointer(&k))
return asmcgocall(unsafe.Pointer(abi.FuncPCABI0(pthread_key_create_trampoline)), unsafe.Pointer(&k))
}
func pthread_key_create_trampoline()
//go:nosplit
//go:cgo_unsafe_args
func g0_pthread_setspecific(k pthreadkey, value uintptr) int32 {
return asmcgocall(unsafe.Pointer(funcPC(pthread_setspecific_trampoline)), unsafe.Pointer(&k))
return asmcgocall(unsafe.Pointer(abi.FuncPCABI0(pthread_setspecific_trampoline)), unsafe.Pointer(&k))
}
func pthread_setspecific_trampoline()

View File

@ -250,3 +250,7 @@ TEXT runtime·errstr(SB),NOSPLIT,$8-8
MOVL 0(SP), AX
MOVL AX, ret_base+0(FP)
RET
// never called on this platform
TEXT ·sigpanictramp(SB),NOSPLIT,$0-0
UNDEF

View File

@ -251,3 +251,7 @@ TEXT runtime·errstr(SB),NOSPLIT,$16-16
MOVQ 0(SP), AX
MOVQ AX, ret_base+0(FP)
RET
// never called on this platform
TEXT ·sigpanictramp(SB),NOSPLIT,$0-0
UNDEF