From: Paul Floyd Date: Sat, 19 Jul 2025 20:13:15 +0000 (+0200) Subject: Linux arm64 and riscv64: for build for VG_(lstat) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c78edc2da61abfdbb494ec0437ca7ecafc3f278;p=thirdparty%2Fvalgrind.git 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 --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c index ff1ead4e7..6addb8761 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 4b336e7f0..2052286d4 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)