From 942aefd5675556b297a73f3ed4e94690a59cf9ed Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Fri, 11 Oct 2019 14:17:31 +0000 Subject: [PATCH] gcore: Add powerpc64 32-bit gcore support Summary: Add the necessary bits for taking 32-bit gcore coredumps on powerpc64. Reviewed by: luporl Differential Revision: https://reviews.freebsd.org/D21954 --- usr.bin/gcore/Makefile | 3 ++- usr.bin/gcore/elf32core.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/usr.bin/gcore/Makefile b/usr.bin/gcore/Makefile index 205b3f1ea46c..e58f4ede82b3 100644 --- a/usr.bin/gcore/Makefile +++ b/usr.bin/gcore/Makefile @@ -5,7 +5,8 @@ PROG= gcore SRCS= elfcore.c gcore.c LIBADD= sbuf util -.if ${MACHINE_ARCH} == "aarch64" || ${MACHINE_ARCH} == "amd64" +.if ${MACHINE_ARCH} == "aarch64" || ${MACHINE_ARCH} == "amd64" || \ + ${MACHINE_ARCH} == "powerpc64" SRCS+= elf32core.c .endif diff --git a/usr.bin/gcore/elf32core.c b/usr.bin/gcore/elf32core.c index ba35631f4fb3..4e91fb0bc065 100644 --- a/usr.bin/gcore/elf32core.c +++ b/usr.bin/gcore/elf32core.c @@ -41,6 +41,17 @@ elf_convert_gregset(elfcore_gregset_t *rd, struct reg *rs) rd->r_lr = rs->x[14]; rd->r_pc = rs->elr; rd->r_cpsr = rs->spsr; +#elif defined(__powerpc64__) + int i; + + for (i = 0; i < 32; i++) + rd->fixreg[i] = rs->fixreg[i]; + rd->lr = rs->lr; + rd->cr = rs->cr; + rd->xer = rs->xer; + rd->ctr = rs->ctr; + rd->pc = rs->pc; +#else #error Unsupported architecture #endif } @@ -53,6 +64,8 @@ elf_convert_fpregset(elfcore_fpregset_t *rd, struct fpreg *rs) memcpy(rd, rs, sizeof(*rd)); #elif defined(__aarch64__) /* ARM64TODO */ +#elif defined(__powerpc64__) + memcpy(rd, rs, sizeof(*rd)); #else #error Unsupported architecture #endif