From 85e93ef612fcce0670c962fde4b874ad2b7b3fd7 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Fri, 25 May 2012 15:37:16 +0000 Subject: [PATCH] Factor ParseAsanOptions outside __asan_init llvm-svn: 157473 --- compiler-rt/lib/asan/asan_rtl.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index f883d31..ac4c1ea 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -424,15 +424,7 @@ void __asan_report_error(uintptr_t pc, uintptr_t bp, uintptr_t sp, AsanDie(); } -void __asan_init() { - if (asan_inited) return; - asan_init_is_running = true; - - // Make sure we are not statically linked. - AsanDoesNotSupportStaticLinkage(); - - // flags - const char *options = AsanGetEnv("ASAN_OPTIONS"); +static void ParseAsanOptions(const char *options) { FLAG_malloc_context_size = IntFlagValue(options, "malloc_context_size=", kMallocContextSize); CHECK(FLAG_malloc_context_size <= kMallocContextSize); @@ -476,11 +468,24 @@ void __asan_init() { FLAG_quarantine_size = IntFlagValue(options, "quarantine_size=", (ASAN_LOW_MEMORY) ? 1UL << 24 : 1UL << 28); +} + +void __asan_init() { + if (asan_inited) return; + asan_init_is_running = true; + + // Make sure we are not statically linked. + AsanDoesNotSupportStaticLinkage(); + + // flags + const char *options = AsanGetEnv("ASAN_OPTIONS"); if (FLAG_v) { Report("Parsed ASAN_OPTIONS: %s\n", options); } + ParseAsanOptions(options); + if (FLAG_atexit) { Atexit(asan_atexit); } -- 2.7.4