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
This commit is contained in:
Justin Hibbits 2019-10-11 14:17:31 +00:00
parent 26517dcf60
commit 942aefd567
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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