Commit f0005230 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

runtime: set r12 to sigpanic before jumping to it in sighandler

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/17280Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 7305b55e
......@@ -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 }
......
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment