diff options
author | Walter Lee <waltl@google.com> | 2018-05-30 04:57:04 +0000 |
---|---|---|
committer | Walter Lee <waltl@google.com> | 2018-05-30 04:57:04 +0000 |
commit | 0a70e9db035eba6432718820943bf6c02cbbb7e3 (patch) | |
tree | e7270763e89a9f81a2e4ae60b81ae0b2f3a69fda | |
parent | 3872c6c63383d48a5f940bf535877df45b18027f (diff) | |
download | bcm5719-llvm-0a70e9db035eba6432718820943bf6c02cbbb7e3.tar.gz bcm5719-llvm-0a70e9db035eba6432718820943bf6c02cbbb7e3.zip |
[asan, myriad] Reset shadow memory during exit
Reset shadow memory during exit. Also update a cut-and-paste comment,
and do some minor refactoring of InitializeShadowMemory.
Differential Revision: https://reviews.llvm.org/D47501
llvm-svn: 333503
-rw-r--r-- | compiler-rt/lib/asan/asan_rtems.cc | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/compiler-rt/lib/asan/asan_rtems.cc b/compiler-rt/lib/asan/asan_rtems.cc index 9e6a91f5258..4ad9a4a66cc 100644 --- a/compiler-rt/lib/asan/asan_rtems.cc +++ b/compiler-rt/lib/asan/asan_rtems.cc @@ -29,21 +29,24 @@ namespace __asan { -void InitializeShadowMemory() { - kHighMemEnd = 0; - kMidMemBeg = 0; - kMidMemEnd = 0; - +static void ResetShadowMemory() { uptr shadow_start = SHADOW_OFFSET; uptr shadow_end = MEM_TO_SHADOW(kMyriadMemoryEnd32); - uptr shadow_size = shadow_end - shadow_start; uptr gap_start = MEM_TO_SHADOW(shadow_start); uptr gap_end = MEM_TO_SHADOW(shadow_end); - REAL(memset)((void *)shadow_start, 0, shadow_size); + REAL(memset)((void *)shadow_start, 0, shadow_end - shadow_start); REAL(memset)((void *)gap_start, kAsanShadowGap, gap_end - gap_start); } +void InitializeShadowMemory() { + kHighMemEnd = 0; + kMidMemBeg = 0; + kMidMemEnd = 0; + + ResetShadowMemory(); +} + void AsanApplyToGlobals(globals_op_fptr op, const void *needle) { UNIMPLEMENTED(); } @@ -66,7 +69,7 @@ void EarlyInit() { // Provide early initialization of shadow memory so that // instrumented code running before full initialzation will not // report spurious errors. - InitializeShadowMemory(); + ResetShadowMemory(); } // Main thread information. Initialized in CreateMainThread() and @@ -118,10 +121,8 @@ static AsanThread *CreateAsanThread(StackTrace *stack, u32 parent_tid, } // This gets the same arguments passed to Init by CreateAsanThread, above. -// We're in the creator thread before the new thread is actually started, -// but its stack address range is already known. We don't bother tracking -// the static TLS address range because the system itself already uses an -// ASan-aware allocator for that. +// We're in the creator thread before the new thread is actually started, but +// its stack and tls address range are already known. void AsanThread::SetThreadStackAndTls(const AsanThread::InitOptions *options) { DCHECK_NE(GetCurrentThread(), this); DCHECK_NE(GetCurrentThread(), nullptr); @@ -219,8 +220,10 @@ static void HandleExit() { // Disable ASan by setting it to uninitialized. Also reset the // shadow memory to avoid reporting errors after the run-time has // been desroyed. - asan_inited = false; - // InitializeShadowMemory(); + if (asan_inited) { + asan_inited = false; + ResetShadowMemory(); + } } } // namespace __asan |