[compiler-rt] 0b15f89 - Revert "[nsan] Add nsan_preinit.cpp and make it static library only"

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 23:50:52 PDT 2024


Author: Vitaly Buka
Date: 2024-07-10T23:50:41-07:00
New Revision: 0b15f89182a4b2a4c46ad207fa2e282ad35f12ee

URL: https://github.com/llvm/llvm-project/commit/0b15f89182a4b2a4c46ad207fa2e282ad35f12ee
DIFF: https://github.com/llvm/llvm-project/commit/0b15f89182a4b2a4c46ad207fa2e282ad35f12ee.diff

LOG: Revert "[nsan] Add nsan_preinit.cpp and make it static library only"

https://lab.llvm.org/buildbot/#/builders/66/builds/1345

This reverts commit 2cec041a103137343e1019f6f883bdcdf60db708.

Added: 
    

Modified: 
    compiler-rt/lib/nsan/CMakeLists.txt
    compiler-rt/lib/nsan/nsan.cpp
    compiler-rt/lib/nsan/nsan.h

Removed: 
    compiler-rt/lib/nsan/nsan_preinit.cpp


################################################################################
diff  --git a/compiler-rt/lib/nsan/CMakeLists.txt b/compiler-rt/lib/nsan/CMakeLists.txt
index 1e138d4560c89..d67c3ac434d3a 100644
--- a/compiler-rt/lib/nsan/CMakeLists.txt
+++ b/compiler-rt/lib/nsan/CMakeLists.txt
@@ -11,9 +11,6 @@ set(NSAN_SOURCES
   nsan_suppressions.cpp
 )
 
-set(NSAN_PREINIT_SOURCES
-  nsan_preinit.cpp)
-
 set(NSAN_HEADERS
   nsan.h
   nsan_flags.h
@@ -64,12 +61,6 @@ if(NOT APPLE)
       ADDITIONAL_HEADERS ${NSAN_HEADERS}
       CFLAGS ${NSAN_CFLAGS})
 
-  add_compiler_rt_object_libraries(RTNsan_preinit
-    ARCHS ${NSAN_SUPPORTED_ARCH}
-    SOURCES ${NSAN_PREINIT_SOURCES}
-    ADDITIONAL_HEADERS ${NSAN_HEADERS}
-    CFLAGS ${NSAN_CFLAGS})
-
   file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "")
   add_compiler_rt_object_libraries(RTNsan_dynamic_version_script_dummy
     ARCHS ${NSAN_SUPPORTED_ARCH}
@@ -81,7 +72,7 @@ add_compiler_rt_runtime(
   clang_rt.nsan
   STATIC
   ARCHS ${NSAN_SUPPORTED_ARCH}
-  OBJECT_LIBS RTNsan_preinit RTNsan
+  OBJECT_LIBS RTNsan
               ${NSAN_COMMON_RUNTIME_OBJECT_LIBS}
   CFLAGS ${NSAN_CFLAGS}
   PARENT_TARGET nsan)

diff  --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index 43ed84fbad5b4..f7b2ce2048290 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -779,7 +779,7 @@ extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_dump_shadow_args() {
 bool __nsan::nsan_initialized;
 bool __nsan::nsan_init_is_running;
 
-extern "C" void __nsan_init() {
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_init() {
   CHECK(!nsan_init_is_running);
   if (nsan_initialized)
     return;
@@ -801,3 +801,8 @@ extern "C" void __nsan_init() {
   nsan_init_is_running = false;
   nsan_initialized = true;
 }
+
+#if SANITIZER_CAN_USE_PREINIT_ARRAY
+__attribute__((section(".preinit_array"),
+               used)) static void (*nsan_init_ptr)() = __nsan_init;
+#endif

diff  --git a/compiler-rt/lib/nsan/nsan.h b/compiler-rt/lib/nsan/nsan.h
index 8277e3d778047..0fb998b049854 100644
--- a/compiler-rt/lib/nsan/nsan.h
+++ b/compiler-rt/lib/nsan/nsan.h
@@ -32,8 +32,6 @@ using __sanitizer::uptr;
 // Private nsan interface. Used e.g. by interceptors.
 extern "C" {
 
-void __nsan_init();
-
 // This marks the shadow type of the given block of application memory as
 // unknown.
 // printf-free (see comment in nsan_interceptors.cc).

diff  --git a/compiler-rt/lib/nsan/nsan_preinit.cpp b/compiler-rt/lib/nsan/nsan_preinit.cpp
deleted file mode 100644
index 5d869bbdf9668..0000000000000
--- a/compiler-rt/lib/nsan/nsan_preinit.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-//===- nsan_preinit.cpp ---------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Call __nsan_init early using ELF DT_PREINIT_ARRAY.
-//
-//===----------------------------------------------------------------------===//
-
-#include "nsan/nsan.h"
-#include "sanitizer_common/sanitizer_internal_defs.h"
-
-#if SANITIZER_CAN_USE_PREINIT_ARRAY
-
-__attribute__((section(".preinit_array"), used)) static auto nsan_preinit =
-    __nsan_init;
-
-#endif


        


More information about the llvm-commits mailing list