From a045fd8aededbe15339bc067c1b68a75ea8b9679 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Fri, 29 Nov 2024 19:49:16 +0100 Subject: [PATCH 27/30] 32-bit musl sanitizer fixes --- .../lib/sanitizer_common/sanitizer_linux.cpp | 48 ++++------------------- 1 file changed, 7 insertions(+), 41 deletions(-) --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp @@ -344,25 +344,6 @@ uptr internal_ftruncate(fd_t fd, uptr size) { return res; } -# if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && SANITIZER_LINUX -static void stat64_to_stat(struct stat64 *in, struct stat *out) { - internal_memset(out, 0, sizeof(*out)); - out->st_dev = in->st_dev; - out->st_ino = in->st_ino; - out->st_mode = in->st_mode; - out->st_nlink = in->st_nlink; - out->st_uid = in->st_uid; - out->st_gid = in->st_gid; - out->st_rdev = in->st_rdev; - out->st_size = in->st_size; - out->st_blksize = in->st_blksize; - out->st_blocks = in->st_blocks; - out->st_atime = in->st_atime; - out->st_mtime = in->st_mtime; - out->st_ctime = in->st_ctime; -} -# endif - # if SANITIZER_LINUX && defined(__loongarch__) static void statx_to_stat(struct statx *in, struct stat *out) { internal_memset(out, 0, sizeof(*out)); @@ -462,17 +443,11 @@ uptr internal_stat(const char *path, void *buf) { kernel_stat_to_stat(&buf64, (struct stat *)buf); return res; # else - struct stat64 buf64; - int res = internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, - (uptr)&buf64, 0); - stat64_to_stat(&buf64, (struct stat *)buf); - return res; + return internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, (uptr)buf, + 0); # endif # else - struct stat64 buf64; - int res = internal_syscall(SYSCALL(stat64), path, &buf64); - stat64_to_stat(&buf64, (struct stat *)buf); - return res; + return internal_syscall(SYSCALL(stat64), path, (uptr)buf); # endif } @@ -501,17 +476,11 @@ uptr internal_lstat(const char *path, void *buf) { kernel_stat_to_stat(&buf64, (struct stat *)buf); return res; # else - struct stat64 buf64; - int res = internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, - (uptr)&buf64, AT_SYMLINK_NOFOLLOW); - stat64_to_stat(&buf64, (struct stat *)buf); - return res; + return internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, (uptr)buf, + AT_SYMLINK_NOFOLLOW); # endif # else - struct stat64 buf64; - int res = internal_syscall(SYSCALL(lstat64), path, &buf64); - stat64_to_stat(&buf64, (struct stat *)buf); - return res; + return internal_syscall(SYSCALL(lstat64), path, (uptr)buf); # endif } @@ -539,10 +508,7 @@ uptr internal_fstat(fd_t fd, void *buf) { return internal_syscall(SYSCALL(fstat), fd, (uptr)buf); # endif # else - struct stat64 buf64; - int res = internal_syscall(SYSCALL(fstat64), fd, &buf64); - stat64_to_stat(&buf64, (struct stat *)buf); - return res; + return internal_syscall(SYSCALL(fstat64), fd, (uptr)buf); # endif }