]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] runtime: use internal/abi.FuncPCABI0 to reference ABI0 assembly...
authorCherry Mui <cherryyz@google.com>
Fri, 21 May 2021 01:33:01 +0000 (21:33 -0400)
committerCherry Mui <cherryyz@google.com>
Fri, 21 May 2021 22:12:04 +0000 (22:12 +0000)
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>
16 files changed:
src/runtime/defs_plan9_386.go
src/runtime/defs_plan9_amd64.go
src/runtime/os3_plan9.go
src/runtime/os_dragonfly.go
src/runtime/os_freebsd.go
src/runtime/os_linux.go
src/runtime/os_netbsd.go
src/runtime/os_netbsd_386.go
src/runtime/os_netbsd_amd64.go
src/runtime/os_netbsd_arm.go
src/runtime/os_netbsd_arm64.go
src/runtime/os_openbsd_syscall.go
src/runtime/proc.go
src/runtime/sys_darwin_arm64.go
src/runtime/sys_plan9_386.s
src/runtime/sys_plan9_amd64.s

index 49129b3c3fcb1c675f26c89426b27ebb8a0d0624..428044df6871d71823a5f18edd745e1fb749eda9 100644 (file)
@@ -61,4 +61,4 @@ func dumpregs(u *ureg) {
        print("gs    ", hex(u.gs), "\n")
 }
 
-func sigpanictramp() {}
+func sigpanictramp()
index 00995630341a81c09cd28eaab16a31942532fd48..15a27fc7db9e5110991e4dcf282ed590b2171d9a 100644 (file)
@@ -78,4 +78,4 @@ func dumpregs(u *ureg) {
        print("gs    ", hex(u.gs), "\n")
 }
 
-func sigpanictramp() {}
+func sigpanictramp()
index dacb5c23a0c01f4e7f4533dea21826e07fdd42d2..ce8bc7f1034d8ba568ea194d7a9d4d7a3ee4f501 100644 (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))
                }
index ab0ad4728fe0964490090431635aa27f2c9709de..45aeaecd891a11e00505832cff16b95ae39c4e1e 100644 (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
index 09dd50ce59477583ff418da334e3769f191890a4..41feaecf6b659357183cd47caa0affcfc60deafb 100644 (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,
index 235c96e45a7d3e243a6a18e9a6293b1c89fd5120..9203f28351bfe80feed1522744e96cd54eea4f40 100644 (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
index 6fbb3aa6947bad99357103f6adb00364ed5b9a02..0920d5293e5effe2bc6db35530f56506f8917aac 100644 (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)
index 037f7e36dc6ae730321f68e2b9f2c777cd49a06b..ac89b9852c7f64a268615180b3d885f56b88d488 100644 (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)))
index 5118b0c4ffda78c82406ef194c5575f7d445cbbe..74eea0ceabc4d9562af9f3e6ae120e08418ac34f 100644 (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)))
index b5ec23e45b0a8833154279d37920e42ad6673802..5fb4e08d66a9158755227d0d9f53cc13132e9a0e 100644 (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)))
index 8d21b0a430f9abeecc833cf6dcb4f1e459f698b0..2dda9c9274d73bdcd44b145bf67d9379995932b1 100644 (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)))
index 3cdcb6c707bfe2dfb08986e19ade174ca717d742..a04eb4fc4dd7023d5191a6fdafd5fd91fc2d770a 100644 (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 {
index ded406cc28dcc8c91098e248e7e45f18baac4fec..694f456ac5e2fdca893ca2625fd4364b7d0ce7ab 100644 (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))
                }
index 9c14f33a1ce2389778dd17c144c59dcd20b95fa3..7dabaca08d2503c5a65544794f1cbaece6500aef 100644 (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()
 
index b3d2f1376d624c8b97e9e37ab95e53ee74fcf84e..bdcb98e19e0bbf083dd1a8511e3507f4fa0bad69 100644 (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
index 731306ab448463217fd5a8dd1a5ab273d081e386..39fc4c68e4ce969632c34ec14a650ec3b97ca9d7 100644 (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