0027-32-bit-musl-sanitizer-fixes.patch (3308B)
1 From aef527f16bc8cf69f5253691c807881538597d5f Mon Sep 17 00:00:00 2001 2 From: Erica Z <zerica@callcc.eu> 3 Date: Fri, 29 Nov 2024 19:49:16 +0100 4 Subject: [PATCH 27/29] 32-bit musl sanitizer fixes 5 6 --- 7 .../lib/sanitizer_common/sanitizer_linux.cpp | 48 +++---------------- 8 1 file changed, 7 insertions(+), 41 deletions(-) 9 10 diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp 11 index a782d5221..6ebf10aa6 100644 12 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp 13 +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp 14 @@ -329,25 +329,6 @@ uptr internal_ftruncate(fd_t fd, uptr size) { 15 return res; 16 } 17 18 -# if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && SANITIZER_LINUX 19 -static void stat64_to_stat(struct stat64 *in, struct stat *out) { 20 - internal_memset(out, 0, sizeof(*out)); 21 - out->st_dev = in->st_dev; 22 - out->st_ino = in->st_ino; 23 - out->st_mode = in->st_mode; 24 - out->st_nlink = in->st_nlink; 25 - out->st_uid = in->st_uid; 26 - out->st_gid = in->st_gid; 27 - out->st_rdev = in->st_rdev; 28 - out->st_size = in->st_size; 29 - out->st_blksize = in->st_blksize; 30 - out->st_blocks = in->st_blocks; 31 - out->st_atime = in->st_atime; 32 - out->st_mtime = in->st_mtime; 33 - out->st_ctime = in->st_ctime; 34 -} 35 -# endif 36 - 37 # if SANITIZER_LINUX && defined(__loongarch__) 38 static void statx_to_stat(struct statx *in, struct stat *out) { 39 internal_memset(out, 0, sizeof(*out)); 40 @@ -447,17 +428,11 @@ uptr internal_stat(const char *path, void *buf) { 41 kernel_stat_to_stat(&buf64, (struct stat *)buf); 42 return res; 43 # else 44 - struct stat64 buf64; 45 - int res = internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, 46 - (uptr)&buf64, 0); 47 - stat64_to_stat(&buf64, (struct stat *)buf); 48 - return res; 49 + return internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, (uptr)buf, 50 + 0); 51 # endif 52 # else 53 - struct stat64 buf64; 54 - int res = internal_syscall(SYSCALL(stat64), path, &buf64); 55 - stat64_to_stat(&buf64, (struct stat *)buf); 56 - return res; 57 + return internal_syscall(SYSCALL(stat64), path, (uptr)buf); 58 # endif 59 } 60 61 @@ -486,17 +461,11 @@ uptr internal_lstat(const char *path, void *buf) { 62 kernel_stat_to_stat(&buf64, (struct stat *)buf); 63 return res; 64 # else 65 - struct stat64 buf64; 66 - int res = internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, 67 - (uptr)&buf64, AT_SYMLINK_NOFOLLOW); 68 - stat64_to_stat(&buf64, (struct stat *)buf); 69 - return res; 70 + return internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, (uptr)buf, 71 + AT_SYMLINK_NOFOLLOW); 72 # endif 73 # else 74 - struct stat64 buf64; 75 - int res = internal_syscall(SYSCALL(lstat64), path, &buf64); 76 - stat64_to_stat(&buf64, (struct stat *)buf); 77 - return res; 78 + return internal_syscall(SYSCALL(lstat64), path, (uptr)buf); 79 # endif 80 } 81 82 @@ -524,10 +493,7 @@ uptr internal_fstat(fd_t fd, void *buf) { 83 return internal_syscall(SYSCALL(fstat), fd, (uptr)buf); 84 # endif 85 # else 86 - struct stat64 buf64; 87 - int res = internal_syscall(SYSCALL(fstat64), fd, &buf64); 88 - stat64_to_stat(&buf64, (struct stat *)buf); 89 - return res; 90 + return internal_syscall(SYSCALL(fstat64), fd, (uptr)buf); 91 # endif 92 } 93 94 -- 95 2.49.0 96