From 7fd1899ed6fe950a95d4e52e43f47e87a39c8a3b Mon Sep 17 00:00:00 2001 From: Jia Chao Date: Thu, 21 Nov 2024 03:07:54 +0000 Subject: [PATCH 1/2] Always apply riscv64 patch, so the same source code support for multiple architectures Signed-off-by: Jia Chao (cherry picked from commit b39680dcb0da636824980e90f7758d3f349592ba) --- crash-gcore-command.spec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crash-gcore-command.spec b/crash-gcore-command.spec index ca68400..cebbb70 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: 4 Summary: Command of Gcore for Crash utility License: GPLv2 @@ -14,9 +14,7 @@ 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 %description @@ -39,6 +37,9 @@ 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-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 -- Gitee From 16ada664c0ef0b18ca854cc8f91713c2c759ef18 Mon Sep 17 00:00:00 2001 From: Jia Chao Date: Thu, 21 Nov 2024 03:18:47 +0000 Subject: [PATCH 2/2] Add loongarch64 support Signed-off-by: Jia Chao (cherry picked from commit b1e2816befeed851ef87a7ad9be311d9f3304071) --- 0004-add-loongarch64-support.patch | 111 +++++++++++++++++++++++++++++ crash-gcore-command.spec | 6 +- 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 0004-add-loongarch64-support.patch diff --git a/0004-add-loongarch64-support.patch b/0004-add-loongarch64-support.patch new file mode 100644 index 0000000..58244ce --- /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 cebbb70..ff650f8 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: 4 +Release: 5 Summary: Command of Gcore for Crash utility License: GPLv2 @@ -16,6 +16,7 @@ Patch0: crash-gcore-1.6.4-coredump-fix-building-failure-due-to-undefined-macro.p Patch1: 0001-add-stdbool.h-to-fix-build-error.patch Patch2: 0002-add-riscv64-support.patch 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 @@ -37,6 +38,9 @@ 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. -- Gitee