[compiler-rt] r312973 - Runtime detection of android_set_abort_message.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 16:27:58 PDT 2017
Author: eugenis
Date: Mon Sep 11 16:27:58 2017
New Revision: 312973
URL: http://llvm.org/viewvc/llvm-project?rev=312973&view=rev
Log:
Runtime detection of android_set_abort_message.
Summary:
Use runtime detection (with a weak-undef symbol) of
android_set_abort_message availability. Android NDK provides a single
version of the ASan runtime library to be used for any target API
level, which makes compile-time feature detection impossible (the
library itself is built at API level 9).
Reviewers: vitalybuka
Subscribers: srhines, llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D37716
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc?rev=312973&r1=312972&r2=312973&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc Mon Sep 11 16:27:58 2017
@@ -553,9 +553,11 @@ void LogMessageOnPrintf(const char *str)
WriteToSyslog(str);
}
-#if SANITIZER_ANDROID && __ANDROID_API__ >= 21
-extern "C" void android_set_abort_message(const char *msg);
-void SetAbortMessage(const char *str) { android_set_abort_message(str); }
+#if SANITIZER_ANDROID
+extern "C" __attribute__((weak)) void android_set_abort_message(const char *);
+void SetAbortMessage(const char *str) {
+ if (&android_set_abort_message) android_set_abort_message(str);
+}
#else
void SetAbortMessage(const char *str) {}
#endif
Modified: compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc?rev=312973&r1=312972&r2=312973&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc (original)
+++ compiler-rt/trunk/lib/ubsan_minimal/ubsan_minimal_handlers.cc Mon Sep 11 16:27:58 2017
@@ -44,11 +44,9 @@ static bool report_this_error(void *call
}
#if defined(__ANDROID__)
-extern "C" void android_set_abort_message(const char *msg);
+extern "C" __attribute__((weak)) void android_set_abort_message(const char *);
static void abort_with_message(const char *msg) {
-#if __ANDROID_API__ >= 21
- android_set_abort_message(msg);
-#endif
+ if (&android_set_abort_message) android_set_abort_message(msg);
abort();
}
#else
More information about the llvm-commits
mailing list