Index: compiler-rt/trunk/lib/asan/asan_rtl.cc =================================================================== --- compiler-rt/trunk/lib/asan/asan_rtl.cc +++ compiler-rt/trunk/lib/asan/asan_rtl.cc @@ -423,57 +423,7 @@ kHighShadowBeg > kMidMemEnd); } -static void AsanInitInternal() { - if (LIKELY(asan_inited)) return; - SanitizerToolName = "AddressSanitizer"; - CHECK(!asan_init_is_running && "ASan init calls itself!"); - asan_init_is_running = true; - - CacheBinaryName(); - - // Initialize flags. This must be done early, because most of the - // initialization steps look at flags(). - InitializeFlags(); - - AsanCheckIncompatibleRT(); - AsanCheckDynamicRTPrereqs(); - AvoidCVE_2016_2143(); - - SetCanPoisonMemory(flags()->poison_heap); - SetMallocContextSize(common_flags()->malloc_context_size); - - InitializePlatformExceptionHandlers(); - - InitializeHighMemEnd(); - - // Make sure we are not statically linked. - AsanDoesNotSupportStaticLinkage(); - - // Install tool-specific callbacks in sanitizer_common. - AddDieCallback(AsanDie); - SetCheckFailedCallback(AsanCheckFailed); - SetPrintfAndReportCallback(AppendToErrorMessageBuffer); - - __sanitizer_set_report_path(common_flags()->log_path); - - __asan_option_detect_stack_use_after_return = - flags()->detect_stack_use_after_return; - - // Re-exec ourselves if we need to set additional env or command line args. - MaybeReexec(); - - // Setup internal allocator callback. - SetLowLevelAllocateCallback(OnLowLevelAllocate); - - InitializeAsanInterceptors(); - - // Enable system log ("adb logcat") on Android. - // Doing this before interceptors are initialized crashes in: - // AsanInitInternal -> android_log_write -> __interceptor_strcmp - AndroidLogInit(); - - ReplaceSystemMalloc(); - +static void InitializeShadowMemory() { // Set the shadow memory address to uninitialized. __asan_shadow_memory_dynamic_address = kDefaultShadowSentinel; @@ -513,8 +463,6 @@ if (Verbosity()) PrintAddressSpaceLayout(); - DisableCoreDumperIfNecessary(); - if (full_shadow_is_available) { // mmap the low shadow plus at least one page at the left. if (kLowShadowBeg) @@ -546,6 +494,62 @@ DumpProcessMap(); Die(); } +} + +static void AsanInitInternal() { + if (LIKELY(asan_inited)) return; + SanitizerToolName = "AddressSanitizer"; + CHECK(!asan_init_is_running && "ASan init calls itself!"); + asan_init_is_running = true; + + CacheBinaryName(); + + // Initialize flags. This must be done early, because most of the + // initialization steps look at flags(). + InitializeFlags(); + + AsanCheckIncompatibleRT(); + AsanCheckDynamicRTPrereqs(); + AvoidCVE_2016_2143(); + + SetCanPoisonMemory(flags()->poison_heap); + SetMallocContextSize(common_flags()->malloc_context_size); + + InitializePlatformExceptionHandlers(); + + InitializeHighMemEnd(); + + // Make sure we are not statically linked. + AsanDoesNotSupportStaticLinkage(); + + // Install tool-specific callbacks in sanitizer_common. + AddDieCallback(AsanDie); + SetCheckFailedCallback(AsanCheckFailed); + SetPrintfAndReportCallback(AppendToErrorMessageBuffer); + + __sanitizer_set_report_path(common_flags()->log_path); + + __asan_option_detect_stack_use_after_return = + flags()->detect_stack_use_after_return; + + // Re-exec ourselves if we need to set additional env or command line args. + MaybeReexec(); + + // Setup internal allocator callback. + SetLowLevelAllocateCallback(OnLowLevelAllocate); + + InitializeAsanInterceptors(); + + // Enable system log ("adb logcat") on Android. + // Doing this before interceptors are initialized crashes in: + // AsanInitInternal -> android_log_write -> __interceptor_strcmp + AndroidLogInit(); + + ReplaceSystemMalloc(); + + DisableCoreDumperIfNecessary(); + + InitializeShadowMemory(); AsanTSDInit(PlatformTSDDtor); InstallDeadlySignalHandlers(AsanOnDeadlySignal);