Index: lib/sanitizer_common/sanitizer_linux.cc =================================================================== --- lib/sanitizer_common/sanitizer_linux.cc +++ lib/sanitizer_common/sanitizer_linux.cc @@ -592,7 +592,9 @@ // rt_sigaction, so we need to do the same (we'll need to reimplement the // restorers; for x86_64 the restorer address can be obtained from // oldact->sa_restorer upon a call to sigaction(xxx, NULL, oldact). +#if !(SANITIZER_ANDROID && defined(__mips__) && !defined(__mips64)) k_act.sa_restorer = u_act->sa_restorer; +#endif } uptr result = internal_syscall(SYSCALL(rt_sigaction), (uptr)signum, @@ -606,7 +608,9 @@ internal_memcpy(&u_oldact->sa_mask, &k_oldact.sa_mask, sizeof(__sanitizer_kernel_sigset_t)); u_oldact->sa_flags = k_oldact.sa_flags; +#if !(SANITIZER_ANDROID && defined(__mips__) && !defined(__mips64)) u_oldact->sa_restorer = k_oldact.sa_restorer; +#endif } return result; } Index: lib/sanitizer_common/sanitizer_linux_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -156,7 +156,8 @@ #endif } -#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO +#if !SANITIZER_FREEBSD && !(SANITIZER_ANDROID && !defined(__mips__)) \ + && !SANITIZER_GO static uptr g_tls_size; #endif Index: lib/sanitizer_common/sanitizer_platform_limits_posix.h =================================================================== --- lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -77,10 +77,18 @@ const unsigned struct_kernel_stat_sz = 144; const unsigned struct_kernel_stat64_sz = 104; #elif defined(__mips__) - #if SANITIZER_WORDSIZE == 64 - const unsigned struct_kernel_stat_sz = 216; + #if SANITIZER_ANDROID + #if SANITIZER_WORDSIZE == 64 + const unsigned struct_kernel_stat_sz = 128; + #else + const unsigned struct_kernel_stat_sz = 104; + #endif #else - const unsigned struct_kernel_stat_sz = 144; + #if SANITIZER_WORDSIZE == 64 + const unsigned struct_kernel_stat_sz = 216; + #else + const unsigned struct_kernel_stat_sz = 144; + #endif #endif const unsigned struct_kernel_stat64_sz = 104; #endif @@ -516,7 +524,11 @@ }; #if SANITIZER_ANDROID + #ifdef __mips__ + typedef unsigned long __sanitizer_sigset_t[16/sizeof(unsigned long)]; + #else typedef unsigned long __sanitizer_sigset_t; + #endif #elif SANITIZER_MAC typedef unsigned __sanitizer_sigset_t; #elif SANITIZER_LINUX @@ -532,7 +544,9 @@ #endif // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros. -#if SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 64) + +#if SANITIZER_ANDROID +#if SANITIZER_WORDSIZE == 64 || defined(__mips__) struct __sanitizer_sigaction { unsigned sa_flags; union { @@ -540,9 +554,11 @@ void (*handler)(int sig); }; __sanitizer_sigset_t sa_mask; + #if !defined(__mips__) || defined(__mips64) void (*sa_restorer)(); + #endif }; -#elif SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32) +#else // non-mips wordsize 32 struct __sanitizer_sigaction { union { void (*sigaction)(int sig, void *siginfo, void *uctx); @@ -552,6 +568,7 @@ uptr sa_flags; void (*sa_restorer)(); }; +#endif // SANITIZE_WORDSIZE #else // !SANITIZER_ANDROID struct __sanitizer_sigaction { #if defined(__mips__) && !SANITIZER_FREEBSD Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc =================================================================== --- lib/sanitizer_common/sanitizer_platform_limits_posix.cc +++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc @@ -1056,7 +1056,7 @@ // preprocessor macros. CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask); CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags); -#if SANITIZER_LINUX +#if SANITIZER_LINUX && (!defined(__mips__) || defined(__mips64)) CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer); #endif Index: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +++ lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc @@ -38,6 +38,9 @@ # include # endif # include // for user_regs_struct +# if SANITIZER_ANDROID && defined(__mips__) +# include // for mips SP register in sys/user.h +# endif #endif #include // for signal-related stuff @@ -467,7 +470,11 @@ #elif defined(__mips__) typedef struct user regs_struct; +#if SANITIZER_ANDROID +#define REG_SP regs[EF_R29] +#else #define REG_SP regs[EF_REG29] +#endif #elif defined(__aarch64__) typedef struct user_pt_regs regs_struct;