Index: compiler-rt/trunk/lib/msan/tests/msan_test.cc =================================================================== --- compiler-rt/trunk/lib/msan/tests/msan_test.cc +++ compiler-rt/trunk/lib/msan/tests/msan_test.cc @@ -2869,8 +2869,13 @@ const char *last_slash = strrchr(program_path, '/'); ASSERT_NE(nullptr, last_slash); size_t dir_len = (size_t)(last_slash - program_path); - +#if defined(__x86_64__) static const char basename[] = "libmsan_loadable.x86_64.so"; +#elif defined(__MIPSEB__) || defined(MIPSEB) + static const char basename[] = "libmsan_loadable.mips64.so"; +#elif defined(__mips64) + static const char basename[] = "libmsan_loadable.mips64el.so"; +#endif int res = snprintf(buf, sz, "%.*s/%s", (int)dir_len, program_path, basename); ASSERT_GE(res, 0); @@ -2920,7 +2925,7 @@ // Regression test for a crash in dlopen() interceptor. TEST(MemorySanitizer, dlopenFailed) { - const char *path = "/libmsan_loadable_does_not_exist.x86_64.so"; + const char *path = "/libmsan_loadable_does_not_exist.so"; void *lib = dlopen(path, RTLD_LAZY); ASSERT_TRUE(lib == NULL); } Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc @@ -2297,7 +2297,8 @@ POST_SYSCALL(ni_syscall)(long res) {} PRE_SYSCALL(ptrace)(long request, long pid, long addr, long data) { -#if !SANITIZER_ANDROID && (defined(__i386) || defined (__x86_64)) +#if !SANITIZER_ANDROID && \ + (defined(__i386) || defined(__x86_64) || defined(__mips64)) if (data) { if (request == ptrace_setregs) { PRE_READ((void *)data, struct_user_regs_struct_sz); @@ -2316,7 +2317,8 @@ } POST_SYSCALL(ptrace)(long res, long request, long pid, long addr, long data) { -#if !SANITIZER_ANDROID && (defined(__i386) || defined (__x86_64)) +#if !SANITIZER_ANDROID && \ + (defined(__i386) || defined(__x86_64) || defined(__mips64)) if (res >= 0 && data) { // Note that this is different from the interceptor in // sanitizer_common_interceptors.inc. Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -127,7 +127,7 @@ #define SANITIZER_INTERCEPT_READDIR SI_NOT_WINDOWS #define SANITIZER_INTERCEPT_READDIR64 SI_LINUX_NOT_ANDROID #define SANITIZER_INTERCEPT_PTRACE SI_LINUX_NOT_ANDROID && \ - (defined(__i386) || defined (__x86_64)) // NOLINT + (defined(__i386) || defined (__x86_64) || defined (__mips64)) // NOLINT #define SANITIZER_INTERCEPT_SETLOCALE SI_NOT_WINDOWS #define SANITIZER_INTERCEPT_GETCWD SI_NOT_WINDOWS #define SANITIZER_INTERCEPT_GET_CURRENT_DIR_NAME SI_LINUX_NOT_ANDROID Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -695,7 +695,7 @@ #endif #if SANITIZER_LINUX && !SANITIZER_ANDROID && \ - (defined(__i386) || defined(__x86_64)) + (defined(__i386) || defined(__x86_64) || defined(__mips64)) extern unsigned struct_user_regs_struct_sz; extern unsigned struct_user_fpregs_struct_sz; extern unsigned struct_user_fpxregs_struct_sz; Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc @@ -116,6 +116,9 @@ #if SANITIZER_LINUX || SANITIZER_FREEBSD # include # include +# if defined(__mips64) +# include +# endif #endif #if !SANITIZER_ANDROID @@ -139,6 +142,9 @@ #include #include #include +#if defined(__mips64) +# include +#endif #include #include #include @@ -283,14 +289,19 @@ #endif #if SANITIZER_LINUX && !SANITIZER_ANDROID && \ - (defined(__i386) || defined(__x86_64)) + (defined(__i386) || defined(__x86_64) || defined(__mips64)) +#if defined(__mips64) + unsigned struct_user_regs_struct_sz = sizeof(struct pt_regs); + unsigned struct_user_fpregs_struct_sz = sizeof(elf_fpregset_t); +#else unsigned struct_user_regs_struct_sz = sizeof(struct user_regs_struct); unsigned struct_user_fpregs_struct_sz = sizeof(struct user_fpregs_struct); -#ifdef __x86_64 +#endif // __mips64 +#if (defined(__x86_64) || defined(__mips64)) unsigned struct_user_fpxregs_struct_sz = 0; #else unsigned struct_user_fpxregs_struct_sz = sizeof(struct user_fpxregs_struct); -#endif +#endif // __x86_64 || __mips64 int ptrace_peektext = PTRACE_PEEKTEXT; int ptrace_peekdata = PTRACE_PEEKDATA; Index: compiler-rt/trunk/test/msan/mmap_below_shadow.cc =================================================================== --- compiler-rt/trunk/test/msan/mmap_below_shadow.cc +++ compiler-rt/trunk/test/msan/mmap_below_shadow.cc @@ -15,8 +15,13 @@ int main(void) { // Hint address just below shadow. +#if defined(__x86_64__) uintptr_t hint = 0x4f0000000000ULL; const uintptr_t app_start = 0x600000000000ULL; +#elif defined (__mips64) + uintptr_t hint = 0x4f00000000ULL; + const uintptr_t app_start = 0x6000000000ULL; +#endif uintptr_t p = (uintptr_t)mmap( (void *)hint, 4096, PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | (FIXED ? MAP_FIXED : 0), -1, 0); Index: compiler-rt/trunk/test/msan/strlen_of_shadow.cc =================================================================== --- compiler-rt/trunk/test/msan/strlen_of_shadow.cc +++ compiler-rt/trunk/test/msan/strlen_of_shadow.cc @@ -9,7 +9,11 @@ #include const char *mem_to_shadow(const char *p) { +#if defined(__x86_64__) return (char *)((uintptr_t)p & ~0x400000000000ULL); +#elif defined (__mips64) + return (char *)((uintptr_t)p & ~0x4000000000ULL); +#endif } int main(void) { Index: compiler-rt/trunk/test/msan/vector_select.cc =================================================================== --- compiler-rt/trunk/test/msan/vector_select.cc +++ compiler-rt/trunk/test/msan/vector_select.cc @@ -4,10 +4,18 @@ // Regression test for MemorySanitizer instrumentation of a select instruction // with vector arguments. +#if defined(__x86_64__) #include __m128d select(bool b, __m128d c, __m128d d) { return b ? c : d; } +#elif defined (__mips64) +typedef double __w64d __attribute__ ((vector_size(16))); +__w64d select(bool b, __w64d c, __w64d d) +{ + return b ? c : d; +} +#endif Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ptrace.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ptrace.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ptrace.cc @@ -8,6 +8,10 @@ #include #include #include +#if __mips64 + #include + #include +#endif int main(void) { pid_t pid; @@ -33,19 +37,23 @@ printf("%x\n", fpregs.mxcsr); #endif // __x86_64__ -#if __powerpc64__ +#if (__powerpc64__ || __mips64) struct pt_regs regs; res = ptrace((enum __ptrace_request)PTRACE_GETREGS, pid, NULL, ®s); assert(!res); +#if (__powerpc64__) if (regs.nip) printf("%lx\n", regs.nip); - +#else + if (regs.cp0_epc) + printf("%lx\n", regs.cp0_epc); +#endif elf_fpregset_t fpregs; res = ptrace((enum __ptrace_request)PTRACE_GETFPREGS, pid, NULL, &fpregs); assert(!res); if ((elf_greg_t)fpregs[32]) // fpscr printf("%lx\n", (elf_greg_t)fpregs[32]); -#endif // __powerpc64__ +#endif // (__powerpc64__ || __mips64) siginfo_t siginfo; res = ptrace(PTRACE_GETSIGINFO, pid, NULL, &siginfo);