]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: fix pc/sp information for prologue
authorRuss Cox <rsc@golang.org>
Tue, 14 Jul 2015 01:21:49 +0000 (21:21 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 15 Jul 2015 04:09:35 +0000 (04:09 +0000)
When the prologue call to morestack was moved down to the
bottom of the function, the pc/sp tables were not updated.
If a traceback through a call to morestack is needed, it would
get confused at and stop at morestack.

Confirmed the fix by adding //go:systemstack (which calls
morestackc, but same issue) where it did not belong
and inspecting the crash.

Change-Id: Id0294bb9dba51ef1a49154637228fb57f1086a94
Reviewed-on: https://go-review.googlesource.com/12144
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/internal/obj/arm/obj5.go
src/cmd/internal/obj/arm64/obj7.go
src/cmd/internal/obj/x86/obj6.go

index ce1cad9c47313c0372aaa7f0c21e20edae0f4058..15534e6f34169fa8e902e22a6076136f6a2776e3 100644 (file)
@@ -804,8 +804,12 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
        for last = ctxt.Cursym.Text; last.Link != nil; last = last.Link {
        }
 
+       spfix := obj.Appendp(ctxt, last)
+       spfix.As = obj.ANOP
+       spfix.Spadj = -framesize
+
        // MOVW LR, R3
-       movw := obj.Appendp(ctxt, last)
+       movw := obj.Appendp(ctxt, spfix)
        movw.As = AMOVW
        movw.From.Type = obj.TYPE_REG
        movw.From.Reg = REGLINK
@@ -833,6 +837,10 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
        b.To.Type = obj.TYPE_BRANCH
        b.Pcond = ctxt.Cursym.Text.Link
 
+       spfix = obj.Appendp(ctxt, b)
+       spfix.As = obj.ANOP
+       spfix.Spadj = +framesize
+
        return bls
 }
 
index 77117fb530df6c271eea32579177f2a55c151989..91088c14900b37f3bac9a3b7aa62eaad578677b1 100644 (file)
@@ -161,8 +161,12 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
        for last = ctxt.Cursym.Text; last.Link != nil; last = last.Link {
        }
 
+       spfix := obj.Appendp(ctxt, last)
+       spfix.As = obj.ANOP
+       spfix.Spadj = -framesize
+
        // MOV  LR, R3
-       movlr := obj.Appendp(ctxt, last)
+       movlr := obj.Appendp(ctxt, spfix)
        movlr.As = AMOVD
        movlr.From.Type = obj.TYPE_REG
        movlr.From.Reg = REGLINK
@@ -202,6 +206,10 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
        jmp.To.Type = obj.TYPE_BRANCH
        jmp.Pcond = ctxt.Cursym.Text.Link
 
+       spfix = obj.Appendp(ctxt, jmp)
+       spfix.As = obj.ANOP
+       spfix.Spadj = +framesize
+
        // placeholder for bls's jump target
        // p = obj.Appendp(ctxt, p)
        // p.As = obj.ANOP
index fa9c474adb344f8f66089330bcd408e7a4b07ff8..5ee097e1d645dbcd6a87fa9a89089399b89334a9 100644 (file)
@@ -975,7 +975,12 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob
        for last = ctxt.Cursym.Text; last.Link != nil; last = last.Link {
        }
 
-       call := obj.Appendp(ctxt, last)
+       // Explain to PC-line tables that there is no frame here.
+       spfix := obj.Appendp(ctxt, last)
+       spfix.As = obj.ANOP
+       spfix.Spadj = -framesize
+
+       call := obj.Appendp(ctxt, spfix)
        call.Lineno = ctxt.Cursym.Text.Lineno
        call.Mode = ctxt.Cursym.Text.Mode
        call.As = obj.ACALL
@@ -994,6 +999,10 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32, textarg int32) *ob
        jmp.To.Type = obj.TYPE_BRANCH
        jmp.Pcond = ctxt.Cursym.Text.Link
 
+       spfix = obj.Appendp(ctxt, jmp)
+       spfix.As = obj.ANOP
+       spfix.Spadj = +framesize
+
        jls.Pcond = call
        if q1 != nil {
                q1.Pcond = call