summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2017-09-18 22:38:18 +0000
committerVitaly Buka <vitalybuka@google.com>2017-09-18 22:38:18 +0000
commiteb0c26168ff93b454d765df371543fec76a14901 (patch)
tree141a415262da809ede0eb026bd6a0a9c18e5bd29
parentfca1a34a113452ad3e101456fd4422916afd9b4e (diff)
downloadbcm5719-llvm-eb0c26168ff93b454d765df371543fec76a14901.tar.gz
bcm5719-llvm-eb0c26168ff93b454d765df371543fec76a14901.zip
[ubsan] Split ubsan_init_standalone
On Linux we may need preinit_array in static lib and ubsan_standalone_initializer in shared lib. llvm-svn: 313583
-rw-r--r--compiler-rt/lib/ubsan/CMakeLists.txt15
-rw-r--r--compiler-rt/lib/ubsan/ubsan_init_standalone.cc7
2 files changed, 12 insertions, 10 deletions
diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt
index a29c0eed9d3..0375cffb98e 100644
--- a/compiler-rt/lib/ubsan/CMakeLists.txt
+++ b/compiler-rt/lib/ubsan/CMakeLists.txt
@@ -10,7 +10,6 @@ set(UBSAN_SOURCES
set(UBSAN_STANDALONE_SOURCES
ubsan_diag_standalone.cc
- ubsan_init_standalone.cc
)
set(UBSAN_CXXABI_SOURCES
@@ -64,6 +63,7 @@ if(APPLE)
OS ${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${UBSAN_SUPPORTED_ARCH}
SOURCES ${UBSAN_STANDALONE_SOURCES}
+ ubsan_init_standalone.cc
CFLAGS ${UBSAN_STANDALONE_CFLAGS})
add_weak_symbols("ubsan" WEAK_SYMBOL_LINK_FLAGS)
@@ -133,7 +133,15 @@ else()
# Initializer of standalone UBSan runtime.
add_compiler_rt_object_libraries(RTUbsan_standalone
ARCHS ${UBSAN_SUPPORTED_ARCH}
- SOURCES ${UBSAN_STANDALONE_SOURCES} CFLAGS ${UBSAN_STANDALONE_CFLAGS})
+ SOURCES ${UBSAN_STANDALONE_SOURCES}
+ ubsan_init_standalone
+ CFLAGS ${UBSAN_STANDALONE_CFLAGS})
+ # This can't not be linked into share lib
+ add_compiler_rt_object_libraries(RTUbsan_standalone_preinit
+ ARCHS ${UBSAN_SUPPORTED_ARCH}
+ SOURCES ${UBSAN_STANDALONE_SOURCES}
+ ubsan_init_standalone_preinit.cc
+ CFLAGS ${UBSAN_STANDALONE_CFLAGS})
# Standalone UBSan runtimes.
add_compiler_rt_runtime(clang_rt.ubsan_standalone
@@ -142,7 +150,7 @@ else()
OBJECT_LIBS RTSanitizerCommon
RTSanitizerCommonLibc
RTUbsan
- RTUbsan_standalone
+ RTUbsan_standalone_preinit
CFLAGS ${UBSAN_CFLAGS}
PARENT_TARGET ubsan)
@@ -160,6 +168,7 @@ else()
OBJECT_LIBS RTSanitizerCommon
RTSanitizerCommonLibc
RTUbsan
+ RTUbsan_standalone
CFLAGS ${UBSAN_CFLAGS}
LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}
LINK_LIBS ${UBSAN_DYNAMIC_LIBS}
diff --git a/compiler-rt/lib/ubsan/ubsan_init_standalone.cc b/compiler-rt/lib/ubsan/ubsan_init_standalone.cc
index ff1a20efea3..8e999e3aca1 100644
--- a/compiler-rt/lib/ubsan/ubsan_init_standalone.cc
+++ b/compiler-rt/lib/ubsan/ubsan_init_standalone.cc
@@ -19,11 +19,6 @@
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "ubsan_init.h"
-#if SANITIZER_CAN_USE_PREINIT_ARRAY
-__attribute__((section(".preinit_array"), used))
-void (*__local_ubsan_preinit)(void) = __ubsan::InitAsStandalone;
-#else
-// Use a dynamic initializer.
class UbsanStandaloneInitializer {
public:
UbsanStandaloneInitializer() {
@@ -31,5 +26,3 @@ class UbsanStandaloneInitializer {
}
};
static UbsanStandaloneInitializer ubsan_standalone_initializer;
-#endif // SANITIZER_CAN_USE_PREINIT_ARRAY
-
OpenPOWER on IntegriCloud