runtime: use correct field name for PPC32 GLIBC registers

One of these days we will get this right.

Fixes https://gcc.gnu.org/PR105315

Change-Id: I579156373977efefb88f1968e82af569ffdf909f
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/401374
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c
index 2caddd0..528d9b6 100644
--- a/libgo/runtime/go-signal.c
+++ b/libgo/runtime/go-signal.c
@@ -233,7 +233,11 @@
 #elif defined(__PPC64__) && defined(__linux__)
 	ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gp_regs[32];
 #elif defined(__PPC__) && defined(__linux__)
+# if defined(__GLIBC__)
+	ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.uc_regs->gregs[32];
+# else
 	ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gregs[32];
+# endif
 #elif defined(__PPC__) && defined(_AIX)
 	ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.jmp_context.iar;
 #elif defined(__aarch64__) && defined(__linux__)
@@ -344,12 +348,13 @@
 		runtime_printf("sp  %X\n", m->sc_regs[30]);
 		runtime_printf("pc  %X\n", m->sc_pc);
 	  }
-#elif defined(__PPC__) && defined(__LITTLE_ENDIAN__) && defined(__linux__)
+#elif defined(__PPC__) && defined(__linux__)
 	  {
-		mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext;
 		int i;
 
-#if defined(__PPC64__)
+# if defined(__PPC64__)
+		mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext;
+
 		for (i = 0; i < 32; i++)
 			runtime_printf("r%d %X\n", i, m->gp_regs[i]);
 		runtime_printf("pc  %X\n", m->gp_regs[32]);
@@ -358,16 +363,22 @@
 		runtime_printf("lr  %X\n", m->gp_regs[36]);
 		runtime_printf("ctr %X\n", m->gp_regs[35]);
 		runtime_printf("xer %X\n", m->gp_regs[37]);
-#else
+# else
+#  if defined(__GLIBC__)
+		mcontext_t *m = ((ucontext_t*)(context))->uc_mcontext.uc_regs;
+#  else
+		mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext;
+#  endif
+
 		for (i = 0; i < 32; i++)
-			runtime_printf("r%d %X\n", i, m->gregs[i]);
-		runtime_printf("pc  %X\n", m->gregs[32]);
-		runtime_printf("msr %X\n", m->gregs[33]);
-		runtime_printf("cr  %X\n", m->gregs[38]);
-		runtime_printf("lr  %X\n", m->gregs[36]);
-		runtime_printf("ctr %X\n", m->gregs[35]);
-		runtime_printf("xer %X\n", m->gregs[37]);
-#endif
+			runtime_printf("r%d %x\n", i, m->gregs[i]);
+		runtime_printf("pc  %x\n", m->gregs[32]);
+		runtime_printf("msr %x\n", m->gregs[33]);
+		runtime_printf("cr  %x\n", m->gregs[38]);
+		runtime_printf("lr  %x\n", m->gregs[36]);
+		runtime_printf("ctr %x\n", m->gregs[35]);
+		runtime_printf("xer %x\n", m->gregs[37]);
+# endif
 	  }
 #elif defined(__PPC__) && defined(_AIX)
 	  {