[compiler-rt] r213980 - [Sanitizer] Introduce SANITIZER_CAN_USE_PREINIT_ARRAY definition and use it across sanitizers.
Alexey Samsonov
vonosmas at gmail.com
Fri Jul 25 15:05:03 PDT 2014
Author: samsonov
Date: Fri Jul 25 17:05:02 2014
New Revision: 213980
URL: http://llvm.org/viewvc/llvm-project?rev=213980&view=rev
Log:
[Sanitizer] Introduce SANITIZER_CAN_USE_PREINIT_ARRAY definition and use it across sanitizers.
Get rid of ASAN_USE_PREINIT_ARRAY and LSAN_USE_PREINIT_ARRAY - just always
use .preinit_array if it's available. This mode seems stable enough, and
we've been relying on default values of these macro for a long time.
Modified:
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_preinit.cc
compiler-rt/trunk/lib/dfsan/dfsan.cc
compiler-rt/trunk/lib/lsan/lsan_preinit.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
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=213980&r1=213979&r2=213980&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Fri Jul 25 17:05:02 2014
@@ -45,10 +45,6 @@
# endif
#endif
-#ifndef ASAN_USE_PREINIT_ARRAY
-# define ASAN_USE_PREINIT_ARRAY (SANITIZER_LINUX && !SANITIZER_ANDROID)
-#endif
-
#ifndef ASAN_DYNAMIC
# ifdef PIC
# define ASAN_DYNAMIC 1
Modified: compiler-rt/trunk/lib/asan/asan_preinit.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_preinit.cc?rev=213980&r1=213979&r2=213980&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_preinit.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_preinit.cc Fri Jul 25 17:05:02 2014
@@ -10,14 +10,10 @@
// This file is a part of AddressSanitizer, an address sanity checker.
//
// Call __asan_init at the very early stage of process startup.
-// On Linux we use .preinit_array section (unless PIC macro is defined).
//===----------------------------------------------------------------------===//
#include "asan_internal.h"
-#if ASAN_USE_PREINIT_ARRAY && !defined(PIC)
- // On Linux, we force __asan_init to be called before anyone else
- // by placing it into .preinit_array section.
- // FIXME: do we have anything like this on Mac?
+#if SANITIZER_CAN_USE_PREINIT_ARRAY
// The symbol is called __local_asan_preinit, because it's not intended to be
// exported.
__attribute__((section(".preinit_array"), used))
Modified: compiler-rt/trunk/lib/dfsan/dfsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan.cc?rev=213980&r1=213979&r2=213980&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/dfsan.cc (original)
+++ compiler-rt/trunk/lib/dfsan/dfsan.cc Fri Jul 25 17:05:02 2014
@@ -269,7 +269,7 @@ static void dfsan_init(int argc, char **
InitializeInterceptors();
}
-#ifndef DFSAN_NOLIBC
+#ifndef DFSAN_NOLIBC && SANITIZER_CAN_USE_PREINIT_ARRAY
__attribute__((section(".preinit_array"), used))
static void (*dfsan_init_ptr)(int, char **, char **) = dfsan_init;
#endif
Modified: compiler-rt/trunk/lib/lsan/lsan_preinit.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_preinit.cc?rev=213980&r1=213979&r2=213980&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_preinit.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_preinit.cc Fri Jul 25 17:05:02 2014
@@ -14,11 +14,7 @@
#include "lsan.h"
-#ifndef LSAN_USE_PREINIT_ARRAY
-#define LSAN_USE_PREINIT_ARRAY 1
-#endif
-
-#if LSAN_USE_PREINIT_ARRAY && !defined(PIC)
+#if SANITIZER_CAN_USE_PREINIT_ARRAY
// We force __lsan_init to be called before anyone else by placing it into
// .preinit_array section.
__attribute__((section(".preinit_array"), used))
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h?rev=213980&r1=213979&r2=213980&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h Fri Jul 25 17:05:02 2014
@@ -34,6 +34,15 @@
# define SANITIZER_SUPPORTS_WEAK_HOOKS 0
#endif
+// We can use .preinit_array section on Linux to call sanitizer initialization
+// functions very early in the process startup (unless PIC macro is defined).
+// FIXME: do we have anything like this on Mac?
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !defined(PIC)
+# define SANITIZER_CAN_USE_PREINIT_ARRAY 1
+#else
+# define SANITIZER_CAN_USE_PREINIT_ARRAY 0
+#endif
+
// GCC does not understand __has_feature
#if !defined(__has_feature)
# define __has_feature(x) 0
More information about the llvm-commits
mailing list