linux-user: Move elf_core_copy_regs to microblaze/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 a8081da18d
commit e06b9c34ea
3 changed files with 26 additions and 21 deletions
-21
View File
@@ -416,27 +416,6 @@ static const VdsoImageInfo *vdso_image_info(uint32_t elf_flags)
#define ELF_EXEC_PAGESIZE 4096
#define HAVE_ELF_CORE_DUMP
#define ELF_NREG 38
typedef struct target_elf_gregset_t {
target_elf_greg_t regs[ELF_NREG];
} target_elf_gregset_t;
/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUMBState *env)
{
for (int i = 0; i < 32; i++) {
r->regs[i] = tswapreg(env->regs[i]);
}
r->regs[32] = tswapreg(env->pc);
r->regs[33] = tswapreg(mb_cpu_read_msr(env));
r->regs[34] = 0;
r->regs[35] = tswapreg(env->ear);
r->regs[36] = 0;
r->regs[37] = tswapreg(env->esr);
}
#endif /* TARGET_MICROBLAZE */
#ifdef TARGET_OPENRISC
+17
View File
@@ -3,9 +3,26 @@
#include "qemu/osdep.h"
#include "qemu.h"
#include "loader.h"
#include "target_elf.h"
const char *get_elf_cpu_model(uint32_t eflags)
{
return "any";
}
#define tswapreg(ptr) tswapal(ptr)
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUMBState *env)
{
for (int i = 0; i < 32; i++) {
r->regs[i] = tswapreg(env->regs[i]);
}
r->regs[32] = tswapreg(env->pc);
r->regs[33] = tswapreg(mb_cpu_read_msr(env));
r->regs[34] = 0;
r->regs[35] = tswapreg(env->ear);
r->regs[36] = 0;
r->regs[37] = tswapreg(env->esr);
}
+9
View File
@@ -8,4 +8,13 @@
#ifndef MICROBLAZE_TARGET_ELF_H
#define MICROBLAZE_TARGET_ELF_H
#define HAVE_ELF_CORE_DUMP 1
typedef abi_ulong target_elf_greg_t;
#define ELF_NREG 38
typedef struct target_elf_gregset_t {
target_elf_greg_t regs[ELF_NREG];
} target_elf_gregset_t;
#endif