diff options
| author | Thea Heinen <tsheinen@gmail.com> | 2026-03-09 22:04:38 +0000 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2026-03-10 20:49:32 -0700 |
| commit | 59b188cee2cdf522b621d1ee72c811fcd46e22b2 (patch) | |
| tree | 89d94d5145454bce89205c055a42c66812a542eb /src | |
| parent | 23fde5c48c9bacb0ec8f5e21cc72191c64364ce1 (diff) | |
| download | go-59b188cee2cdf522b621d1ee72c811fcd46e22b2.tar.xz | |
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 <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>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/internal/obj/arm/obj5.go | 8 |
1 files changed, 7 insertions, 1 deletions
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 |
