]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: set r12 to sigpanic before jumping to it in sighandler
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Tue, 1 Dec 2015 01:47:22 +0000 (14:47 +1300)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Tue, 1 Dec 2015 04:51:35 +0000 (04:51 +0000)
The ppc64le shared library ABI demands that r12 is set to a function's global
entrypoint before jumping to the global entrypoint. Not doing so means that
handling signals that usually panic actually crashes (and so, e.g. can't be
recovered). Fixes several failures of "cd test; go run run.go -linkshared".

Change-Id: Ia4d0da4c13efda68340d38c045a52b37c2f90796
Reviewed-on: https://go-review.googlesource.com/17280
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/signal_linux_ppc64x.go
src/runtime/signal_ppc64x.go

index 5445201b19b64889d0029f8d075bb28ad65526b0..49e97a4d2516905d4b07bbe2be21ca5cecf55d58 100644 (file)
@@ -63,6 +63,7 @@ func (c *sigctxt) sigaddr() uint64 { return c.info.si_addr }
 func (c *sigctxt) fault() uint64   { return c.regs().dar }
 
 func (c *sigctxt) set_r0(x uint64)   { c.regs().gpr[0] = x }
+func (c *sigctxt) set_r12(x uint64)  { c.regs().gpr[12] = x }
 func (c *sigctxt) set_r30(x uint64)  { c.regs().gpr[30] = x }
 func (c *sigctxt) set_pc(x uint64)   { c.regs().nip = x }
 func (c *sigctxt) set_sp(x uint64)   { c.regs().gpr[1] = x }
index e0c5f91e338a4cac5513161e88d9d05aa97ee371..b22df8860210db8d0543eea8e2aa372a74d79cfc 100644 (file)
@@ -110,6 +110,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
                // In case we are panicking from external C code
                c.set_r0(0)
                c.set_r30(uint64(uintptr(unsafe.Pointer(gp))))
+               c.set_r12(uint64(funcPC(sigpanic)))
                c.set_pc(uint64(funcPC(sigpanic)))
                return
        }