From 6096b85b1326c22ec07c2aed2d78f3bef513ea69 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 31 Oct 2018 20:39:59 -0400 Subject: [PATCH] runtime: avoid variable/function alias on runtime._cgo_panic_internal 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/runtime/cgo/callbacks.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/runtime/cgo/callbacks.go b/src/runtime/cgo/callbacks.go index 8590aa3659..14a218ec92 100644 --- a/src/runtime/cgo/callbacks.go +++ b/src/runtime/cgo/callbacks.go @@ -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 -- 2.50.0