!22 [sync] PR-20: 添加龙芯和申威架构支持
From: @openeuler-sync-bot Reviewed-by: @overweight Signed-off-by: @overweight
This commit is contained in:
commit
e6d5eb4fd8
74
1000-add-loongarch-support-not-upstream-modified.patch
Normal file
74
1000-add-loongarch-support-not-upstream-modified.patch
Normal file
@ -0,0 +1,74 @@
|
||||
From 3546fafed9fb09e653f72f5f47034d0eba97e270 Mon Sep 17 00:00:00 2001
|
||||
From: herengui <herengui@kylinsec.com.cn>
|
||||
Date: Tue, 16 May 2023 15:36:25 +0800
|
||||
Subject: [PATCH] add loongarch64 support
|
||||
|
||||
Signed-off-by: herengui <herengui@kylinsec.com.cn>
|
||||
---
|
||||
configure | 6 +++++-
|
||||
machines.h | 30 ++++++++++++++++++++++++++++++
|
||||
2 files changed, 35 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 7c7280f..60fd170 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -59,9 +59,13 @@ case `uname -m` in
|
||||
machine="aarch64"
|
||||
CFLAGS="$CFLAGS -DMLX_AARCH64"
|
||||
;;
|
||||
+'loongarch64')
|
||||
+ machine="loongarch64"
|
||||
+ CFLAGS="$CFLAGS -DMLX_LOONGARCH64"
|
||||
+ ;;
|
||||
*)
|
||||
echo "Error: unsupported machine: `uname -m`."
|
||||
- echo "Only x86, x86_64, arm, and aarch64 are supported."
|
||||
+ echo "Only x86, x86_64, arm, loongarch and aarch64 are supported."
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
diff --git a/machines.h b/machines.h
|
||||
index cbbe69d..477f060 100644
|
||||
--- a/machines.h
|
||||
+++ b/machines.h
|
||||
@@ -87,6 +87,36 @@ static inline int is_breakpoint(pid_t pid, uintptr_t address)
|
||||
return (ptrace_get_data(pid, address) & 0xFF) == 0xCC;
|
||||
}
|
||||
|
||||
+#elif defined(MLX_LOONGARCH64)
|
||||
+static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs)
|
||||
+{
|
||||
+ return ptrace_get_data(pid, regs->regs[3]);
|
||||
+}
|
||||
+static inline uintptr_t call_return_value(registers_info_t *regs)
|
||||
+{
|
||||
+ return regs->regs[1];
|
||||
+}
|
||||
+static inline uintptr_t call_arg1(pid_t pid, registers_info_t *regs)
|
||||
+{
|
||||
+ return regs->regs[6];
|
||||
+}
|
||||
+static inline uintptr_t call_arg2(pid_t pid, registers_info_t *regs)
|
||||
+{
|
||||
+ return regs->regs[7];
|
||||
+}
|
||||
+static inline uintptr_t pc_unwind(pid_t pid, registers_info_t *regs)
|
||||
+{
|
||||
+ return regs->csr_era;;
|
||||
+}
|
||||
+static inline void set_breakpoint(pid_t pid, uintptr_t address, uintptr_t code)
|
||||
+{
|
||||
+ ptrace_set_data(pid, address, (code & 0x002a0000));
|
||||
+}
|
||||
+static inline int is_breakpoint(pid_t pid, uintptr_t address)
|
||||
+{
|
||||
+ return ptrace_get_data(pid, address) == 0x002a0000;
|
||||
+}
|
||||
+
|
||||
#elif defined(MLX_ARMv7)
|
||||
static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs)
|
||||
{
|
||||
--
|
||||
2.40.1
|
||||
|
||||
153
1001-add-sw_64-support-not-upstream-modified.patch
Normal file
153
1001-add-sw_64-support-not-upstream-modified.patch
Normal file
@ -0,0 +1,153 @@
|
||||
From 2ffd47cc031947d85da9f2f11139b9bbadba5daa Mon Sep 17 00:00:00 2001
|
||||
From: herengui <herengui@kylinsec.com.cn>
|
||||
Date: Tue, 29 Aug 2023 13:53:15 +0800
|
||||
Subject: [PATCH] add sw_64 support not upstream modified
|
||||
|
||||
Signed-off-by: herengui <herengui@kylinsec.com.cn>
|
||||
---
|
||||
configure | 7 +++++-
|
||||
machines.h | 30 +++++++++++++++++++++++
|
||||
ptrace_utils.h | 65 +++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
3 files changed, 100 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 60fd170..a68210f 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -63,9 +63,14 @@ case `uname -m` in
|
||||
machine="loongarch64"
|
||||
CFLAGS="$CFLAGS -DMLX_LOONGARCH64"
|
||||
;;
|
||||
+'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 and aarch64 are supported."
|
||||
+ echo "Only x86, x86_64, arm, loongarch, sw_64 and aarch64 are supported."
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
diff --git a/machines.h b/machines.h
|
||||
index 477f060..24d8ce0 100644
|
||||
--- a/machines.h
|
||||
+++ b/machines.h
|
||||
@@ -117,6 +117,36 @@ static inline int is_breakpoint(pid_t pid, uintptr_t address)
|
||||
return ptrace_get_data(pid, address) == 0x002a0000;
|
||||
}
|
||||
|
||||
+#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;
|
||||
+}
|
||||
+
|
||||
#elif defined(MLX_ARMv7)
|
||||
static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs)
|
||||
{
|
||||
diff --git a/ptrace_utils.h b/ptrace_utils.h
|
||||
index 5fc1cd6..1a3b888 100644
|
||||
--- a/ptrace_utils.h
|
||||
+++ b/ptrace_utils.h
|
||||
@@ -17,8 +17,71 @@
|
||||
#include <elf.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
- #ifdef MLX_ARMv7
|
||||
+#ifdef MLX_SW_64
|
||||
+#ifndef __ASSEMBLY__
|
||||
+
|
||||
+typedef uint64_t __u64;
|
||||
+struct user_pt_regs {
|
||||
+ __u64 regs[31];
|
||||
+ __u64 pc;
|
||||
+ __u64 pstate;
|
||||
+};
|
||||
+
|
||||
+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
|
||||
+
|
||||
+ #if (defined 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
|
||||
--
|
||||
2.41.0
|
||||
|
||||
10
memleax.spec
10
memleax.spec
@ -1,11 +1,14 @@
|
||||
Name: memleax
|
||||
Version: 1.1.1
|
||||
Release: 4
|
||||
Release: 5
|
||||
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
|
||||
|
||||
Patch1000: 1000-add-loongarch-support-not-upstream-modified.patch
|
||||
Patch1001: 1001-add-sw_64-support-not-upstream-modified.patch
|
||||
|
||||
BuildRequires: make libunwind-devel elfutils-devel gdb gcc
|
||||
|
||||
%description
|
||||
@ -24,7 +27,7 @@ memleax follows new threads, but not forked processes.
|
||||
If you want to debug multiple processes, just run multiple memleax.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}/
|
||||
%autosetup -p1
|
||||
|
||||
%build
|
||||
./configure
|
||||
@ -46,6 +49,9 @@ make install DESTDIR="%{buildroot}"
|
||||
%{_mandir}/man1/%{name}.1*
|
||||
|
||||
%changelog
|
||||
* Tue Aug 29 2023 herengui <herengui@kylinsec.com.cn> - 1.1.1-5
|
||||
- add support for loongarch64 and sw_64
|
||||
|
||||
* Mon Jun 28 2021 wulei <wulei80@huawei.com> - 1.1.1-4
|
||||
- fix missing gcc
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user