diff options
| author | Richard Henderson <richard.henderson@linaro.org> | 2025-07-29 05:58:48 -1000 |
|---|---|---|
| committer | Richard Henderson <richard.henderson@linaro.org> | 2025-08-30 07:04:03 +1000 |
| commit | cf334829cb2a68ba1582923c773557b6fd20e123 (patch) | |
| tree | 000a4e963b108b5d29f3890e3d91f10a734e711f | |
| parent | a67e20d629a849d9d9d5ef527963462cd0718e78 (diff) | |
| download | focaccia-qemu-cf334829cb2a68ba1582923c773557b6fd20e123.tar.gz focaccia-qemu-cf334829cb2a68ba1582923c773557b6fd20e123.zip | |
linux-user: Move elf_core_copy_regs to loongarch64/elfload.c
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. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
| -rw-r--r-- | linux-user/elfload.c | 25 | ||||
| -rw-r--r-- | linux-user/loongarch64/elfload.c | 21 | ||||
| -rw-r--r-- | linux-user/loongarch64/target_elf.h | 9 |
3 files changed, 30 insertions, 25 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index d1d0a112fb..4acd7b9ffe 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -383,31 +383,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 -typedef struct target_elf_gregset_t { - target_elf_greg_t regs[ELF_NREG]; -} target_elf_gregset_t; - -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_elf_gregset_t *r, const CPULoongArchState *env) -{ - r->regs[TARGET_EF_R0] = 0; - - for (int i = 1; i < ARRAY_SIZE(env->gpr); i++) { - r->regs[TARGET_EF_R0 + i] = tswapreg(env->gpr[i]); - } - - r->regs[TARGET_EF_CSR_ERA] = tswapreg(env->pc); - r->regs[TARGET_EF_CSR_BADV] = tswapreg(env->CSR_BADV); -} - -#define HAVE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #endif /* TARGET_LOONGARCH64 */ diff --git a/linux-user/loongarch64/elfload.c b/linux-user/loongarch64/elfload.c index 911352840f..832890de10 100644 --- a/linux-user/loongarch64/elfload.c +++ b/linux-user/loongarch64/elfload.c @@ -3,6 +3,7 @@ #include "qemu/osdep.h" #include "qemu.h" #include "loader.h" +#include "target_elf.h" const char *get_elf_cpu_model(uint32_t eflags) @@ -61,3 +62,23 @@ const char *get_elf_platform(CPUState *cs) { return "loongarch"; } + +#define tswapreg(ptr) tswapal(ptr) + +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_elf_gregset_t *r, const CPULoongArchState *env) +{ + r->regs[TARGET_EF_R0] = 0; + + for (int i = 1; i < ARRAY_SIZE(env->gpr); i++) { + r->regs[TARGET_EF_R0 + i] = tswapreg(env->gpr[i]); + } + + r->regs[TARGET_EF_CSR_ERA] = tswapreg(env->pc); + r->regs[TARGET_EF_CSR_BADV] = tswapreg(env->CSR_BADV); +} diff --git a/linux-user/loongarch64/target_elf.h b/linux-user/loongarch64/target_elf.h index eb17927325..90bca4499d 100644 --- a/linux-user/loongarch64/target_elf.h +++ b/linux-user/loongarch64/target_elf.h @@ -8,5 +8,14 @@ #define HAVE_ELF_HWCAP 1 #define HAVE_ELF_PLATFORM 1 +#define HAVE_ELF_CORE_DUMP 1 + +typedef abi_ulong target_elf_greg_t; + +/* See linux kernel: arch/loongarch/include/asm/elf.h */ +#define ELF_NREG 45 +typedef struct target_elf_gregset_t { + target_elf_greg_t regs[ELF_NREG]; +} target_elf_gregset_t; #endif |