linux-user: Move elf_core_copy_regs to aarch64/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>
This commit is contained in:
Richard Henderson
2025-08-30 07:04:03 +10:00
parent 53c6724cc9
commit b71b68b233
3 changed files with 20 additions and 15 deletions
+12
View File
@@ -4,6 +4,7 @@
#include "qemu.h"
#include "loader.h"
#include "target/arm/cpu-features.h"
#include "target_elf.h"
const char *get_elf_cpu_model(uint32_t eflags)
@@ -347,3 +348,14 @@ const char *get_elf_platform(CPUState *cs)
{
return TARGET_BIG_ENDIAN ? "aarch64_be" : "aarch64";
}
#define tswapreg(ptr) tswapal(ptr)
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUARMState *env)
{
for (int i = 0; i < 32; i++) {
r->regs[i] = tswapreg(env->xregs[i]);
}
r->regs[32] = tswapreg(env->pc);
r->regs[33] = tswapreg(pstate_read((CPUARMState *)env));
}
+8
View File
@@ -11,5 +11,13 @@
#define HAVE_ELF_HWCAP 1
#define HAVE_ELF_HWCAP2 1
#define HAVE_ELF_PLATFORM 1
#define HAVE_ELF_CORE_DUMP 1
typedef abi_ulong target_elf_greg_t;
#define ELF_NREG 34
typedef struct target_elf_gregset_t {
target_elf_greg_t regs[ELF_NREG];
} target_elf_gregset_t;
#endif
-15
View File
@@ -291,21 +291,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)
#define ELF_ARCH EM_AARCH64
#define ELF_CLASS ELFCLASS64
#define ELF_NREG 34
typedef struct target_elf_gregset_t {
target_elf_greg_t regs[ELF_NREG];
} target_elf_gregset_t;
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUARMState *env)
{
for (int i = 0; i < 32; i++) {
r->regs[i] = tswapreg(env->xregs[i]);
}
r->regs[32] = tswapreg(env->pc);
r->regs[33] = tswapreg(pstate_read((CPUARMState *)env));
}
#define HAVE_ELF_CORE_DUMP
#define ELF_EXEC_PAGESIZE 4096
#if TARGET_BIG_ENDIAN