]> Cypherpunks repositories - gostls13.git/commit
runtime: fix uses of ABIInternal PCs in assembly
authorAustin Clements <austin@google.com>
Mon, 29 Mar 2021 21:38:20 +0000 (17:38 -0400)
committerAustin Clements <austin@google.com>
Thu, 1 Apr 2021 00:51:26 +0000 (00:51 +0000)
commitec721d92bf35cd47543acf6792acd474fdd39446
tree9a8c2a9df49cdfb2b9b6e0364c086ebfdfa0e962
parent1f29e69bad3673aa4f9d1c4d1016170b9ced634a
runtime: fix uses of ABIInternal PCs in assembly

The covers three kinds of uses:

1. Calls of closures from assembly. These are always ABIInternal calls
without wrappers. I went through every indirect call in the runtime
and I think mcall is the only case of assembly calling a Go closure in
a way that's affected by ABIInternal. systemstack also calls a
closure, but it takes no arguments.

2. Calls of Go functions that expect raw ABIInternal pointers. I also
only found one of these: callbackasm1 -> cgocallback on Windows. These
are trickier to find, though.

3. Finally, I found one case on NetBSD where new OS threads were
directly calling the Go runtime entry-point from assembly via a PC,
rather than going through a wrapper. This meant new threads may not
have special registers set up. In this case, a change on all other
OSes had already forced new thread entry to go through an ABI wrapper,
so I just caught NetBSD up with that change.

With this change, I'm able to run a "hello world" with
GOEXPERIMENT=regabi,regabiargs.

For #40724.

Change-Id: I2a6d0e530c4fd4edf13484d923891c6160d683aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/305669
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/cmd/internal/objabi/util.go
src/runtime/asm_amd64.s
src/runtime/cgocall.go
src/runtime/os_netbsd.go
src/runtime/proc.go
src/runtime/sys_linux_amd64.s
src/runtime/sys_netbsd_386.s
src/runtime/sys_netbsd_amd64.s
src/runtime/sys_netbsd_arm.s
src/runtime/sys_netbsd_arm64.s
src/runtime/sys_windows_amd64.s