[llvm-commits] [ASan] use macro to define if we intercept should signal/sigaction (issue 5903048)

samsonov at google.com samsonov at google.com
Sat Mar 24 03:35:44 PDT 2012


Reviewers: Evgeniy Stepanov, kcc1,



Please review this at http://codereview.appspot.com/5903048/

Affected files:
   M     asan_interceptors.cc
   M     asan_internal.h


Index: asan_internal.h
===================================================================
--- asan_internal.h	(revision 153379)
+++ asan_internal.h	(working copy)
@@ -104,6 +104,8 @@
  # define ASAN_WINDOWS 0
  #endif

+#define ASAN_POSIX (ASAN_LINUX || ASAN_MAC)
+
  #if !defined(__has_feature)
  #define __has_feature(x) 0
  #endif
Index: asan_interceptors.cc
===================================================================
--- asan_interceptors.cc	(revision 153379)
+++ asan_interceptors.cc	(working copy)
@@ -38,12 +38,18 @@
  # define ASAN_INTERCEPT_STRNLEN 0
  #endif

+#if !defined(ANDROID) && !defined(_WIN32)
+# define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 1
+#else
+# define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 0
+#endif
+
  // Use extern declarations of intercepted functions on Mac and Windows
  // to avoid including system headers.
  #if defined(__APPLE__) || (defined(_WIN32) && !defined(_DLL))
  extern "C" {
  // signal.h
-# if !defined(_WIN32)
+# if ASAN_INTERCEPT_SIGNAL_AND_SIGACTION
  struct sigaction;
  int sigaction(int sig, const struct sigaction *act,
                struct sigaction *oldact);
@@ -346,7 +352,7 @@
  }
  #endif  // !_WIN32

-#if !defined(ANDROID) && !defined(_WIN32)
+#if ASAN_INTERCEPT_SIGNAL_AND_SIGACTION
  INTERCEPTOR(void*, signal, int signum, void *handler) {
    if (!AsanInterceptsSignal(signum)) {
      return REAL(signal)(signum, handler);
@@ -361,7 +367,11 @@
    }
    return 0;
  }
-#endif  // !ANDROID && !_WIN32
+#elif ASAN_POSIX
+// We need to have defined REAL(sigaction) on posix systems.
+DEFINE_REAL(int, sigaction, int signum, const struct sigaction *act,
+    struct sigaction *oldact);
+#endif  // ASAN_INTERCEPT_SIGNAL_AND_SIGACTION

  INTERCEPTOR(void, longjmp, void *env, int val) {
    __asan_handle_no_return();
@@ -511,11 +521,6 @@
  DEFINE_REAL(char*, index, const char *string, int c);
  #endif

-#ifdef ANDROID
-DEFINE_REAL(int, sigaction, int signum, const struct sigaction *act,
-    struct sigaction *oldact);
-#endif
-
  INTERCEPTOR(int, strcasecmp, const char *s1, const char *s2) {
    ENSURE_ASAN_INITED();
    unsigned char c1, c2;
@@ -755,7 +760,7 @@

    // Intecept signal- and jump-related functions.
    CHECK(INTERCEPT_FUNCTION(longjmp));
-#if !defined(ANDROID) && !defined(_WIN32)
+#if ASAN_INTERCEPT_SIGNAL_AND_SIGACTION
    CHECK(INTERCEPT_FUNCTION(sigaction));
    CHECK(INTERCEPT_FUNCTION(signal));
  #endif





More information about the llvm-commits mailing list