From 59b188cee2cdf522b621d1ee72c811fcd46e22b2 Mon Sep 17 00:00:00 2001 From: Thea Heinen Date: Mon, 9 Mar 2026 22:04:38 +0000 Subject: [PATCH] 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: 7226e2e07472549954ca9771b4f528e208703953 GitHub-Pull-Request: golang/go#78022 Reviewed-on: https://go-review.googlesource.com/c/go/+/752881 Reviewed-by: Mark Freeman Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall --- src/cmd/internal/obj/arm/obj5.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cmd/internal/obj/arm/obj5.go b/src/cmd/internal/obj/arm/obj5.go index 62870731b5..7331d62e75 100644 --- a/src/cmd/internal/obj/arm/obj5.go +++ b/src/cmd/internal/obj/arm/obj5.go @@ -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