Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- linux-user/elfload.c | 34 +--------------------------- linux-user/sh4/target_coredump.c.inc | 32 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 linux-user/sh4/target_coredump.c.inc
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 051e9b72cf..836f01e579 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -458,39 +458,7 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags) #define ELF_CLASS ELFCLASS32 #define ELF_ARCH EM_SH -/* See linux kernel: arch/sh/include/asm/elf.h. */ -#define ELF_NREG 23 -typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG]; - -/* 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 -}; - -static inline void elf_core_copy_regs(target_elf_gregset_t *regs, - const CPUSH4State *env) -{ - int i; - - for (i = 0; i < 16; i++) { - (*regs)[i] = tswapreg(env->gregs[i]); - } - - (*regs)[TARGET_REG_PC] = tswapreg(env->pc); - (*regs)[TARGET_REG_PR] = tswapreg(env->pr); - (*regs)[TARGET_REG_SR] = tswapreg(env->sr); - (*regs)[TARGET_REG_GBR] = tswapreg(env->gbr); - (*regs)[TARGET_REG_MACH] = tswapreg(env->mach); - (*regs)[TARGET_REG_MACL] = tswapreg(env->macl); - (*regs)[TARGET_REG_SYSCALL] = 0; /* FIXME */ -} - +#include "target_coredump.c.inc" #define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 diff --git a/linux-user/sh4/target_coredump.c.inc b/linux-user/sh4/target_coredump.c.inc new file mode 100644 index 0000000000..559cd21b1d --- /dev/null +++ b/linux-user/sh4/target_coredump.c.inc @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/* See linux kernel: arch/sh/include/asm/elf.h. */ +#define ELF_NREG 23 +typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG]; + +/* 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 +}; + +static void elf_core_copy_regs(target_elf_gregset_t *regs, + const CPUSH4State *env) +{ + for (int i = 0; i < 16; i++) { + (*regs)[i] = tswapreg(env->gregs[i]); + } + + (*regs)[TARGET_REG_PC] = tswapreg(env->pc); + (*regs)[TARGET_REG_PR] = tswapreg(env->pr); + (*regs)[TARGET_REG_SR] = tswapreg(env->sr); + (*regs)[TARGET_REG_GBR] = tswapreg(env->gbr); + (*regs)[TARGET_REG_MACH] = tswapreg(env->mach); + (*regs)[TARGET_REG_MACL] = tswapreg(env->macl); + (*regs)[TARGET_REG_SYSCALL] = 0; /* FIXME */ +} -- 2.43.0