On Thu, 28 Aug 2025 at 13:09, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/elfload.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 63376fa1d6..98c17d32e6 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -770,7 +770,9 @@ static void elf_core_copy_regs(target_elf_gregset_t *r, const CPUM68KState *env)
>
> /* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs). */
> #define ELF_NREG 27
> -typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG];
> +typedef struct target_elf_gregset_t {
> + target_elf_greg_t regs[ELF_NREG];
> +} target_elf_gregset_t;
>
> enum {
> TARGET_REG_PSWM = 0,
> @@ -780,22 +782,22 @@ enum {
> TARGET_REG_ORIG_R2 = 26,
> };
>
> -static void elf_core_copy_regs(target_elf_gregset_t *regs,
> +static void elf_core_copy_regs(target_elf_gregset_t *r,
> const CPUS390XState *env)
> {
> int i;
> uint32_t *aregs;
>
> - (*regs)[TARGET_REG_PSWM] = tswapreg(env->psw.mask);
> - (*regs)[TARGET_REG_PSWA] = tswapreg(env->psw.addr);
> + r->regs[TARGET_REG_PSWM] = tswapreg(env->psw.mask);
> + r->regs[TARGET_REG_PSWA] = tswapreg(env->psw.addr);
> for (i = 0; i < 16; i++) {
> - (*regs)[TARGET_REG_GPRS + i] = tswapreg(env->regs[i]);
> + r->regs[TARGET_REG_GPRS + i] = tswapreg(env->regs[i]);
> }
> - aregs = (uint32_t *)&((*regs)[TARGET_REG_ARS]);
> + aregs = (uint32_t *)&(r->regs[TARGET_REG_ARS]);
> for (i = 0; i < 16; i++) {
> aregs[i] = tswap32(env->aregs[i]);
> }
This code (which takes a pointer to an entry in an
array of 64-bit integers, casts it to a pointer to
uint32_t, and then stores to that) looks very suspicious
for not handing big-endian hosts correctly. But that's
a separate problem, so for this refactoring
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
> - (*regs)[TARGET_REG_ORIG_R2] = 0;
> + r->regs[TARGET_REG_ORIG_R2] = 0;
> }
>
> #define USE_ELF_CORE_DUMP
> --
> 2.43.0