[ASan] Apply some ASan-relevant pieces of patch by Ruben Van Boxem. In the same time...
authorAlexey Samsonov <samsonov@google.com>
Mon, 24 Sep 2012 11:43:40 +0000 (11:43 +0000)
committerAlexey Samsonov <samsonov@google.com>
Mon, 24 Sep 2012 11:43:40 +0000 (11:43 +0000)
llvm-svn: 164486

compiler-rt/CMakeLists.txt
compiler-rt/include/sanitizer/common_interface_defs.h
compiler-rt/lib/CMakeLists.txt
compiler-rt/lib/asan/asan_malloc_win.cc
compiler-rt/lib/interception/interception.h
compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h

index 67c7799ab9e761e537777a534e39b1e534b13bce..d5f669649c7b07abc16c3229449d0f1060dfd800 100644 (file)
@@ -67,9 +67,11 @@ set(SANITIZER_COMMON_CFLAGS
   -fno-exceptions
   -fomit-frame-pointer
   -funwind-tables
-  -fvisibility=hidden
   -O3
   )
+if(NOT WIN32)
+  list(APPEND SANITIZER_COMMON_CFLAGS -fvisibility=hidden)
+endif()
 check_cxx_compiler_flag(-Wno-variadic-macros SUPPORTS_NO_VARIADIC_MACROS_FLAG)
 if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
   list(APPEND SANITIZER_COMMON_CFLAGS -Wno-variadic-macros)
index 1aa4f0b765f0be439906fbe2cc9177caff509e26..cbce63f1c6a5dad5848c3e764a6aed1800a59aaa 100644 (file)
 // in a portable way by the language itself.
 namespace __sanitizer {
 
+#if defined(_WIN64)
+// 64-bit Windows uses LLP64 data model.
+typedef unsigned long long uptr;  // NOLINT
+typedef signed   long long sptr;  // NOLINT
+#else
 typedef unsigned long uptr;  // NOLINT
 typedef signed   long sptr;  // NOLINT
+#endif  // defined(_WIN64)
 typedef unsigned char u8;
 typedef unsigned short u16;  // NOLINT
 typedef unsigned int u32;
index cb72594e699bb3261f913202ed0e527a18c53c53..a1dc48c467f820478e2b527c6d1baad0b8345235 100644 (file)
@@ -1,6 +1,6 @@
 # First, add the subdirectories which contain feature-based runtime libraries
 # and several convenience helper libraries.
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|Windows")
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux")
   # AddressSanitizer is supported on Linux and Mac OS X.
   # Windows support is work in progress.
   add_subdirectory(asan)
index 6c00e77caae83b3fddc79e5248db099f022589aa..3ec76d89caa2425f3948a3474765317312710cda 100644 (file)
 #include "asan_interceptors.h"
 #include "asan_internal.h"
 #include "asan_stack.h"
-
 #include "interception/interception.h"
 
+#include <stddef.h>
+
 // ---------------------- Replacement functions ---------------- {{{1
 using namespace __asan;  // NOLINT
 
index 6ff7355684dd4225a669d3b226653fb102c5dc7d..7dad07fc6eb13d943033b51e00a3197adf9995d7 100644 (file)
 // challenging, as we don't even pass function type to
 // INTERCEPT_FUNCTION macro, only its name.
 namespace __interception {
+#if defined(_WIN64)
+typedef unsigned long long uptr;  // NOLINT
+#else
 typedef unsigned long uptr;  // NOLINT
+#endif  // _WIN64
 }  // namespace __interception
 
 #define INCLUDED_FROM_INTERCEPTION_LIB
index 6fdbd97584ec4a9a1552f86b67435cc84038838a..00549f03c00db41ca810079cfbb55c57c7ff0aee 100644 (file)
@@ -142,6 +142,8 @@ void NORETURN CheckFailed(const char *file, int line, const char *cond,
 
 // Limits for integral types. We have to redefine it in case we don't
 // have stdint.h (like in Visual Studio 9).
+#undef __INT64_C
+#undef __UINT64_C
 #if __WORDSIZE == 64
 # define __INT64_C(c)  c ## L
 # define __UINT64_C(c) c ## UL
@@ -164,7 +166,7 @@ void NORETURN CheckFailed(const char *file, int line, const char *cond,
 
 enum LinkerInitialized { LINKER_INITIALIZED = 0 };
 
-#if !defined(_WIN32) || defined(__clang__)
+#if !defined(_MSC_VER) || defined(__clang__)
 # define GET_CALLER_PC() (uptr)__builtin_return_address(0)
 # define GET_CURRENT_FRAME() (uptr)__builtin_frame_address(0)
 #else