From aef527f16bc8cf69f5253691c807881538597d5f Mon Sep 17 00:00:00 2001 From: Erica Z Date: Fri, 29 Nov 2024 19:49:16 +0100 Subject: [PATCH 27/29] 32-bit musl sanitizer fixes --- .../lib/sanitizer_common/sanitizer_linux.cpp | 48 +++---------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp index a782d5221..6ebf10aa6 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp @@ -329,25 +329,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)); @@ -447,17 +428,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 } @@ -486,17 +461,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 } @@ -524,10 +493,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 } -- 2.49.0