Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -179,7 +179,7 @@ # by other sanitizers (even if they build into dummy object files). filter_available_targets(LSAN_COMMON_SUPPORTED_ARCH ${SANITIZER_COMMON_SUPPORTED_ARCH}) -filter_available_targets(MSAN_SUPPORTED_ARCH x86_64) +filter_available_targets(MSAN_SUPPORTED_ARCH x86_64 mips64 mips64el) filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 i686 arm mips mips64 mipsel mips64el aarch64 powerpc64 powerpc64le) filter_available_targets(TSAN_SUPPORTED_ARCH x86_64) Index: lib/msan/CMakeLists.txt =================================================================== --- lib/msan/CMakeLists.txt +++ lib/msan/CMakeLists.txt @@ -22,8 +22,7 @@ # Static runtime library. add_custom_target(msan) -set(arch "x86_64") -if(CAN_TARGET_${arch}) +foreach(arch ${MSAN_SUPPORTED_ARCH}) add_compiler_rt_runtime(clang_rt.msan-${arch} ${arch} STATIC SOURCES ${MSAN_RTL_SOURCES} $ @@ -36,7 +35,7 @@ add_sanitizer_rt_symbols(clang_rt.msan-${arch} msan.syms.extra) add_dependencies(msan clang_rt.msan-${arch}-symbols) endif() -endif() +endforeach() add_compiler_rt_resource_file(msan_blacklist msan_blacklist.txt) add_dependencies(msan msan_blacklist) Index: lib/msan/msan.h =================================================================== --- lib/msan/msan.h +++ lib/msan/msan.h @@ -25,12 +25,21 @@ # define MSAN_REPLACE_OPERATORS_NEW_AND_DELETE 1 #endif +#if defined(__mips64) +#define MEM_TO_SHADOW(mem) (((uptr)mem) & ~0x4000000000ULL) +#define SHADOW_TO_ORIGIN(shadow) (((uptr)shadow) + 0x2000000000ULL) +#define MEM_TO_ORIGIN(mem) (SHADOW_TO_ORIGIN(MEM_TO_SHADOW(mem))) +#define MEM_IS_APP(mem) ((uptr)mem >= 0xe000000000ULL) +#define MEM_IS_SHADOW(mem) \ + ((uptr)mem >= 0xa000000000ULL && (uptr)mem <= 0xc000000000ULL) +#elif defined(__x86_64__) #define MEM_TO_SHADOW(mem) (((uptr)mem) & ~0x400000000000ULL) #define SHADOW_TO_ORIGIN(shadow) (((uptr)shadow) + 0x200000000000ULL) #define MEM_TO_ORIGIN(mem) (SHADOW_TO_ORIGIN(MEM_TO_SHADOW(mem))) #define MEM_IS_APP(mem) ((uptr)mem >= 0x600000000000ULL) #define MEM_IS_SHADOW(mem) \ ((uptr)mem >= 0x200000000000ULL && (uptr)mem <= 0x400000000000ULL) +#endif // These constants must be kept in sync with the ones in MemorySanitizer.cc. const int kMsanParamTlsSize = 800; Index: lib/msan/msan.cc =================================================================== --- lib/msan/msan.cc +++ lib/msan/msan.cc @@ -508,10 +508,15 @@ } static void* get_tls_base() { + // as this function is only relevant for architecture supporting msandr +#ifdef __x86_64__ u64 p; asm("mov %%fs:0, %0" : "=r"(p) ::); return (void*)p; +#else + return 0; +#endif /* __x86_64__ */ } int __msan_get_retval_tls_offset() { Index: lib/msan/msan_allocator.cc =================================================================== --- lib/msan/msan_allocator.cc +++ lib/msan/msan_allocator.cc @@ -40,14 +40,24 @@ } }; -static const uptr kAllocatorSpace = 0x600000000000ULL; -static const uptr kAllocatorSize = 0x80000000000; // 8T. -static const uptr kMetadataSize = sizeof(Metadata); -static const uptr kMaxAllowedMallocSize = 8UL << 30; - -typedef SizeClassAllocator64> kRegionSizeLog; + typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap; + typedef CompactSizeClassMap SizeClassMap; + typedef SizeClassAllocator32<0, SANITIZER_MMAP_RANGE_SIZE, sizeof(Metadata), + SizeClassMap, kRegionSizeLog, ByteMap, + MsanMapUnmapCallback> PrimaryAllocator; +#elif defined(__x86_64__) + static const uptr kAllocatorSpace = 0x600000000000ULL; + static const uptr kAllocatorSize = 0x80000000000; // 8T. + static const uptr kMaxAllowedMallocSize = 8UL << 30; + static const uptr kMetadataSize = sizeof(Metadata); + typedef SizeClassAllocator64 PrimaryAllocator; +#endif typedef SizeClassAllocatorLocalCache AllocatorCache; typedef LargeMmapAllocator SecondaryAllocator; typedef CombinedAllocator