!14 Add riscv64 support

From: @a-xiang-and-shanhaijing 
Reviewed-by: @overweight 
Signed-off-by: @overweight
This commit is contained in:
openeuler-ci-bot 2023-08-17 07:39:59 +00:00 committed by Gitee
commit e0f5e0952b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,78 @@
diff -ur memleax-1.1.1/configure memleax-1.1.1/configure
--- memleax-1.1.1/configure 2023-06-30 16:52:49.401032162 +0800
+++ memleax-1.1.1/configure 2023-06-30 16:56:52.793616961 +0800
@@ -63,9 +63,13 @@
machine="loongarch64"
CFLAGS="$CFLAGS -DMLX_LOONGARCH64"
;;
+'riscv64')
+ machine="riscv"
+ CFLAGS="$CFLAGS -DMLX_RISCV64"
+ ;;
*)
echo "Error: unsupported machine: `uname -m`."
- echo "Only x86, x86_64, arm, loongarch and aarch64 are supported."
+ echo "Only x86, x86_64, arm, loongarch, riscv and aarch64 are supported."
exit 2
;;
esac
@@ -159,7 +163,7 @@
cat << EOF > Makefile
CFLAGS = $CFLAGS -g -O2 -Wall
-LDLIBS = $LDLIBS
+LDLIBS = $LDLIBS -llzma
LDFLAGS = $LDFLAGS
PREFIX = $prefix
DESTDIR =
diff -ur memleax-1.1.1/machines.h memleax-1.1.1/machines.h
--- memleax-1.1.1/machines.h 2023-06-30 16:52:49.401032162 +0800
+++ memleax-1.1.1/machines.h 2023-06-30 16:30:58.889630806 +0800
@@ -177,6 +177,35 @@
{
return ptrace_get_data(pid, address) == 0xd4200000;
}
+#elif defined(MLX_RISCV64)
+static inline uintptr_t call_return_address(pid_t pid, registers_info_t *regs)
+{
+ return regs->ra;
+}
+static inline uintptr_t call_return_value(registers_info_t *regs)
+{
+ return regs->a0;
+}
+static inline uintptr_t call_arg1(pid_t pid, registers_info_t *regs)
+{
+ return regs->a0;
+}
+static inline uintptr_t call_arg2(pid_t pid, registers_info_t *regs)
+{
+ return regs->a1;
+}
+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, 0x00100073);
+}
+static inline int is_breakpoint(pid_t pid, uintptr_t address)
+{
+ return ptrace_get_data(pid, address) == 0x00100073;
+}
#endif
#endif
diff -ur memleax-1.1.1/ptrace_utils.h memleax-1.1.1/ptrace_utils.h
--- memleax-1.1.1/ptrace_utils.h 2018-01-04 06:05:08.000000000 +0800
+++ memleax-1.1.1/ptrace_utils.h 2023-06-30 16:31:47.693773352 +0800
@@ -16,7 +16,7 @@
#include <elf.h>
#include <sys/uio.h>
-
+#include <asm/ptrace.h>
#ifdef MLX_ARMv7
typedef struct user_regs registers_info_t;
#else

View File

@ -1,11 +1,12 @@
Name: memleax
Version: 1.1.1
Release: 6
Release: 7
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
BuildRequires: make libunwind-devel elfutils-devel gcc
@ -48,6 +49,9 @@ make install DESTDIR="%{buildroot}"
%{_mandir}/man1/%{name}.1*
%changelog
* Fri Jun 30 2023 zhangxiang <zhangxiang@iscas.ac.cn> - 1.1.1-7
- add riscv64 support
* Wed Dec 14 2022 doupengda <doupengda@loongson.cn> - 1.1.1-6
- add loongarch64 support