runtime: pass to signal handler value of g at time of signal

The existing code assumed that signals only arrived
while executing on the goroutine stack (g == m->curg),
not while executing on the scheduler stack (g == m->g0).

Most of the signal handling trampolines correctly saved
and restored g already, but the sighandler C code did not
have access to it.

Some rewriting of assembly to make the various
implementations as similar as possible.

Will need to change Windows too but I don't
understand how sigtramp gets called there.

R=r
CC=golang-dev
https://golang.org/cl/4203042
diff --git a/src/pkg/runtime/linux/arm/sys.s b/src/pkg/runtime/linux/arm/sys.s
index b25cf81..6c222fc 100644
--- a/src/pkg/runtime/linux/arm/sys.s
+++ b/src/pkg/runtime/linux/arm/sys.s
@@ -197,11 +197,24 @@
 	RET
 
 TEXT runtime·sigtramp(SB),7,$24
+	// save g
+	MOVW	g, R3
+	MOVW	g, 20(R13)
+	
+	// g = m->gsignal
 	MOVW	m_gsignal(m), g
+
+	// copy arguments for call to sighandler
 	MOVW	R0, 4(R13)
 	MOVW	R1, 8(R13)
 	MOVW	R2, 12(R13)
+	MOVW	R3, 16(R13)
+
 	BL	runtime·sighandler(SB)
+	
+	// restore g
+	MOVW	20(R13), g
+
 	RET
 
 TEXT runtime·rt_sigaction(SB),7,$0