]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Linux arm64 and riscv64: for build for VG_(lstat)
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 19 Jul 2025 20:13:15 +0000 (22:13 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 19 Jul 2025 20:16:07 +0000 (22:16 +0200)
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.

coregrind/m_libcfile.c
none/tests/linux/open_client.cpp

index ff1ead4e71cc93ac682587cea99681ad5a25a489..6addb876106ad4468fa121cd0e0e4b8e1c5285a9 100644 (file)
@@ -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);
    }
index 4b336e7f0230b9015c8aaf38662507ae9579d062..2052286d4947aef4dcb4e933bed436a8afb0b935 100644 (file)
@@ -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)