diff --git a/0003-add-sw_64-support-not-upstream-modified.patch b/0003-add-sw_64-support-not-upstream-modified.patch new file mode 100644 index 0000000000000000000000000000000000000000..e1b39b638210176c76a4fda3304f28c53b0197fb --- /dev/null +++ b/0003-add-sw_64-support-not-upstream-modified.patch @@ -0,0 +1,130 @@ +diff --git a/configure b/configure +index 583efbc..1bd90c5 100755 +--- a/configure ++++ b/configure +@@ -67,9 +67,14 @@ case `uname -m` in + machine="riscv" + CFLAGS="$CFLAGS -DMLX_RISCV64" + ;; ++'sw_64') ++ machine="sw_64" ++ CFLAGS="$CFLAGS -DMLX_SW_64" ++ LDFLAGS="$LDFLAGS -llzma" ++ ;; + *) + echo "Error: unsupported machine: `uname -m`." +- echo "Only x86, x86_64, arm, loongarch, riscv and aarch64 are supported." ++ echo "Only x86, x86_64, arm, loongarch, riscv, sw_64 and aarch64 are supported." + exit 2 + ;; + esac +diff --git a/machines.h b/machines.h +index c92da46..97eb696 100644 +--- a/machines.h ++++ b/machines.h +@@ -206,6 +206,35 @@ static inline int is_breakpoint(pid_t pid, uintptr_t address) + { + return ptrace_get_data(pid, address) == 0x00100073; + } ++#elif defined(MLX_SW_64) ++static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs) ++{ ++ return regs->regs[30]; ++} ++static inline uintptr_t call_return_value(registers_info_t *regs) ++{ ++ return regs->regs[0]; ++} ++static inline uintptr_t call_arg1(pid_t pid, registers_info_t *regs) ++{ ++ return regs->regs[0]; ++} ++static inline uintptr_t call_arg2(pid_t pid, registers_info_t *regs) ++{ ++ return regs->regs[1]; ++} ++static inline uintptr_t pc_unwind(pid_t pid, registers_info_t *regs) ++{ ++ return regs->pc; ++} ++static inline void set_breakpoint(pid_t pid, uintptr_t address, uintptr_t code) ++{ ++ ptrace_set_data(pid, address, 0x00000080); ++} ++static inline int is_breakpoint(pid_t pid, uintptr_t address) ++{ ++ return ptrace_get_data(pid, address) == 0x00000080; ++} + #endif + + #endif +diff --git a/ptrace_utils.h b/ptrace_utils.h +index a9ef0f4..9a10327 100644 +--- a/ptrace_utils.h ++++ b/ptrace_utils.h +@@ -17,8 +17,65 @@ + #include + #include + #include ++ ++#ifdef MLX_SW_64 ++#ifndef __ASSEMBLY__ ++ ++struct pt_regs { ++ union { ++ struct user_pt_regs user_regs; ++ struct { ++ unsigned long r0; ++ unsigned long r1; ++ unsigned long r2; ++ unsigned long r3; ++ unsigned long r4; ++ unsigned long r5; ++ unsigned long r6; ++ unsigned long r7; ++ unsigned long r8; ++ unsigned long r9; ++ unsigned long r10; ++ unsigned long r11; ++ unsigned long r12; ++ unsigned long r13; ++ unsigned long r14; ++ unsigned long r15; ++ unsigned long r16; ++ unsigned long r17; ++ unsigned long r18; ++ unsigned long r19; ++ unsigned long r20; ++ unsigned long r21; ++ unsigned long r22; ++ unsigned long r23; ++ unsigned long r24; ++ unsigned long r25; ++ unsigned long r26; ++ unsigned long r27; ++ unsigned long r28; ++ unsigned long gp; ++ unsigned long sp; ++ unsigned long pc; ++ unsigned long ps; ++ }; ++ }; ++ /* These are saved by HMcode: */ ++ unsigned long hm_ps; ++ unsigned long hm_pc; ++ unsigned long hm_gp; ++ unsigned long hm_r16; ++ unsigned long hm_r17; ++ unsigned long hm_r18; ++}; ++ ++#endif ++#endif ++ + #ifdef MLX_ARMv7 + typedef struct user_regs registers_info_t; ++ #elif (defined MLX_SW_64) ++typedef struct user_pt_regs registers_info_t; + #else + typedef struct user_regs_struct registers_info_t; + #endif diff --git a/memleax.spec b/memleax.spec index c6c004b13d1e4885a0a9fe903289941560581730..91302a186d24ffe5f3e47d81a2040947c8c59a86 100644 --- a/memleax.spec +++ b/memleax.spec @@ -1,12 +1,13 @@ Name: memleax Version: 1.1.1 -Release: 8 +Release: 9 Summary: Memory lead detection tool License: GPLv2 URL: https://github.com/WuBingzheng/memleax Source0: https://github.com/WuBingzheng/memleax/archive/v%{version}.tar.gz#/memleax-%{version}.tar.gz Patch0: 0001-add-loongarch64-support.patch Patch1: 0002-add-riscv64-support.patch +Patch2: 0003-add-sw_64-support-not-upstream-modified.patch BuildRequires: make libunwind-devel elfutils-devel gcc @@ -49,6 +50,9 @@ make install DESTDIR="%{buildroot}" %{_mandir}/man1/%{name}.1* %changelog +* Mon Feb 17 2025 maqi - 1.1.1-9 +- add support sw_64 + * Tue May 14 2024 wangshuo - 1.1.1-8 - Resolve compilation errors for loongarch64