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
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
//