[llvm-commits] [compiler-rt] r168509 - in /compiler-rt/trunk/lib/asan: asan_intercepted_functions.h asan_linux.cc asan_mac.cc asan_posix.cc

Alexey Samsonov samsonov at google.com
Fri Nov 23 02:14:44 PST 2012


Author: samsonov
Date: Fri Nov 23 04:14:44 2012
New Revision: 168509

URL: http://llvm.org/viewvc/llvm-project?rev=168509&view=rev
Log:
[ASan] intercept swapcontext on Linux only

Modified:
    compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
    compiler-rt/trunk/lib/asan/asan_linux.cc
    compiler-rt/trunk/lib/asan/asan_mac.cc
    compiler-rt/trunk/lib/asan/asan_posix.cc

Modified: compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_intercepted_functions.h?rev=168509&r1=168508&r2=168509&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_intercepted_functions.h (original)
+++ compiler-rt/trunk/lib/asan/asan_intercepted_functions.h Fri Nov 23 04:14:44 2012
@@ -51,12 +51,16 @@
 # define ASAN_INTERCEPT_STRNLEN 0
 #endif
 
+#if defined(__linux__) && !defined(ANDROID)
+# define ASAN_INTERCEPT_SWAPCONTEXT 1
+#else
+# define ASAN_INTERCEPT_SWAPCONTEXT 0
+#endif
+
 #if !defined(ANDROID) && !defined(_WIN32)
 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 1
-# define ASAN_INTERCEPT_SWAPCONTEXT 1
 #else
 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 0
-# define ASAN_INTERCEPT_SWAPCONTEXT 0
 #endif
 
 // On Darwin siglongjmp tailcalls longjmp, so we don't want to intercept it
@@ -90,12 +94,6 @@
 DECLARE_FUNCTION_AND_WRAPPER(void*, signal, int signum, void *handler);
 # endif
 
-// ucontext.h
-# if ASAN_INTERCEPT_SWAPCONTEXT
-DECLARE_FUNCTION_AND_WRAPPER(int, swapcontext, struct ucontext_t *oucp,
-                             struct ucontext_t *ucp);
-# endif
-
 // setjmp.h
 DECLARE_FUNCTION_AND_WRAPPER(void, longjmp, void *env, int value);
 # if ASAN_INTERCEPT__LONGJMP

Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=168509&r1=168508&r2=168509&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_linux.cc Fri Nov 23 04:14:44 2012
@@ -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__

Modified: compiler-rt/trunk/lib/asan/asan_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=168509&r1=168508&r2=168509&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.cc Fri Nov 23 04:14:44 2012
@@ -171,6 +171,10 @@
   }
 }
 
+void ClearShadowMemoryForContext(void *context) {
+  UNIMPLEMENTED();
+}
+
 // The range of pages to be used for escape islands.
 // TODO(glider): instead of mapping a fixed range we must find a range of
 // unmapped pages in vmmap and take them.

Modified: compiler-rt/trunk/lib/asan/asan_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=168509&r1=168508&r2=168509&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_posix.cc Fri Nov 23 04:14:44 2012
@@ -27,7 +27,6 @@
 #include <stdlib.h>
 #include <sys/time.h>
 #include <sys/resource.h>
-#include <ucontext.h>
 #include <unistd.h>
 
 static const uptr kAltStackSize = SIGSTKSZ * 4;  // SIGSTKSZ is not enough.
@@ -96,17 +95,6 @@
   MaybeInstallSigaction(SIGBUS, ASAN_OnSIGSEGV);
 }
 
-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);
-}
-
 // ---------------------- TSD ---------------- {{{1
 
 static pthread_key_t tsd_key;





More information about the llvm-commits mailing list