Move elf_core_copy_regs to elfload.c. Move ELF_NREG to target_elf.h. Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- linux-user/loongarch64/target_elf.h | 3 +++ linux-user/elfload.c | 23 ----------------------- linux-user/loongarch64/elfload.c | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/linux-user/loongarch64/target_elf.h b/linux-user/loongarch64/target_elf.h index eb17927325..f2d00c9232 100644 --- a/linux-user/loongarch64/target_elf.h +++ b/linux-user/loongarch64/target_elf.h @@ -9,4 +9,7 @@ #define HAVE_ELF_HWCAP 1 #define HAVE_ELF_PLATFORM 1 +/* See linux kernel: arch/loongarch/include/asm/elf.h */ +#define ELF_NREG 45 + #endif diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0bfcbcf78d..834120c9f2 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -375,29 +375,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags) #define VDSO_HEADER "vdso.c.inc" -/* See linux kernel: arch/loongarch/include/asm/elf.h */ -#define ELF_NREG 45 - -enum { - TARGET_EF_R0 = 0, - TARGET_EF_CSR_ERA = TARGET_EF_R0 + 33, - TARGET_EF_CSR_BADV = TARGET_EF_R0 + 34, -}; - -void elf_core_copy_regs(target_ulong *regs, const CPULoongArchState *env) -{ - int i; - - regs[TARGET_EF_R0] = 0; - - for (i = 1; i < ARRAY_SIZE(env->gpr); i++) { - regs[TARGET_EF_R0 + i] = tswapl(env->gpr[i]); - } - - regs[TARGET_EF_CSR_ERA] = tswapl(env->pc); - regs[TARGET_EF_CSR_BADV] = tswapl(env->CSR_BADV); -} - #define ELF_EXEC_PAGESIZE 4096 #endif /* TARGET_LOONGARCH64 */ diff --git a/linux-user/loongarch64/elfload.c b/linux-user/loongarch64/elfload.c index 911352840f..c9ce8ba3da 100644 --- a/linux-user/loongarch64/elfload.c +++ b/linux-user/loongarch64/elfload.c @@ -61,3 +61,23 @@ const char *get_elf_platform(CPUState *cs) { return "loongarch"; } + +enum { + TARGET_EF_R0 = 0, + TARGET_EF_CSR_ERA = TARGET_EF_R0 + 33, + TARGET_EF_CSR_BADV = TARGET_EF_R0 + 34, +}; + +void elf_core_copy_regs(target_ulong *regs, const CPULoongArchState *env) +{ + int i; + + regs[TARGET_EF_R0] = 0; + + for (i = 1; i < ARRAY_SIZE(env->gpr); i++) { + regs[TARGET_EF_R0 + i] = tswapl(env->gpr[i]); + } + + regs[TARGET_EF_CSR_ERA] = tswapl(env->pc); + regs[TARGET_EF_CSR_BADV] = tswapl(env->CSR_BADV); +} -- 2.43.0