aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/cgo/callbacks.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2018-10-31 20:39:59 -0400
committerAustin Clements <austin@google.com>2018-11-12 20:27:17 +0000
commit6096b85b1326c22ec07c2aed2d78f3bef513ea69 (patch)
treec2e2db23b11695cbfa7ceaad63b6f279fafa2992 /src/runtime/cgo/callbacks.go
parentef7ce57ac2da02aeceada27761c282e0718c6e14 (diff)
downloadgo-6096b85b1326c22ec07c2aed2d78f3bef513ea69.tar.xz
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 <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/cgo/callbacks.go')
-rw-r--r--src/runtime/cgo/callbacks.go9
1 files 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