]> Cypherpunks repositories - gostls13.git/commit
cmd/asm,cmd/compile,runtime: stop using X3 (aka GP) on riscv64
authorJoel Sing <joel@sing.id.au>
Sun, 26 Sep 2021 09:21:29 +0000 (19:21 +1000)
committerJoel Sing <joel@sing.id.au>
Wed, 3 Nov 2021 09:08:46 +0000 (09:08 +0000)
commit5b213178e72b6031c9ec790bf9fe784c66b397e3
tree2796033f0ff66b84cad1c3cb26292f6d00d29c6f
parent519c0a2323700934cbec97b75df92917108548be
cmd/asm,cmd/compile,runtime: stop using X3 (aka GP) on riscv64

The X3 (aka GP) register will potentially be loaded with the __global_pointer$ symbol
during program start up (usually by the dynamic linker). As such, non-Go code may depend
on the contents of GP and calculate offsets based on it, including code called via cgo
and signal handlers installed by non-Go code. As such, stop using the X3 register so
that there are fewer issues interacting between Go and non-Go code.

While here remove the X4 (TP) name from the assembler such that any references must
use the 'TP' name. This should reduce the likelihood of accidental use (like we do
for the 'g' register). The same applies for X3 (GP) when the -shared flag is given.

Updates #47100

Change-Id: I72e82b5ca3f80c46a781781345ca0432a4111b74
Reviewed-on: https://go-review.googlesource.com/c/go/+/351859
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/cmd/asm/internal/arch/arch.go
src/cmd/asm/internal/asm/operand_test.go
src/cmd/asm/main.go
src/cmd/compile/internal/ssa/gen/RISCV64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/runtime/asm_riscv64.s
src/runtime/cgo/asm_riscv64.s
src/runtime/cgo/gcc_riscv64.S
src/runtime/mkpreempt.go
src/runtime/preempt_riscv64.s
src/runtime/tls_riscv64.s