[ASan] intercept swapcontext on Linux only
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168509 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
index 2e6934e..a70adee 100644
--- a/lib/asan/asan_linux.cc
+++ b/lib/asan/asan_linux.cc
@@ -170,6 +170,23 @@
}
}
+#if !ASAN_ANDROID
+void ClearShadowMemoryForContext(void *context) {
+ ucontext_t *ucp = (ucontext_t*)context;
+ uptr sp = (uptr)ucp->uc_stack.ss_sp;
+ uptr size = ucp->uc_stack.ss_size;
+ // Align to page size.
+ uptr bottom = sp & ~(kPageSize - 1);
+ size += sp - bottom;
+ size = RoundUpTo(size, kPageSize);
+ PoisonShadow(bottom, size, 0);
+}
+#else
+void ClearShadowMemoryForContext(void *context) {
+ UNIMPLEMENTED();
+}
+#endif
+
} // namespace __asan
#endif // __linux__