From 52b751088b11547e0f4ef0589ebbe5e57752c68c Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Wed, 27 Feb 2019 23:47:00 +0000 Subject: [PATCH] [Sanitizer] Attempt to fix linker error on ARM variants Previous commit: https://github.com/llvm/llvm-project/commit/a0884da62a471f08c65a03e337aea23203a43eb8 llvm-svn: 355046 --- compiler-rt/lib/ubsan/ubsan_diag.cc | 14 ++++++++++++++ compiler-rt/lib/ubsan/ubsan_diag_standalone.cc | 11 ----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/compiler-rt/lib/ubsan/ubsan_diag.cc b/compiler-rt/lib/ubsan/ubsan_diag.cc index 1935306..d86c0c2 100644 --- a/compiler-rt/lib/ubsan/ubsan_diag.cc +++ b/compiler-rt/lib/ubsan/ubsan_diag.cc @@ -26,6 +26,20 @@ using namespace __ubsan; +// Weak linkage: UBSan is combined with runtimes that already provide this +// functionality (e.g., ASan) as well as runtimes that lack it (e.g., scudo). +SANITIZER_WEAK_ATTRIBUTE +void __sanitizer::GetStackTrace(BufferedStackTrace *stack, uptr max_depth, + uptr pc, uptr bp, void *context, bool fast) { + uptr top = 0; + uptr bottom = 0; + if (StackTrace::WillUseFastUnwind(fast)) { + GetThreadStackTopAndBottom(false, &top, &bottom); + stack->Unwind(max_depth, pc, bp, nullptr, top, bottom, true); + } else + stack->Unwind(max_depth, pc, bp, context, 0, 0, false); +} + static void MaybePrintStackTrace(uptr pc, uptr bp) { // We assume that flags are already parsed, as UBSan runtime // will definitely be called when we print the first diagnostics message. diff --git a/compiler-rt/lib/ubsan/ubsan_diag_standalone.cc b/compiler-rt/lib/ubsan/ubsan_diag_standalone.cc index 9c5c0af..1eff090 100644 --- a/compiler-rt/lib/ubsan/ubsan_diag_standalone.cc +++ b/compiler-rt/lib/ubsan/ubsan_diag_standalone.cc @@ -14,17 +14,6 @@ #if CAN_SANITIZE_UB #include "ubsan_diag.h" -void __sanitizer::GetStackTrace(BufferedStackTrace *stack, uptr max_depth, - uptr pc, uptr bp, void *context, bool fast) { - uptr top = 0; - uptr bottom = 0; - if (StackTrace::WillUseFastUnwind(fast)) { - GetThreadStackTopAndBottom(false, &top, &bottom); - stack->Unwind(max_depth, pc, bp, nullptr, top, bottom, true); - } else - stack->Unwind(max_depth, pc, bp, context, 0, 0, false); -} - using namespace __ubsan; extern "C" { -- 2.7.4