Move elf_core_copy_regs to elfload.c. Move HAVE_ELF_CORE_DUMP, ELF_NREGS, target_elf_gregset_t to target_elf.h. For now, duplicate the definitions of target_elf_greg_t and tswapreg.
Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- linux-user/xtensa/target_elf.h | 10 +++++++++ linux-user/elfload.c | 39 ---------------------------------- linux-user/xtensa/elfload.c | 35 ++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 39 deletions(-) diff --git a/linux-user/xtensa/target_elf.h b/linux-user/xtensa/target_elf.h index 2c55c22e14..43e241aac1 100644 --- a/linux-user/xtensa/target_elf.h +++ b/linux-user/xtensa/target_elf.h @@ -8,4 +8,14 @@ #ifndef XTENSA_TARGET_ELF_H #define XTENSA_TARGET_ELF_H +#define HAVE_ELF_CORE_DUMP 1 + +typedef abi_ulong target_elf_greg_t; + +/* See linux kernel: arch/xtensa/include/asm/elf.h. */ +#define ELF_NREG 128 +typedef struct target_elf_gregset_t { + target_elf_greg_t regs[ELF_NREG]; +} target_elf_gregset_t; + #endif diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 7c783b74d4..5cdbdc20d9 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -531,45 +531,6 @@ static bool init_guest_commpage(void) #define ELF_CLASS ELFCLASS32 #define ELF_ARCH EM_XTENSA -/* See linux kernel: arch/xtensa/include/asm/elf.h. */ -#define ELF_NREG 128 -typedef struct target_elf_gregset_t { - target_elf_greg_t regs[ELF_NREG]; -} target_elf_gregset_t; - -enum { - TARGET_REG_PC, - TARGET_REG_PS, - TARGET_REG_LBEG, - TARGET_REG_LEND, - TARGET_REG_LCOUNT, - TARGET_REG_SAR, - TARGET_REG_WINDOWSTART, - TARGET_REG_WINDOWBASE, - TARGET_REG_THREADPTR, - TARGET_REG_AR0 = 64, -}; - -void elf_core_copy_regs(target_elf_gregset_t *r, const CPUXtensaState *env) -{ - unsigned i; - - r->regs[TARGET_REG_PC] = tswapreg(env->pc); - r->regs[TARGET_REG_PS] = tswapreg(env->sregs[PS] & ~PS_EXCM); - r->regs[TARGET_REG_LBEG] = tswapreg(env->sregs[LBEG]); - r->regs[TARGET_REG_LEND] = tswapreg(env->sregs[LEND]); - r->regs[TARGET_REG_LCOUNT] = tswapreg(env->sregs[LCOUNT]); - r->regs[TARGET_REG_SAR] = tswapreg(env->sregs[SAR]); - r->regs[TARGET_REG_WINDOWSTART] = tswapreg(env->sregs[WINDOW_START]); - r->regs[TARGET_REG_WINDOWBASE] = tswapreg(env->sregs[WINDOW_BASE]); - r->regs[TARGET_REG_THREADPTR] = tswapreg(env->uregs[THREADPTR]); - xtensa_sync_phys_from_window((CPUXtensaState *)env); - for (i = 0; i < env->config->nareg; ++i) { - r->regs[TARGET_REG_AR0 + i] = tswapreg(env->phys_regs[i]); - } -} - -#define HAVE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #endif /* TARGET_XTENSA */ diff --git a/linux-user/xtensa/elfload.c b/linux-user/xtensa/elfload.c index e35ba69a10..49e709a094 100644 --- a/linux-user/xtensa/elfload.c +++ b/linux-user/xtensa/elfload.c @@ -3,9 +3,44 @@ #include "qemu/osdep.h" #include "qemu.h" #include "loader.h" +#include "target_elf.h" const char *get_elf_cpu_model(uint32_t eflags) { return XTENSA_DEFAULT_CPU_MODEL; } + +#define tswapreg(ptr) tswapal(ptr) + +enum { + TARGET_REG_PC, + TARGET_REG_PS, + TARGET_REG_LBEG, + TARGET_REG_LEND, + TARGET_REG_LCOUNT, + TARGET_REG_SAR, + TARGET_REG_WINDOWSTART, + TARGET_REG_WINDOWBASE, + TARGET_REG_THREADPTR, + TARGET_REG_AR0 = 64, +}; + +void elf_core_copy_regs(target_elf_gregset_t *r, const CPUXtensaState *env) +{ + unsigned i; + + r->regs[TARGET_REG_PC] = tswapreg(env->pc); + r->regs[TARGET_REG_PS] = tswapreg(env->sregs[PS] & ~PS_EXCM); + r->regs[TARGET_REG_LBEG] = tswapreg(env->sregs[LBEG]); + r->regs[TARGET_REG_LEND] = tswapreg(env->sregs[LEND]); + r->regs[TARGET_REG_LCOUNT] = tswapreg(env->sregs[LCOUNT]); + r->regs[TARGET_REG_SAR] = tswapreg(env->sregs[SAR]); + r->regs[TARGET_REG_WINDOWSTART] = tswapreg(env->sregs[WINDOW_START]); + r->regs[TARGET_REG_WINDOWBASE] = tswapreg(env->sregs[WINDOW_BASE]); + r->regs[TARGET_REG_THREADPTR] = tswapreg(env->uregs[THREADPTR]); + xtensa_sync_phys_from_window((CPUXtensaState *)env); + for (i = 0; i < env->config->nareg; ++i) { + r->regs[TARGET_REG_AR0 + i] = tswapreg(env->phys_regs[i]); + } +} -- 2.43.0