From 6d09c8ea6680cc76981d0a13a8fa7f9adf348585 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Mon, 4 Oct 2021 16:19:17 -0700 Subject: [PATCH] [Memory64] sanitizer C++ changes for 64-bit --- system/lib/compiler-rt/lib/asan/asan_flags.cpp | 3 ++- system/lib/compiler-rt/lib/lsan/lsan_allocator.cpp | 2 +- system/lib/compiler-rt/lib/lsan/lsan_allocator.h | 2 +- .../compiler-rt/lib/sanitizer_common/sanitizer_emscripten.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/system/lib/compiler-rt/lib/asan/asan_flags.cpp b/system/lib/compiler-rt/lib/asan/asan_flags.cpp index 197dfb23661af..5c47926c07e42 100644 --- a/system/lib/compiler-rt/lib/asan/asan_flags.cpp +++ b/system/lib/compiler-rt/lib/asan/asan_flags.cpp @@ -128,8 +128,9 @@ void InitializeFlags() { #if SANITIZER_EMSCRIPTEN char *options; // Override from Emscripten Module. + // TODO: add EM_ASM_I64 and avoid using a double for a 64-bit pointer. #define MAKE_OPTION_LOAD(parser, name) \ - options = (char*) EM_ASM_INT({ \ + options = (char*)(long)EM_ASM_DOUBLE({ \ return withBuiltinMalloc(function () { \ return allocateUTF8(Module[name] || 0); \ }); \ diff --git a/system/lib/compiler-rt/lib/lsan/lsan_allocator.cpp b/system/lib/compiler-rt/lib/lsan/lsan_allocator.cpp index 5dff571e4a059..a682cc1fa8caf 100644 --- a/system/lib/compiler-rt/lib/lsan/lsan_allocator.cpp +++ b/system/lib/compiler-rt/lib/lsan/lsan_allocator.cpp @@ -28,7 +28,7 @@ extern "C" void *memset(void *ptr, int value, uptr num); namespace __lsan { #if defined(__i386__) || defined(__arm__) || defined(__wasm32__) static const uptr kMaxAllowedMallocSize = 1UL << 30; -#elif defined(__mips64) || defined(__aarch64__) +#elif defined(__mips64) || defined(__aarch64__) || defined(__wasm64__) static const uptr kMaxAllowedMallocSize = 4UL << 30; #else static const uptr kMaxAllowedMallocSize = 8UL << 30; diff --git a/system/lib/compiler-rt/lib/lsan/lsan_allocator.h b/system/lib/compiler-rt/lib/lsan/lsan_allocator.h index 050a9143bc014..a15fb0434e255 100644 --- a/system/lib/compiler-rt/lib/lsan/lsan_allocator.h +++ b/system/lib/compiler-rt/lib/lsan/lsan_allocator.h @@ -50,7 +50,7 @@ struct ChunkMetadata { }; #if defined(__mips64) || defined(__aarch64__) || defined(__i386__) || \ - defined(__arm__) || defined(__wasm32__) + defined(__arm__) || defined(__wasm__) static const uptr kRegionSizeLog = 20; static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog; template diff --git a/system/lib/compiler-rt/lib/sanitizer_common/sanitizer_emscripten.cpp b/system/lib/compiler-rt/lib/sanitizer_common/sanitizer_emscripten.cpp index 785ebf97169d8..f9605e44307f4 100644 --- a/system/lib/compiler-rt/lib/sanitizer_common/sanitizer_emscripten.cpp +++ b/system/lib/compiler-rt/lib/sanitizer_common/sanitizer_emscripten.cpp @@ -27,7 +27,7 @@ namespace __sanitizer { extern "C" { - int emscripten_get_module_name(char *buf, uptr length); + uptr emscripten_get_module_name(char *buf, uptr length); } void ListOfModules::init() {