[asan] Improvements for asan deactivated mode: disable asan activation for runtime library on Linux, disable malloc checks.

Reviewed in http://reviews.llvm.org/D6265

llvm-svn: 222732
This commit is contained in:
Yury Gribov 2014-11-25 07:10:30 +00:00
parent 81537b5c8e
commit 4646b11acf
2 changed files with 18 additions and 5 deletions

View File

@ -25,6 +25,8 @@ static struct AsanDeactivatedFlags {
int max_redzone; int max_redzone;
int malloc_context_size; int malloc_context_size;
bool poison_heap; bool poison_heap;
bool alloc_dealloc_mismatch;
bool allocator_may_return_null;
} asan_deactivated_flags; } asan_deactivated_flags;
static bool asan_is_deactivated; static bool asan_is_deactivated;
@ -37,11 +39,17 @@ void AsanStartDeactivated() {
asan_deactivated_flags.poison_heap = flags()->poison_heap; asan_deactivated_flags.poison_heap = flags()->poison_heap;
asan_deactivated_flags.malloc_context_size = asan_deactivated_flags.malloc_context_size =
common_flags()->malloc_context_size; common_flags()->malloc_context_size;
asan_deactivated_flags.alloc_dealloc_mismatch =
flags()->alloc_dealloc_mismatch;
asan_deactivated_flags.allocator_may_return_null =
common_flags()->allocator_may_return_null;
flags()->quarantine_size = 0; flags()->quarantine_size = 0;
flags()->max_redzone = 16; flags()->max_redzone = 16;
flags()->poison_heap = false; flags()->poison_heap = false;
common_flags()->malloc_context_size = 0; common_flags()->malloc_context_size = 0;
flags()->alloc_dealloc_mismatch = false;
common_flags()->allocator_may_return_null = true;
asan_is_deactivated = true; asan_is_deactivated = true;
} }
@ -57,6 +65,10 @@ void AsanActivate() {
flags()->poison_heap = asan_deactivated_flags.poison_heap; flags()->poison_heap = asan_deactivated_flags.poison_heap;
common_flags()->malloc_context_size = common_flags()->malloc_context_size =
asan_deactivated_flags.malloc_context_size; asan_deactivated_flags.malloc_context_size;
flags()->alloc_dealloc_mismatch =
asan_deactivated_flags.alloc_dealloc_mismatch;
common_flags()->allocator_may_return_null =
asan_deactivated_flags.allocator_may_return_null;
ParseExtraActivationFlags(); ParseExtraActivationFlags();
@ -65,10 +77,12 @@ void AsanActivate() {
asan_is_deactivated = false; asan_is_deactivated = false;
VReport( VReport(
1, 1,
"quarantine_size %d, max_redzone %d, poison_heap %d, malloc_context_size " "quarantine_size %d, max_redzone %d, poison_heap %d, "
"%d\n", "malloc_context_size %d, alloc_dealloc_mismatch %d, "
"allocator_may_return_null %d\n",
flags()->quarantine_size, flags()->max_redzone, flags()->poison_heap, flags()->quarantine_size, flags()->max_redzone, flags()->poison_heap,
common_flags()->malloc_context_size); common_flags()->malloc_context_size, flags()->alloc_dealloc_mismatch,
common_flags()->allocator_may_return_null);
} }
} // namespace __asan } // namespace __asan

View File

@ -709,8 +709,7 @@ public: // NOLINT
AsanInitializer() { AsanInitializer() {
AsanCheckIncompatibleRT(); AsanCheckIncompatibleRT();
AsanCheckDynamicRTPrereqs(); AsanCheckDynamicRTPrereqs();
if (UNLIKELY(!asan_inited)) AsanInitFromRtl();
__asan_init();
} }
}; };