Make use of the fact that target_elf_gregset_t is a proper structure.
Drop ELF_NREG, target_elf_greg_t, and tswapreg.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/sh4/target_elf.h | 12 +++++++-----
linux-user/sh4/elfload.c | 28 +++++++---------------------
2 files changed, 14 insertions(+), 26 deletions(-)
diff --git a/linux-user/sh4/target_elf.h b/linux-user/sh4/target_elf.h
index f7443ddbac..fd3ae68a01 100644
--- a/linux-user/sh4/target_elf.h
+++ b/linux-user/sh4/target_elf.h
@@ -8,15 +8,17 @@
#ifndef SH4_TARGET_ELF_H
#define SH4_TARGET_ELF_H
+#include "target_ptrace.h"
+
#define HAVE_ELF_HWCAP 1
#define HAVE_ELF_CORE_DUMP 1
-typedef abi_ulong target_elf_greg_t;
-
-/* See linux kernel: arch/sh/include/asm/elf.h. */
-#define ELF_NREG 23
+/*
+ * See linux kernel: arch/sh/include/asm/elf.h, where
+ * elf_gregset_t is mapped to struct pt_regs via sizeof.
+ */
typedef struct target_elf_gregset_t {
- target_elf_greg_t regs[ELF_NREG];
+ struct target_pt_regs pt;
} target_elf_gregset_t;
#endif
diff --git a/linux-user/sh4/elfload.c b/linux-user/sh4/elfload.c
index 71cae9703e..ddf2aaaed7 100644
--- a/linux-user/sh4/elfload.c
+++ b/linux-user/sh4/elfload.c
@@ -38,30 +38,16 @@ abi_ulong get_elf_hwcap(CPUState *cs)
return hwcap;
}
-#define tswapreg(ptr) tswapal(ptr)
-
-/* See linux kernel: arch/sh/include/asm/ptrace.h. */
-enum {
- TARGET_REG_PC = 16,
- TARGET_REG_PR = 17,
- TARGET_REG_SR = 18,
- TARGET_REG_GBR = 19,
- TARGET_REG_MACH = 20,
- TARGET_REG_MACL = 21,
- TARGET_REG_SYSCALL = 22
-};
-
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUSH4State *env)
{
for (int i = 0; i < 16; i++) {
- r->regs[i] = tswapreg(env->gregs[i]);
+ r->pt.regs[i] = tswapal(env->gregs[i]);
}
- r->regs[TARGET_REG_PC] = tswapreg(env->pc);
- r->regs[TARGET_REG_PR] = tswapreg(env->pr);
- r->regs[TARGET_REG_SR] = tswapreg(env->sr);
- r->regs[TARGET_REG_GBR] = tswapreg(env->gbr);
- r->regs[TARGET_REG_MACH] = tswapreg(env->mach);
- r->regs[TARGET_REG_MACL] = tswapreg(env->macl);
- r->regs[TARGET_REG_SYSCALL] = 0; /* FIXME */
+ r->pt.pc = tswapal(env->pc);
+ r->pt.pr = tswapal(env->pr);
+ r->pt.sr = tswapal(env->sr);
+ r->pt.gbr = tswapal(env->gbr);
+ r->pt.mach = tswapal(env->mach);
+ r->pt.macl = tswapal(env->macl);
}
--
2.43.0