diff --git a/0004-add-loongarch64-support.patch b/0004-add-loongarch64-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..58244ce9c419b8bc50cd0f9a1fa1e53733fac787 --- /dev/null +++ b/0004-add-loongarch64-support.patch @@ -0,0 +1,111 @@ +diff -Naru a/src/gcore.mk b/src/gcore.mk +--- a/src/gcore.mk 2024-11-21 03:10:28.072000000 +0000 ++++ b/src/gcore.mk 2024-11-21 03:11:06.920000000 +0000 +@@ -42,6 +42,12 @@ + ARCH=SUPPORTED + endif + ++ifeq ($(shell arch), loongarch64) ++ TARGET=loongarch64 ++ TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64 ++ ARCH=SUPPORTED ++endif ++ + ifeq ($(shell arch), mips) + TARGET=MIPS + TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64 +diff -Naru a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c +--- a/src/libgcore/gcore_coredump.c 2024-11-21 03:10:28.072000000 +0000 ++++ b/src/libgcore/gcore_coredump.c 2024-11-21 03:12:21.352000000 +0000 +@@ -889,7 +889,7 @@ + struct memelfnote *memnote) + { + struct elf_prstatus *prstatus; +-#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS) || defined(PPC64) || defined(RISCV64) ++#if defined(X86) || defined(X86_64) || defined(ARM) || defined(loongarch64) || defined(MIPS) || defined(PPC64) || defined(RISCV64) + struct user_regs_struct *regs = (struct user_regs_struct *)memnote->data; + #endif + #ifdef ARM64 +diff -Naru a/src/libgcore/gcore_defs.h b/src/libgcore/gcore_defs.h +--- a/src/libgcore/gcore_defs.h 2024-11-21 03:10:28.072000000 +0000 ++++ b/src/libgcore/gcore_defs.h 2024-11-21 03:14:38.792000000 +0000 +@@ -194,6 +194,26 @@ + #define Elf_Nhdr Elf64_Nhdr + #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 ++ + #ifndef NT_FILE + #define NT_FILE 0x46494c45 + #endif +@@ -347,6 +367,11 @@ + #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 +@@ -670,6 +695,24 @@ + #endif /* GCORE_ARCH_COMPAT */ + #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 MIPS + struct user_regs_struct { + unsigned long gregs[45]; +@@ -708,13 +751,13 @@ + }; + #endif + +-#if defined(X86) || defined(X86_64) || defined(ARM) || defined(MIPS) || defined(RISCV64) ++#if defined(X86) || defined(X86_64) || defined(ARM) || defined(loongarch64) || defined(MIPS) + 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]; + #endif + +-#if defined(X86) || defined(ARM) || defined(MIPS) ++#if defined(X86) || defined(ARM) || defined(loongarch64) || defined(MIPS) + #define PAGE_SIZE 4096 + #endif + #if defined(ARM64) || defined(PPC64) || defined(RISCV64) diff --git a/crash-gcore-command.spec b/crash-gcore-command.spec index ca684008f5fe807e21ffe988e9e583d90ffaf0c3..ff650f81d5df28ceb416a9c32c0f6c686eaa7eee 100644 --- a/crash-gcore-command.spec +++ b/crash-gcore-command.spec @@ -1,7 +1,7 @@ %global reponame crash-gcore Name: crash-gcore-command Version: 1.6.4 -Release: 3 +Release: 5 Summary: Command of Gcore for Crash utility License: GPLv2 @@ -14,10 +14,9 @@ Requires: crash >= 5.1.5 Patch0: crash-gcore-1.6.4-coredump-fix-building-failure-due-to-undefined-macro.patch Patch1: 0001-add-stdbool.h-to-fix-build-error.patch -%ifarch riscv64 Patch2: 0002-add-riscv64-support.patch -%endif Patch3: 0003-support-clang-build.patch +Patch4: 0004-add-loongarch64-support.patch %description The crash-gcore-command packages contain an extension module for the crash utility @@ -39,6 +38,12 @@ install -D %{_builddir}/%{reponame}-%{version}/src/gcore.so %{buildroot}%{_libdi %{_libdir}/crash/extensions/gcore.so %changelog +* Thu Nov 21 2024 Jia Chao - 1.6.4-5 +- Add loongarch64 support. + +* Thu Nov 21 2024 Jia Chao - 1.6.4-4 +- Always apply riscv64 patch, so the same source code support for multiple architectures. + * Fri Mar 1 2024 luofeng - 1.6.4-3 - support clang build