diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2025-08-28 12:22:55 +1000 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2025-08-30 07:04:04 +1000 |
commit | 8ad5f12426dd6218db4753722ab240a16a235259 (patch) | |
tree | 6bdf2d20b5cf2a76a3ee776db589a8043371dd6a /linux-user | |
parent | 584c21f34eb0419858d74420df7d0fd5f3ea419a (diff) | |
download | qemu-8ad5f12426dd6218db4753722ab240a16a235259.zip qemu-8ad5f12426dd6218db4753722ab240a16a235259.tar.gz qemu-8ad5f12426dd6218db4753722ab240a16a235259.tar.bz2 |
linux-user/ppc: Expand target_elf_gregset_t
Make use of the fact that target_elf_gregset_t is a proper structure.
Drop ELF_NREG, target_elf_greg_t, and tswapreg.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/ppc/elfload.c | 23 | ||||
-rw-r--r-- | linux-user/ppc/target_elf.h | 16 |
2 files changed, 19 insertions, 20 deletions
diff --git a/linux-user/ppc/elfload.c b/linux-user/ppc/elfload.c index 114e40a..0d54da9 100644 --- a/linux-user/ppc/elfload.c +++ b/linux-user/ppc/elfload.c @@ -131,23 +131,16 @@ abi_ulong get_elf_hwcap2(CPUState *cs) return features; } -#define tswapreg(ptr) tswapal(ptr) - void elf_core_copy_regs(target_elf_gregset_t *r, const CPUPPCState *env) { - int i; - target_ulong ccr = 0; - - for (i = 0; i < ARRAY_SIZE(env->gpr); i++) { - r->regs[i] = tswapreg(env->gpr[i]); + for (int i = 0; i < ARRAY_SIZE(env->gpr); i++) { + r->pt.gpr[i] = tswapal(env->gpr[i]); } - r->regs[32] = tswapreg(env->nip); - r->regs[33] = tswapreg(env->msr); - r->regs[35] = tswapreg(env->ctr); - r->regs[36] = tswapreg(env->lr); - r->regs[37] = tswapreg(cpu_read_xer(env)); - - ccr = ppc_get_cr(env); - r->regs[38] = tswapreg(ccr); + r->pt.nip = tswapal(env->nip); + r->pt.msr = tswapal(env->msr); + r->pt.ctr = tswapal(env->ctr); + r->pt.link = tswapal(env->lr); + r->pt.xer = tswapal(cpu_read_xer(env)); + r->pt.ccr = tswapal(ppc_get_cr(env)); } diff --git a/linux-user/ppc/target_elf.h b/linux-user/ppc/target_elf.h index 7261555..2a61cd2 100644 --- a/linux-user/ppc/target_elf.h +++ b/linux-user/ppc/target_elf.h @@ -8,16 +8,22 @@ #ifndef PPC_TARGET_ELF_H #define PPC_TARGET_ELF_H +#include "target_ptrace.h" + #define HAVE_ELF_HWCAP 1 #define HAVE_ELF_HWCAP2 1 #define HAVE_ELF_CORE_DUMP 1 -typedef abi_ulong target_elf_greg_t; - -/* See linux kernel: arch/powerpc/include/asm/elf.h. */ -#define ELF_NREG 48 +/* + * The size of 48 words is set in arch/powerpc/include/uapi/asm/elf.h. + * However PPC_ELF_CORE_COPY_REGS in arch/powerpc/include/asm/elf.h + * open-codes a memcpy from struct pt_regs, then zeros the rest. + */ typedef struct target_elf_gregset_t { - target_elf_greg_t regs[ELF_NREG]; + union { + struct target_pt_regs pt; + abi_ulong reserved[48]; + }; } target_elf_gregset_t; #endif |