Skip to content

Conversation

@fmayer
Copy link
Contributor

@fmayer fmayer commented Aug 18, 2025

This allows people to override them, if they want.

Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented Aug 18, 2025

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

Author: Florian Mayer (fmayer)

Changes

This allows people to override them, if they want.


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

1 Files Affected:

  • (modified) compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp (+6-7)
diff --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
index a2a2e36e8523d..1e143075f1bee 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
@@ -125,15 +125,13 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
 } // namespace __sanitizer
 #endif
 
-#define INTERFACE extern "C" __attribute__((visibility("default")))
-
 #define HANDLER_RECOVER(name, kind)                                            \
-  INTERFACE void __ubsan_handle_##name##_minimal() {                           \
+  SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_handle_##name##_minimal) {        \
     __ubsan_report_error(kind, GET_CALLER_PC(), nullptr);                      \
   }
 
 #define HANDLER_NORECOVER(name, kind)                                          \
-  INTERFACE void __ubsan_handle_##name##_minimal_abort() {                     \
+  SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_handle_##name##_minimal_abort) {  \
     uintptr_t caller = GET_CALLER_PC();                                        \
     __ubsan_report_error_fatal(kind, caller, nullptr);                         \
     abort_with_message(kind, caller, nullptr);                                 \
@@ -144,13 +142,14 @@ void NORETURN CheckFailed(const char *file, int, const char *cond, u64, u64) {
   HANDLER_NORECOVER(name, kind)
 
 #define HANDLER_RECOVER_PTR(name, kind)                                        \
-  INTERFACE void __ubsan_handle_##name##_minimal(const uintptr_t address) {    \
+  SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_handle_##name##_minimal,          \
+                               const uintptr_t address) {                      \
     __ubsan_report_error(kind, GET_CALLER_PC(), &address);                     \
   }
 
 #define HANDLER_NORECOVER_PTR(name, kind)                                      \
-  INTERFACE void __ubsan_handle_##name##_minimal_abort(                        \
-      const uintptr_t address) {                                               \
+  SANITIZER_INTERFACE_WEAK_DEF(void, __ubsan_handle_##name##_minimal_abort,    \
+                               const uintptr_t address) {                      \
     uintptr_t caller = GET_CALLER_PC();                                        \
     __ubsan_report_error_fatal(kind, caller, &address);                        \
     abort_with_message(kind, caller, &address);                                \

@fmayer fmayer merged commit 1947467 into main Aug 18, 2025
13 checks passed
@fmayer fmayer deleted the users/fmayer/spr/ubsan-min-rt-make-minimal-runtime-handlers-weak branch August 18, 2025 23:19
vitalybuka added a commit that referenced this pull request Sep 4, 2025
vitalybuka added a commit that referenced this pull request Sep 4, 2025
Existing `__ubsan_report_error` should be enough to solve this.

Ability to override on two levels, may result in hard to debug bugs
when in the same binary strong __ubsan_report_error and
__ubsan_handle_##name##_minimal_abort
 defined in unrelated components.

With one entry point we will have at least linking error.

Reverts #154220
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Sep 4, 2025
…k" (#156975)

Existing `__ubsan_report_error` should be enough to solve this.

Ability to override on two levels, may result in hard to debug bugs
when in the same binary strong __ubsan_report_error and
__ubsan_handle_##name##_minimal_abort
 defined in unrelated components.

With one entry point we will have at least linking error.

Reverts llvm/llvm-project#154220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants