[llvm-commits] [compiler-rt] r149686 - in /compiler-rt/trunk/lib/asan: asan_interceptors.cc asan_internal.h asan_malloc_linux.cc asan_rtl.cc
Alexey Samsonov
samsonov at google.com
Fri Feb 3 00:37:19 PST 2012
Author: samsonov
Date: Fri Feb 3 02:37:19 2012
New Revision: 149686
URL: http://llvm.org/viewvc/llvm-project?rev=149686&view=rev
Log:
AddressSanitizer: Replace __attribute__ with macro (for Win compatibility). Patch by timurrrr at google.com
Modified:
compiler-rt/trunk/lib/asan/asan_interceptors.cc
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_malloc_linux.cc
compiler-rt/trunk/lib/asan/asan_rtl.cc
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=149686&r1=149685&r2=149686&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Fri Feb 3 02:37:19 2012
@@ -94,8 +94,7 @@
// Instruments read/write access to a single byte in memory.
// On error calls __asan_report_error, which aborts the program.
-__attribute__((noinline))
-static void AccessAddress(uintptr_t address, bool isWrite) {
+static NOINLINE void AccessAddress(uintptr_t address, bool isWrite) {
if (__asan_address_is_poisoned((void*)address)) {
GET_BP_PC_SP;
__asan_report_error(pc, bp, sp, address, isWrite, /* access_size */ 1);
@@ -433,9 +432,9 @@
return result;
}
-#ifndef __APPLE__
+#ifdef __linux__
INTERCEPTOR(void*, index, const char *string, int c)
- __attribute__((alias(WRAPPER_NAME(strchr))));
+ ALIAS(WRAPPER_NAME(strchr));
#else
DEFINE_REAL(void*, index, const char *string, int c);
#endif
Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=149686&r1=149685&r2=149686&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Fri Feb 3 02:37:19 2012
@@ -30,9 +30,21 @@
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
-#else
+
+# define ALIAS(x) // TODO(timurrrr): do we need this on Windows?
+# define ALIGNED(x) __declspec(align(x))
+# define NOINLINE __declspec(noinline)
+
+# define ASAN_INTERFACE_ATTRIBUTE // TODO(timurrrr): do we need this on Win?
+#else // defined(_WIN32)
# include <stdint.h> // for __WORDSIZE
-#endif // _WIN32
+
+# define ALIAS(x) __attribute__((alias(x)))
+# define ALIGNED(x) __attribute__((aligned(x)))
+# define NOINLINE __attribute__((noinline))
+
+# define ASAN_INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
+#endif // defined(_WIN32)
// If __WORDSIZE was undefined by the platform, define it in terms of the
// compiler built-ins __LP64__ and _WIN64.
Modified: compiler-rt/trunk/lib/asan/asan_malloc_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_malloc_linux.cc?rev=149686&r1=149685&r2=149686&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_malloc_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_malloc_linux.cc Fri Feb 3 02:37:19 2012
@@ -31,7 +31,7 @@
void* (*memalign)(size_t alignment, size_t bytes);
};
-const MallocDebug asan_malloc_dispatch __attribute__((aligned(32))) = {
+const MallocDebug asan_malloc_dispatch ALIGNED(32) = {
malloc, free, calloc, realloc, memalign
};
@@ -96,7 +96,7 @@
}
INTERCEPTOR(void*, __libc_memalign, size_t align, size_t s)
- __attribute__((alias("memalign")));
+ ALIAS("memalign");
INTERCEPTOR(size_t, malloc_usable_size, void *ptr) {
GET_STACK_TRACE_HERE_FOR_MALLOC;
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=149686&r1=149685&r2=149686&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Fri Feb 3 02:37:19 2012
@@ -187,8 +187,7 @@
return true;
}
-__attribute__((noinline))
-static void DescribeAddress(uintptr_t addr, uintptr_t access_size) {
+static NOINLINE void DescribeAddress(uintptr_t addr, uintptr_t access_size) {
// Check if this is a global.
if (DescribeAddrIfGlobal(addr))
return;
@@ -203,8 +202,8 @@
// -------------------------- Run-time entry ------------------- {{{1
// exported functions
#define ASAN_REPORT_ERROR(type, is_write, size) \
-extern "C" void __asan_report_ ## type ## size(uintptr_t addr) \
- __attribute__((visibility("default"))) __attribute__((noinline)); \
+NOINLINE ASAN_INTERFACE_ATTRIBUTE \
+extern "C" void __asan_report_ ## type ## size(uintptr_t addr); \
extern "C" void __asan_report_ ## type ## size(uintptr_t addr) { \
GET_BP_PC_SP; \
__asan_report_error(pc, bp, sp, addr, is_write, size); \
More information about the llvm-commits
mailing list