[PATCH] D20646: Init tsan with .preinit_array section
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed May 25 14:19:23 PDT 2016
vitalybuka created this revision.
vitalybuka added reviewers: kcc, eugenis.
vitalybuka added a subscriber: llvm-commits.
Herald added a subscriber: kubabrecka.
Some libraries, like OpenSSL, runs code from .init section.
http://reviews.llvm.org/D20646
Files:
lib/tsan/CMakeLists.txt
lib/tsan/rtl/tsan_preinit.cc
Index: lib/tsan/rtl/tsan_preinit.cc
===================================================================
--- /dev/null
+++ lib/tsan/rtl/tsan_preinit.cc
@@ -0,0 +1,25 @@
+//===-- tsan_preinit.cc ---------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of ThreadSanitizer.
+//
+// Call __tsan_init at the very early stage of process startup.
+//===----------------------------------------------------------------------===//
+
+#include "sanitizer_common/sanitizer_internal_defs.h"
+#include "tsan_interface.h"
+
+#if SANITIZER_CAN_USE_PREINIT_ARRAY
+ // The symbol is called __local_tsan_preinit, because it's not intended to be
+ // exported.
+ // This code linked into the main executable when -fsanitize=thread is in
+ // the link flags. It can only use exported interface functions.
+ __attribute__((section(".preinit_array"), used))
+ void (*__local_tsan_preinit)(void) = __tsan_init;
+#endif
Index: lib/tsan/CMakeLists.txt
===================================================================
--- lib/tsan/CMakeLists.txt
+++ lib/tsan/CMakeLists.txt
@@ -25,24 +25,25 @@
set(TSAN_SOURCES
rtl/tsan_clock.cc
rtl/tsan_debugging.cc
- rtl/tsan_flags.cc
rtl/tsan_fd.cc
+ rtl/tsan_flags.cc
rtl/tsan_ignoreset.cc
rtl/tsan_interceptors.cc
+ rtl/tsan_interface.cc
rtl/tsan_interface_ann.cc
rtl/tsan_interface_atomic.cc
- rtl/tsan_interface.cc
rtl/tsan_interface_java.cc
rtl/tsan_malloc_mac.cc
rtl/tsan_md5.cc
rtl/tsan_mman.cc
rtl/tsan_mutex.cc
rtl/tsan_mutexset.cc
+ rtl/tsan_preinit.cc
rtl/tsan_report.cc
rtl/tsan_rtl.cc
rtl/tsan_rtl_mutex.cc
- rtl/tsan_rtl_report.cc
rtl/tsan_rtl_proc.cc
+ rtl/tsan_rtl_report.cc
rtl/tsan_rtl_thread.cc
rtl/tsan_stack_trace.cc
rtl/tsan_stat.cc
@@ -117,7 +118,7 @@
RTUbsan
CFLAGS ${TSAN_RTL_CFLAGS}
PARENT_TARGET tsan)
- add_compiler_rt_object_libraries(RTTsan_dynamic
+ add_compiler_rt_object_libraries(RTTsan_dynamic
OS ${TSAN_SUPPORTED_OS}
ARCHS ${TSAN_SUPPORTED_ARCH}
SOURCES ${TSAN_SOURCES} ${TSAN_CXX_SOURCES} ${TSAN_ASM_SOURCES}
@@ -197,7 +198,7 @@
# FreeBSD does not install a number of Clang-provided headers for the compiler
# in the base system due to incompatibilities between FreeBSD's and Clang's
# versions. As a workaround do not use --sysroot=. on FreeBSD until this is
-# addressed.
+# addressed.
if(COMPILER_RT_HAS_SYSROOT_FLAG AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
file(GLOB _tsan_generic_sources rtl/tsan*)
file(GLOB _tsan_platform_sources rtl/tsan*posix* rtl/tsan*mac*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20646.58513.patch
Type: text/x-patch
Size: 2901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160525/1fd4a294/attachment.bin>
More information about the llvm-commits
mailing list