From 66df96e38402d243f9c7574ad59435260772ba9d Mon Sep 17 00:00:00 2001 From: Stuart Ianna Date: Mon, 17 Jun 2024 16:25:01 +1000 Subject: [PATCH] arch/risc-v/include/elf.f: Support coredump for rv32 and rv64 targets. Adds the missing elf_gregset_t type definition so pr_regs field can be resolved. Coredumps can be produced for both 32 and 64 bit targets. --- arch/risc-v/include/elf.h | 11 +++++++++++ arch/risc-v/src/common/riscv_tcbinfo.c | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/risc-v/include/elf.h b/arch/risc-v/include/elf.h index 2eb6270fb1..c6d45984f8 100644 --- a/arch/risc-v/include/elf.h +++ b/arch/risc-v/include/elf.h @@ -86,6 +86,9 @@ #define ARCH_ELFDATA 1 #define ARCH_ELF_RELCNT 8 +#define EM_ARCH EM_RISCV +#define EF_FLAG 0 + /**************************************************************************** * Public Types ****************************************************************************/ @@ -103,5 +106,13 @@ struct arch_elfdata_s }; typedef struct arch_elfdata_s arch_elfdata_t; +struct user_pt_regs +{ + uintreg_t regs[32]; +}; + +#define ELF_NGREG (sizeof(struct user_pt_regs) / sizeof(uintreg_t)) +typedef uintreg_t elf_gregset_t[ELF_NGREG]; + #endif /* __ASSEMBLY__ */ #endif /* __ARCH_RISCV_INCLUDE_ELF_H */ diff --git a/arch/risc-v/src/common/riscv_tcbinfo.c b/arch/risc-v/src/common/riscv_tcbinfo.c index bd79624650..1ad6216243 100644 --- a/arch/risc-v/src/common/riscv_tcbinfo.c +++ b/arch/risc-v/src/common/riscv_tcbinfo.c @@ -34,7 +34,7 @@ static const uint16_t g_reg_offs[] = { - UINT16_MAX, /* x0 */ + TCB_REG_OFF(REG_EPC_NDX), TCB_REG_OFF(REG_X1_NDX), TCB_REG_OFF(REG_X2_NDX), TCB_REG_OFF(REG_X3_NDX), @@ -66,7 +66,6 @@ static const uint16_t g_reg_offs[] = TCB_REG_OFF(REG_X29_NDX), TCB_REG_OFF(REG_X30_NDX), TCB_REG_OFF(REG_X31_NDX), - TCB_REG_OFF(REG_EPC_NDX), #if 0 # ifdef CONFIG_ARCH_FPU