mirror of
https://github.com/golang/go
synced 2024-11-18 03:54:50 -07:00
cmd/internal/obj/mips: store LR before update SP in function prologue
This prevents the traceback code from seeing a half-updated stack frame when a profiling signal comes during the execution of function prologue. Also fixes mips64x part of #17381. Change-Id: Iec9683427e546e3648b2e8b1dde956d13f6eb938 Reviewed-on: https://go-review.googlesource.com/31721 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
0c02280fe0
commit
b55cee1893
@ -281,7 +281,21 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
|
||||
q = p
|
||||
|
||||
if autosize != 0 {
|
||||
q = obj.Appendp(ctxt, p)
|
||||
// Make sure to save link register for non-empty frame, even if
|
||||
// it is a leaf function, so that traceback works.
|
||||
// Store link register before decrement SP, so if a signal comes
|
||||
// during the execution of the function prologue, the traceback
|
||||
// code will not see a half-updated stack frame.
|
||||
q = obj.Appendp(ctxt, q)
|
||||
q.As = AMOVV
|
||||
q.Lineno = p.Lineno
|
||||
q.From.Type = obj.TYPE_REG
|
||||
q.From.Reg = REGLINK
|
||||
q.To.Type = obj.TYPE_MEM
|
||||
q.To.Offset = int64(-autosize)
|
||||
q.To.Reg = REGSP
|
||||
|
||||
q = obj.Appendp(ctxt, q)
|
||||
q.As = AADDV
|
||||
q.Lineno = p.Lineno
|
||||
q.From.Type = obj.TYPE_CONST
|
||||
@ -304,15 +318,6 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
|
||||
break
|
||||
}
|
||||
|
||||
q = obj.Appendp(ctxt, q)
|
||||
q.As = AMOVV
|
||||
q.Lineno = p.Lineno
|
||||
q.From.Type = obj.TYPE_REG
|
||||
q.From.Reg = REGLINK
|
||||
q.To.Type = obj.TYPE_MEM
|
||||
q.To.Offset = int64(0)
|
||||
q.To.Reg = REGSP
|
||||
|
||||
if cursym.Text.From3.Offset&obj.WRAPPER != 0 {
|
||||
// if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user