fix(main/valgrind): x86_64 syscall patch (#19741)

This commit is contained in:
Jia Yuan Lo 2024-04-12 20:57:31 +08:00 committed by GitHub
parent 31214195a2
commit 7400b66030
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 59 additions and 9 deletions

View File

@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Instrumentation framework for building dynamic analysis
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="3.22.0"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=http://sourceware.org/pub/valgrind/valgrind-${TERMUX_PKG_VERSION}.tar.bz2
TERMUX_PKG_SHA256=c811db5add2c5f729944caf47c4e7a65dcaabb9461e472b578765dd7bf6d2d4c
TERMUX_PKG_AUTO_UPDATE=true

View File

@ -1,6 +1,23 @@
diff -uNr valgrind-3.16.1/coregrind/m_aspacemgr/aspacemgr-common.c valgrind-3.16.1.mod/coregrind/m_aspacemgr/aspacemgr-common.c
--- ./coregrind/m_aspacemgr/aspacemgr-common.c.orig 2021-10-10 16:17:32.000000000 +0200
+++ ./coregrind/m_aspacemgr/aspacemgr-common.c 2022-01-02 11:31:30.967514202 +0100
--- a/coregrind/m_aspacemgr/aspacemgr-common.c
+++ b/coregrind/m_aspacemgr/aspacemgr-common.c
@@ -262,7 +262,7 @@
SysRes ML_(am_open) ( const HChar* pathname, Int flags, Int mode )
{
-# if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux)
+# if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux) || defined(__ANDROID__)
/* ARM64 wants to use __NR_openat rather than __NR_open. */
SysRes res = VG_(do_syscall4)(__NR_openat,
VKI_AT_FDCWD, (UWord)pathname, flags, mode);
@@ -291,7 +291,7 @@
Int ML_(am_readlink)(const HChar* path, HChar* buf, UInt bufsiz)
{
SysRes res;
-# if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux)
+# if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux) || defined(__ANDROID__)
res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD,
(UWord)path, (UWord)buf, bufsiz);
# elif defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd)
@@ -330,6 +330,7 @@
# if defined(VGO_linux) || defined(VGO_darwin)
SysRes res;
@ -17,11 +34,18 @@ diff -uNr valgrind-3.16.1/coregrind/m_aspacemgr/aspacemgr-common.c valgrind-3.16
# endif // VGO_linux only
# if defined(VGO_linux) && defined(__NR_fstat64)
diff -uNr valgrind-3.16.1/coregrind/m_libcfile.c valgrind-3.16.1.mod/coregrind/m_libcfile.c
--- valgrind-3.16.1/coregrind/m_libcfile.c 2019-12-27 16:51:44.000000000 +0200
+++ valgrind-3.16.1.mod/coregrind/m_libcfile.c 2020-10-01 18:20:40.369886417 +0300
@@ -364,7 +364,7 @@
--- a/coregrind/m_libcfile.c
+++ b/coregrind/m_libcfile.c
@@ -290,7 +290,7 @@
SysRes VG_(open) ( const HChar* pathname, Int flags, Int mode )
{
-# if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux)
+# if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux) || defined(__ANDROID__)
/* ARM64 wants to use __NR_openat rather than __NR_open. */
SysRes res = VG_(do_syscall4)(__NR_openat,
VKI_AT_FDCWD, (UWord)pathname, flags, mode);
@@ -511,7 +511,7 @@
SysRes res;
VG_(memset)(vgbuf, 0, sizeof(*vgbuf));
@ -30,7 +54,20 @@ diff -uNr valgrind-3.16.1/coregrind/m_libcfile.c valgrind-3.16.1.mod/coregrind/m
/* On Linux, first try with statx. If that doesn't work out, fall back to
the stat64 or vanilla version. */
{ struct vki_statx buf;
@@ -434,7 +434,7 @@
@@ -546,6 +546,12 @@
# if defined(VGP_arm64_linux)
res = VG_(do_syscall3)(__NR3264_fstatat, VKI_AT_FDCWD,
(UWord)file_name, (UWord)&buf);
+# elif defined(__NR_newfstatat)
+ res = VG_(do_syscall3)(__NR_newfstatat, VKI_AT_FDCWD,
+ (UWord)file_name, (UWord)&buf);
+# elif defined(__NR_fstatat64)
+ res = VG_(do_syscall3)(__NR_fstatat64, VKI_AT_FDCWD,
+ (UWord)file_name, (UWord)&buf);
# else
res = VG_(do_syscall2)(__NR_stat, (UWord)file_name, (UWord)&buf);
# endif
@@ -595,7 +601,7 @@
SysRes res;
VG_(memset)(vgbuf, 0, sizeof(*vgbuf));
@ -39,3 +76,15 @@ diff -uNr valgrind-3.16.1/coregrind/m_libcfile.c valgrind-3.16.1.mod/coregrind/m
/* On Linux, first try with statx. If that doesn't work out, fall back to
the fstat64 or vanilla version. */
{ struct vki_statx buf;
@@ -994,9 +1000,9 @@
UWord w = (irusr ? VKI_R_OK : 0)
| (iwusr ? VKI_W_OK : 0)
| (ixusr ? VKI_X_OK : 0);
-# if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux)
+# if defined(VGP_arm64_linux) || defined(VGP_nanomips_linux) || defined(__ANDROID__)
SysRes res = VG_(do_syscall3)(__NR_faccessat, VKI_AT_FDCWD, (UWord)path, w);
-# elif defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd)
+# elif defined(VGO_linux) && !defined(__ANDROID__) || defined(VGO_darwin) || defined(VGO_freebsd)
SysRes res = VG_(do_syscall2)(__NR_access, (UWord)path, w);
# elif defined(VGO_solaris)
SysRes res = VG_(do_syscall4)(__NR_faccessat, VKI_AT_FDCWD, (UWord)path,