cmd/internal/obj/arm: set spadj in arm32 tailcall

In the normal case spadj is not needed because ARET handles the frame pop
and return in a single instruction. However, if the ARET is a tailcall then
there will be a second instruction where the pcsp stack depth is
incorrect.

Fixes #78021

Change-Id: I20db57eee03945a369a4b185b8f3311f4accd7ae
GitHub-Last-Rev: 7226e2e074
GitHub-Pull-Request: golang/go#78022
Reviewed-on: https://go-review.googlesource.com/c/go/+/752881
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
Thea Heinen
2026-03-09 22:04:38 +00:00
committed by Keith Randall
parent 23fde5c48c
commit 59b188cee2

View File

@@ -387,12 +387,18 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
// If there are instructions following
// this ARET, they come from a branch
// with the same stackframe, so no spadj.
// with the same stackframe, so spadj should
// sum to 0.
if retSym != nil || retReg != REGLINK { // retjmp
p.To.Reg = REGLINK
// If ARET is a tail-call, the frame pop
// and jump are in separate instructions
// and spadj is needed.
p.Spadj = -autosize
q2 = obj.Appendp(p, newprog)
q2.As = AB
q2.Spadj = +autosize
if retSym != nil {
q2.To.Type = obj.TYPE_BRANCH
q2.To.Sym = retSym