From 90517b9f11d66de80a5df828d80ef0047fc984d8 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Thu, 9 Nov 2023 19:16:45 +0800 Subject: [PATCH] coredump:support arm64 coredump Signed-off-by: anjiahao --- arch/arm64/Kconfig | 1 + arch/arm64/include/elf.h | 20 ++++++++++++++++++++ binfmt/libelf/libelf_coredump.c | 8 ++++---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index e5eff102ea718..a37e03aa694ba 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -71,6 +71,7 @@ config ARCH_CHIP_GOLDFISH select ARCH_HAVE_POWEROFF select ARCH_HAVE_RESET select ARCH_NEED_ADDRENV_MAPPING + select LIBC_ARCH_ELF_64BIT if LIBC_ARCH_ELF ---help--- Android GoldFish platform for NuttX (ARMv8a), based on ARM virt board diff --git a/arch/arm64/include/elf.h b/arch/arm64/include/elf.h index 7a7b9ea231807..289284973910e 100644 --- a/arch/arm64/include/elf.h +++ b/arch/arm64/include/elf.h @@ -25,6 +25,12 @@ #ifndef __ARCH_ARM64_INCLUDE_ELF_H #define __ARCH_ARM64_INCLUDE_ELF_H +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + /**************************************************************************** * Pre-processor Prototypes ****************************************************************************/ @@ -206,10 +212,24 @@ #define PT_AARCH64_ARCHEXT 0x70000000 /* Reserved for architecture compatibility information */ #define PT_AARCH64_UNWIND 0x70000001 /* Reserved for exception unwinding tables */ +#define EF_FLAG 0 + /**************************************************************************** * Public Types ****************************************************************************/ +typedef unsigned long elf_greg_t; +struct user_pt_regs +{ + uint64_t regs[31]; + uint64_t sp; + uint64_t pc; + uint64_t pstate; +}; + +#define ELF_NGREG (sizeof(struct user_pt_regs) / sizeof(elf_greg_t)) +typedef elf_greg_t elf_gregset_t[ELF_NGREG]; + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/binfmt/libelf/libelf_coredump.c b/binfmt/libelf/libelf_coredump.c index 006d43a6b0211..004d33fee13fe 100644 --- a/binfmt/libelf/libelf_coredump.c +++ b/binfmt/libelf/libelf_coredump.c @@ -231,7 +231,7 @@ static void elf_emit_tcb_note(FAR struct elf_dumpinfo_s *cinfo, char name[ROUNDUP(CONFIG_TASK_NAME_SIZE, 8)]; elf_prstatus_t status; elf_prpsinfo_t info; - FAR uint32_t *regs; + FAR uintptr_t *regs; Elf_Nhdr nhdr; int i; @@ -267,17 +267,17 @@ static void elf_emit_tcb_note(FAR struct elf_dumpinfo_s *cinfo, { if (up_interrupt_context()) { - regs = (FAR uint32_t *)CURRENT_REGS; + regs = (FAR uintptr_t *)CURRENT_REGS; } else { up_saveusercontext(g_running_regs); - regs = (FAR uint32_t *)g_running_regs; + regs = (FAR uintptr_t *)g_running_regs; } } else { - regs = tcb->xcp.regs; + regs = (uintptr_t *)tcb->xcp.regs; } if (regs != NULL)