[PATCH] D39791: [ubsan-minimal] Add a path for non-POSIX (and bare-metal) use of the library
Filipe Cabecinhas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 04:12:34 PST 2017
filcab created this revision.
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
https://reviews.llvm.org/D39791
Files:
lib/ubsan_minimal/ubsan_minimal_handlers.cc
Index: lib/ubsan_minimal/ubsan_minimal_handlers.cc
===================================================================
--- lib/ubsan_minimal/ubsan_minimal_handlers.cc
+++ lib/ubsan_minimal/ubsan_minimal_handlers.cc
@@ -3,9 +3,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 std::atomic<void *> caller_pcs[kMaxCallerPcs];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39791.122058.patch
Type: text/x-patch
Size: 590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171108/9409ee72/attachment.bin>
More information about the llvm-commits
mailing list