Skip to content

Commit c383a98

Browse files
abner-chencxen0n
authored andcommitted
cmd/internal/obj/loong64: save LR after decrementing SP
Refer to CL 413428 and 412474, for loong64, like mips, s390x and riscv, there is no single instruction that saves the LR and decrements the SP, so we also need to insert an instruction to save the LR after decrementing the SP. Fixes golang#56623. Updates golang#53374. Change-Id: I3de040792f0a041d3d2a98ea89c23a2dd2f4ad10 Reviewed-on: https://go-review.googlesource.com/c/go/+/416154 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Cherry Mui <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: WANG Xuerui <[email protected]> Reviewed-by: xiaodong liu <[email protected]> Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: Meidan Li <[email protected]> (cherry picked from commit 3ed8a1e)
1 parent 3b795dc commit c383a98

File tree

1 file changed

+14
-0
lines changed
  • src/cmd/internal/obj/loong64

1 file changed

+14
-0
lines changed

src/cmd/internal/obj/loong64/obj.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,20 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
260260
q.Spadj = +autosize
261261

262262
q = c.ctxt.EndUnsafePoint(q, c.newprog, -1)
263+
264+
// On Linux, in a cgo binary we may get a SIGSETXID signal early on
265+
// before the signal stack is set, as glibc doesn't allow us to block
266+
// SIGSETXID. So a signal may land on the current stack and clobber
267+
// the content below the SP. We store the LR again after the SP is
268+
// decremented.
269+
q = obj.Appendp(q, newprog)
270+
q.As = mov
271+
q.Pos = p.Pos
272+
q.From.Type = obj.TYPE_REG
273+
q.From.Reg = REGLINK
274+
q.To.Type = obj.TYPE_MEM
275+
q.To.Offset = 0
276+
q.To.Reg = REGSP
263277
}
264278

265279
if c.cursym.Func().Text.From.Sym.Wrapper() && c.cursym.Func().Text.Mark&LEAF == 0 {

0 commit comments

Comments
 (0)