]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: avoid variable/function alias on runtime._cgo_panic_internal
authorAustin Clements <austin@google.com>
Thu, 1 Nov 2018 00:39:59 +0000 (20:39 -0400)
committerAustin Clements <austin@google.com>
Mon, 12 Nov 2018 20:27:17 +0000 (20:27 +0000)
The symbol runtime._cgo_panic_internal is defined both as a function
in package runtime and as a (linknamed) variable in package
runtime/cgo. Since we're introducing function ABIs, this is going to
cause problems with resolving the ABI-marked function symbol with the
unmarked data symbol. It's also confusing.

Fix this by declaring runtime._cgo_panic_internal as a function in
runtime/cgo as well and extracting the PC from the function object.

For #27539.

Change-Id: I148a458a600cf9e57791cf4cbe92e79bddbf58d4
Reviewed-on: https://go-review.googlesource.com/c/146821
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/cgo/callbacks.go

index 8590aa3659a56298504fdf6f7785ab901ae4bfe2..14a218ec92cdcf93f40c6ecdcae49234bef19b96 100644 (file)
@@ -35,7 +35,7 @@ func _runtime_cgocallback(unsafe.Pointer, unsafe.Pointer, uintptr, uintptr)
 //   /* The function call will not return.  */
 
 //go:linkname _runtime_cgo_panic_internal runtime._cgo_panic_internal
-var _runtime_cgo_panic_internal byte
+func _runtime_cgo_panic_internal(p *byte)
 
 //go:linkname _cgo_panic _cgo_panic
 //go:cgo_export_static _cgo_panic
@@ -43,7 +43,12 @@ var _runtime_cgo_panic_internal byte
 //go:nosplit
 //go:norace
 func _cgo_panic(a unsafe.Pointer, n int32) {
-       _runtime_cgocallback(unsafe.Pointer(&_runtime_cgo_panic_internal), a, uintptr(n), 0)
+       f := _runtime_cgo_panic_internal
+       type funcval struct {
+               pc unsafe.Pointer
+       }
+       fv := *(**funcval)(unsafe.Pointer(&f))
+       _runtime_cgocallback(fv.pc, a, uintptr(n), 0)
 }
 
 //go:cgo_import_static x_cgo_init