From: Paul F. <pa...@so...> - 2025-07-19 20:19:12
|
https://sourceware.org/cgit/valgrind/commit/?id=3c78edc2da61abfdbb494ec0437ca7ecafc3f278 commit 3c78edc2da61abfdbb494ec0437ca7ecafc3f278 Author: Paul Floyd <pj...@wa...> Date: Sat Jul 19 22:13:15 2025 +0200 Linux arm64 and riscv64: for build for VG_(lstat) These 'new' architectures don't have 'old' syscalls like __NR_lstat so use __NR_newfstatat instead. Also modify the oen_client testcase so that it checks for the 'old' open syscall. Diff: --- coregrind/m_libcfile.c | 25 +++++++++++++++++++++---- none/tests/linux/open_client.cpp | 4 ++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c index ff1ead4e71..6addb87610 100644 --- a/coregrind/m_libcfile.c +++ b/coregrind/m_libcfile.c @@ -680,17 +680,34 @@ SysRes VG_(lstat) ( const HChar* file_name, struct vg_stat* vgbuf ) SysRes res; VG_(memset)(vgbuf, 0, sizeof(*vgbuf)); -#if !defined(VGO_freebsd) || (__FreeBSD_version < 1200031) -#if defined(VGO_freebsd) - struct vki_freebsd11_stat buf; +#if defined(VGO_linux) + +struct vki_stat buf; + +#if defined(__NR_newfstatat) + res = VG_(do_syscall4)(__NR_newfstatat, VKI_AT_FDCWD, (UWord)file_name, (UWord)&buf, VKI_AT_SYMLINK_NOFOLLOW); #else - struct vki_stat buf; + res = VG_(do_syscall2)(__NR_lstat, (UWord)file_name, (UWord)&buf); #endif + +#elif defined(VGO_freebsd) + +#if (__FreeBSD_version < 1200031) + struct vki_freebsd11_stat buf; res = VG_(do_syscall2)(__NR_lstat, (UWord)file_name, (UWord)&buf); #else struct vki_stat buf; res = VG_(do_syscall4)(__NR_fstatat, VKI_AT_FDCWD, (UWord)file_name, (UWord)&buf, VKI_AT_SYMLINK_NOFOLLOW); #endif + +#else + + /* check this on illumos and Darwin */ + struct vki_stat buf; + res = VG_(do_syscall2)(__NR_lstat, (UWord)file_name, (UWord)&buf); + +#endif + if (!sr_isError(res)) { TRANSLATE_TO_vg_stat(vgbuf, &buf); } diff --git a/none/tests/linux/open_client.cpp b/none/tests/linux/open_client.cpp index 4b336e7f02..2052286d49 100644 --- a/none/tests/linux/open_client.cpp +++ b/none/tests/linux/open_client.cpp @@ -36,6 +36,7 @@ int main(int argc, char** argv) } } +#if defined(SYS_open) for (auto f : flags) { int res = syscall(SYS_open, n.c_str(), f, 0666); @@ -52,6 +53,7 @@ int main(int argc, char** argv) } } } +#endif } if ((dotdot = open("..", O_DIRECTORY | O_RDONLY)) == -1) @@ -154,6 +156,7 @@ int main(int argc, char** argv) } } +#if defined(SYS_open) for (auto f : flags) { int res = syscall(SYS_open, "linux/open_client", f, 0666); @@ -169,6 +172,7 @@ int main(int argc, char** argv) } } } +#endif #if defined(SYS_openat2) for (auto f : flags) |