Ian Lance Taylor <[email protected]> wrote:
> What I was hoping from my earlier question was that you could tell me
> the exact lines to write in the current sources that will compile on
> MUSL. Don't include <asm/ptrace.h>, don't refer to earlier patches as
> that is what I tried to do earlier but failed, don't add new #define
> macros, just add #ifdef and appropriate lines. Thanks. If the new
> lines also work on glibc using register indexes rather than names,
> that would be a bonus.
Sorry, may bad. Here you go:
diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c
index 9c919e15..454da75e 100644
--- a/libgo/runtime/go-signal.c
+++ b/libgo/runtime/go-signal.c
@@ -233,8 +233,11 @@ getSiginfo(siginfo_t *info, void *context
__attribute__((unused)))
#elif defined(__PPC__) && defined(__linux__)
// For some reason different libc implementations use
// different names.
-#if defined(__PPC64__) || defined(__GLIBC__)
+#if defined(__GLIBC__)
ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip;
+#elif defined(__PPC64__)
+ // Assumed to be ppc64 musl.
+ ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gp_regs[32];
#else
// Assumed to be ppc32 musl.
ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gregs[32];
@@ -354,7 +357,7 @@ dumpregs(siginfo_t *info __attribute__((unused)), void
*context __attribute__((u
mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext;
int i;
-#if defined(__PPC64__) || defined(__GLIBC__)
+#if defined(__GLIBC__)
for (i = 0; i < 32; i++)
runtime_printf("r%d %X\n", i, m->regs->gpr[i]);
runtime_printf("pc %X\n", m->regs->nip);
@@ -363,6 +366,15 @@ dumpregs(siginfo_t *info __attribute__((unused)), void
*context __attribute__((u
runtime_printf("lr %X\n", m->regs->link);
runtime_printf("ctr %X\n", m->regs->ctr);
runtime_printf("xer %X\n", m->regs->xer);
+#elif defined(__PPC64__)
+ 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]);
+ runtime_printf("msr %X\n", m->gp_regs[33]);
+ runtime_printf("cr %X\n", m->gp_regs[38]);
+ 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
for (i = 0; i < 32; i++)
runtime_printf("r%d %X\n", i, m->gregs[i]);