Index: lib/sanitizer_common/sanitizer_linux.cc =================================================================== --- lib/sanitizer_common/sanitizer_linux.cc +++ lib/sanitizer_common/sanitizer_linux.cc @@ -178,6 +178,26 @@ } #endif +#ifdef __mips64 +void kernel_stat_to_stat(struct kernel_stat *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_sec; + out->st_mtime = in->st_mtime_sec; + out->st_ctime = in->st_ctime_sec; + out->st_ino = in->st_ino; +} +#endif + uptr internal_stat(const char *path, void *buf) { #if SANITIZER_FREEBSD return internal_syscall(SYSCALL(stat), path, buf); @@ -201,7 +221,15 @@ return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (uptr)buf, AT_SYMLINK_NOFOLLOW); #elif SANITIZER_LINUX_USES_64BIT_SYSCALLS - return internal_syscall(SYSCALL(lstat), (uptr)path, (uptr)buf); + #ifdef __mips64 + // For MIPS, syscall stat puts values in structure kerenl_stat form + struct kernel_stat kbuf; + int res = internal_syscall(SYSCALL(stat), path, &kbuf); + kernel_stat_to_stat(&kbuf, (struct stat *)buf); + return res; + #else + return internal_syscall(SYSCALL(stat), (uptr)path, (uptr)buf); + #endif #else struct stat64 buf64; int res = internal_syscall(SYSCALL(lstat64), path, &buf64); Index: lib/sanitizer_common/sanitizer_platform.h =================================================================== --- lib/sanitizer_common/sanitizer_platform.h +++ lib/sanitizer_common/sanitizer_platform.h @@ -117,4 +117,28 @@ # define SANITIZER_POINTER_FORMAT_LENGTH FIRST_32_SECOND_64(8, 12) #endif +#ifdef __mips64 + struct kernel_stat { + unsigned int st_dev; + unsigned int __pad1[3]; + unsigned long long st_ino; + unsigned int st_mode; + unsigned int st_nlink; + int st_uid; + int st_gid; + unsigned int st_rdev; + unsigned int __pad2[3]; + long long st_size; + unsigned int st_atime_sec; + unsigned int st_atime_nsec; + unsigned int st_mtime_sec; + unsigned int st_mtime_nsec; + unsigned int st_ctime_sec; + unsigned int st_ctime_nsec; + unsigned int st_blksize; + unsigned int __pad3; + unsigned long long st_blocks; + }; +#endif + #endif // SANITIZER_PLATFORM_H