Index: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc =================================================================== --- compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -553,9 +553,11 @@ 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 Index: compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cc =================================================================== --- compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cc +++ compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cc @@ -44,11 +44,9 @@ } #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