1 Star 0 Fork 16

haomi123/crash-gcore-command

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
add-loongarch-support.sh 3.83 KB
一键复制 编辑 原始数据 按行查看 历史
haomi123 提交于 2023-08-18 11:13 . add loongarch64 support
diff --git a/src/gcore.mk b/src/gcore.mk
index 4af292b..959ad25 100644
--- a/src/gcore.mk
+++ b/src/gcore.mk
@@ -60,6 +60,12 @@ ifeq ($(shell arch), ppc64le)
ARCH=SUPPORTED
endif
+ifeq ($(shell arch), loongarch64)
+ TARGET=loongarch64
+ TARGET_CFLAGS=
+ ARCH=SUPPORTED
+endif
+
ifeq ($(shell /bin/ls /usr/include/crash/defs.h 2>/dev/null), /usr/include/crash/defs.h)
INCDIR=/usr/include/crash
endif
diff --git a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c
index c14cc11..da85463 100644
--- a/src/libgcore/gcore_coredump.c
+++ b/src/libgcore/gcore_coredump.c
@@ -756,7 +756,7 @@ fill_prstatus_note(struct elf_note_info *info, struct task_context *tc,
struct memelfnote *memnote)
{
struct elf_prstatus *prstatus;
-#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS) || defined(PPC64)
+#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS) || defined(PPC64) || defined(__loongarch64)
struct user_regs_struct *regs = (struct user_regs_struct *)memnote->data;
#endif
#ifdef ARM64
diff --git a/src/libgcore/gcore_defs.h b/src/libgcore/gcore_defs.h
index 3233ea5..0462a0f 100644
--- a/src/libgcore/gcore_defs.h
+++ b/src/libgcore/gcore_defs.h
@@ -170,6 +170,26 @@
#define NT_FILE 0x46494c45
#endif
+#ifdef __loongarch64
+#define ELF_EXEC_PAGESIZE PAGESIZE()
+
+#define ELF_MACHINE EM_LOONGARCH
+#define ELF_OSABI ELFOSABI_NONE
+
+#define ELF_CLASS ELFCLASS64
+#define ELF_DATA ELFDATA2LSB
+#define ELF_ARCH EM_LOONGARCH
+
+#define Elf_Half Elf64_Half
+#define Elf_Word Elf64_Word
+#define Elf_Off Elf64_Off
+
+#define Elf_Ehdr Elf64_Ehdr
+#define Elf_Phdr Elf64_Phdr
+#define Elf_Shdr Elf64_Shdr
+#define Elf_Nhdr Elf64_Nhdr
+#endif
+
#define PAGE_ALIGN(X) roundup(X, ELF_EXEC_PAGESIZE)
#ifdef divideup
@@ -319,6 +339,11 @@ extern void gcore_default_regsets_init(void);
#define REGSET_VIEW_MACHINE EM_AARCH64
#endif
+#ifdef __loongarch64
+#define REGSET_VIEW_NAME "loongarch64"
+#define REGSET_VIEW_MACHINE EM_LOONGARCH
+#endif
+
#ifdef MIPS
#define REGSET_VIEW_NAME "mips"
#define REGSET_VIEW_MACHINE EM_MIPS
@@ -643,6 +668,24 @@ struct user_regs_struct {
};
#endif
+#ifdef __loongarch64
+struct user_regs_struct {
+ /* Saved main processor registers. */
+ unsigned long regs[32];
+
+ /* Saved special registers. */
+ unsigned long csr_crmd;
+ unsigned long csr_prmd;
+ unsigned long csr_euen;
+ unsigned long csr_ecfg;
+ unsigned long csr_estat;
+ unsigned long csr_epc;
+ unsigned long csr_badvaddr;
+ unsigned long orig_a0;
+ unsigned long __last[0];
+ } __attribute__ ((aligned (8)));
+#endif
+
#ifdef PPC64
/* taken from asm/ptrace.h */
struct user_regs_struct {
@@ -669,7 +712,7 @@ struct user_regs_struct {
};
#endif
-#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS)
+#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS) || defined(__loongarch64)
typedef ulong elf_greg_t;
#define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
@@ -678,7 +721,7 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
#if defined(X86) || defined(ARM) || defined(MIPS)
#define PAGE_SIZE 4096
#endif
-#if defined(ARM64) || defined(PPC64)
+#if defined(ARM64) || defined(PPC64) || defined(__loongarch64)
#define PAGE_SIZE PAGESIZE()
#endif
@@ -832,12 +875,12 @@ struct elf_prstatus
int pr_fpvalid; /* True if math co-processor being used. */
};
-#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS)
+#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS) || defined(__loongarch64)
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
#endif
-#if defined(X86_64) || defined(ARM64) || defined(PPC64)
+#if defined(X86_64) || defined(ARM64) || defined(PPC64) || defined(__loongarch64)
typedef unsigned int __kernel_uid_t;
typedef unsigned int __kernel_gid_t;
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/haomi0602/crash-gcore-command.git
git@gitee.com:haomi0602/crash-gcore-command.git
haomi0602
crash-gcore-command
crash-gcore-command
master

搜索帮助