summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2017-12-15 17:30:50 +0000
committerFilipe Cabecinhas <me@filcab.net>2017-12-15 17:30:50 +0000
commit237d4c2eabc339f18bb9fc2d533e163357976507 (patch)
treed44625c89f3940a5760050b47af1c0ac6156326f
parenta16395008cbe49da844d2ee020d09bfb1d6e4e88 (diff)
downloadbcm5719-llvm-237d4c2eabc339f18bb9fc2d533e163357976507.tar.gz
bcm5719-llvm-237d4c2eabc339f18bb9fc2d533e163357976507.zip
[ubsan-minimal] Add a path for non-POSIX (and bare-metal) use of the library
Summary: Hook on -DKERNEL_USE (which is also used in lib/builtins) to not import strlen and not rely on write() being implemented with the stderr on fd 2. With this, the only requirements to use this library are: - "Good enough" std::atomic<void*> and std::atomic<int> - abort() being implemented - ubsan_message(const char*) being implemented Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39791 llvm-svn: 320831
-rw-r--r--compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cc b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cc
index 92b673d9eb8..5a5675c983f 100644
--- a/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cc
+++ b/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cc
@@ -5,9 +5,14 @@
#include <string.h>
#include <unistd.h>
+#ifdef KERNEL_USE
+extern "C" void ubsan_message(const char *msg);
+static void message(const char *msg) { ubsan_message(msg); }
+#else
static void message(const char *msg) {
write(2, msg, strlen(msg));
}
+#endif
static const int kMaxCallerPcs = 20;
static __sanitizer::atomic_uintptr_t caller_pcs[kMaxCallerPcs];
OpenPOWER on IntegriCloud