[compiler-rt] [compiler-rt] Add weak defs .*for contiguous_container.* functions (PR #120376)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 23:57:01 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Dmitry Chestnykh (chestnykh)

<details>
<summary>Changes</summary>

Fix #<!-- -->120278

---
Full diff: https://github.com/llvm/llvm-project/pull/120376.diff


3 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/CMakeLists.txt (+1) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc (+7-7) 
- (added) compiler-rt/lib/sanitizer_common/sanitizer_contiguous_container.cpp (+53) 


``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index 09391e4f5f3704..9eb47e21863cb9 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -4,6 +4,7 @@
 set(SANITIZER_SOURCES_NOTERMINATION
   sanitizer_allocator.cpp
   sanitizer_common.cpp
+  sanitizer_contiguous_container.cpp
   sanitizer_deadlock_detector1.cpp
   sanitizer_deadlock_detector2.cpp
   sanitizer_errno.cpp
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc
index 4ea75cdd67cb93..900a99329d56c7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc
@@ -8,18 +8,18 @@
 // Sanitizer Common interface list.
 //===----------------------------------------------------------------------===//
 INTERFACE_FUNCTION(__sanitizer_acquire_crash_state)
-INTERFACE_FUNCTION(__sanitizer_annotate_contiguous_container)
-INTERFACE_FUNCTION(__sanitizer_annotate_double_ended_contiguous_container)
-INTERFACE_FUNCTION(__sanitizer_copy_contiguous_container_annotations)
-INTERFACE_FUNCTION(__sanitizer_contiguous_container_find_bad_address)
-INTERFACE_FUNCTION(
+INTERFACE_WEAK_FUNCTION(__sanitizer_annotate_contiguous_container)
+INTERFACE_WEAK_FUNCTION(__sanitizer_annotate_double_ended_contiguous_container)
+INTERFACE_WEAK_FUNCTION(__sanitizer_copy_contiguous_container_annotations)
+INTERFACE_WEAK_FUNCTION(__sanitizer_contiguous_container_find_bad_address)
+INTERFACE_WEAK_FUNCTION(
     __sanitizer_double_ended_contiguous_container_find_bad_address)
 INTERFACE_FUNCTION(__sanitizer_set_death_callback)
 INTERFACE_FUNCTION(__sanitizer_set_report_path)
 INTERFACE_FUNCTION(__sanitizer_set_report_fd)
 INTERFACE_FUNCTION(__sanitizer_get_report_path)
-INTERFACE_FUNCTION(__sanitizer_verify_contiguous_container)
-INTERFACE_FUNCTION(__sanitizer_verify_double_ended_contiguous_container)
+INTERFACE_WEAK_FUNCTION(__sanitizer_verify_contiguous_container)
+INTERFACE_WEAK_FUNCTION(__sanitizer_verify_double_ended_contiguous_container)
 INTERFACE_WEAK_FUNCTION(__sanitizer_on_print)
 INTERFACE_WEAK_FUNCTION(__sanitizer_report_error_summary)
 INTERFACE_WEAK_FUNCTION(__sanitizer_sandbox_on_notify)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_contiguous_container.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_contiguous_container.cpp
new file mode 100644
index 00000000000000..4c093c1d4e9189
--- /dev/null
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_contiguous_container.cpp
@@ -0,0 +1,53 @@
+//===-- sanitizer_contiguous_container.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
+//
+//===---------------------------------------------------------------------===//
+//
+// This file provides weak defs of __sanitizer*contiguous_container* functions
+// whose strong implementations can be defined in particular runtime libs
+// of sanitizers
+//
+//===---------------------------------------------------------------------===//
+
+#include "sanitizer_internal_defs.h"
+
+SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_annotate_contiguous_container,
+                             const void *, const void *, const void *,
+                             const void *) {}
+
+SANITIZER_INTERFACE_WEAK_DEF(
+    void, __sanitizer_annotate_double_ended_contiguous_container, const void *,
+    const void *, const void *, const void *, const void *, const void *) {}
+
+SANITIZER_INTERFACE_WEAK_DEF(void,
+                             __sanitizer_copy_contiguous_container_annotations,
+                             const void *, const void *, const void *,
+                             const void *) {}
+
+SANITIZER_INTERFACE_WEAK_DEF(int, __sanitizer_verify_contiguous_container,
+                             const void *, const void *, const void *) {
+  return 0;
+}
+
+SANITIZER_INTERFACE_WEAK_DEF(
+    int, __sanitizer_verify_double_ended_contiguous_container, const void *,
+    const void *, const void *, const void *) {
+  return 0;
+}
+
+SANITIZER_INTERFACE_WEAK_DEF(const void *,
+                             __sanitizer_contiguous_container_find_bad_address,
+                             const void *, const void *, const void *) {
+  return nullptr;
+}
+
+SANITIZER_INTERFACE_WEAK_DEF(
+    const void *,
+    __sanitizer_double_ended_contiguous_container_find_bad_address,
+    const void *, const void *, const void *, const void *) {
+  return nullptr;
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/120376


More information about the llvm-commits mailing list