[Sanitizer] Attempt to fix linker error on ARM variants
authorJulian Lettner <jlettner@apple.com>
Wed, 27 Feb 2019 23:47:00 +0000 (23:47 +0000)
committerJulian Lettner <jlettner@apple.com>
Wed, 27 Feb 2019 23:47:00 +0000 (23:47 +0000)
Previous commit:
https://github.com/llvm/llvm-project/commit/a0884da62a471f08c65a03e337aea23203a43eb8

llvm-svn: 355046

compiler-rt/lib/ubsan/ubsan_diag.cc
compiler-rt/lib/ubsan/ubsan_diag_standalone.cc

index 1935306..d86c0c2 100644 (file)
 
 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.
index 9c5c0af..1eff090 100644 (file)
 #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" {