[compiler-rt] 8d19af6 - [GWP-ASan] Use weak abort message definition.

Mitch Phillips via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 6 10:36:35 PST 2020


Author: Mitch Phillips
Date: 2020-02-06T10:36:25-08:00
New Revision: 8d19af685c9b1ba50df0ed739dbfffd0aa7686ee

URL: https://github.com/llvm/llvm-project/commit/8d19af685c9b1ba50df0ed739dbfffd0aa7686ee
DIFF: https://github.com/llvm/llvm-project/commit/8d19af685c9b1ba50df0ed739dbfffd0aa7686ee.diff

LOG: [GWP-ASan] Use weak abort message definition.

Summary:
New shard out of the Check() function for GWP-ASan uses
android_set_abort_message. This is happily present on bionic Android,
but not Android for glibc host x86. Fix up to use the weak definition
always, so we don't have to worry.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: #sanitizers, llvm-commits, pcc, cferris

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D74142

Added: 
    

Modified: 
    compiler-rt/lib/gwp_asan/definitions.h
    compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/gwp_asan/definitions.h b/compiler-rt/lib/gwp_asan/definitions.h
index 870dd969c3a4..563c408b6315 100644
--- a/compiler-rt/lib/gwp_asan/definitions.h
+++ b/compiler-rt/lib/gwp_asan/definitions.h
@@ -15,4 +15,6 @@
 #define GWP_ASAN_UNLIKELY(X) __builtin_expect(!!(X), 0)
 #define GWP_ASAN_ALWAYS_INLINE inline __attribute__((always_inline))
 
+#define GWP_ASAN_WEAK __attribute__((weak))
+
 #endif // GWP_ASAN_DEFINITIONS_H_

diff  --git a/compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp b/compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp
index b2923512e614..68d7ee7867a9 100644
--- a/compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp
+++ b/compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp
@@ -6,11 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "gwp_asan/definitions.h"
 #include "gwp_asan/utilities.h"
 
 #ifdef ANDROID
-#include <android/set_abort_message.h>
 #include <stdlib.h>
+extern "C" GWP_ASAN_WEAK void android_set_abort_message(const char *);
 #else // ANDROID
 #include <stdio.h>
 #endif
@@ -21,7 +22,8 @@ namespace gwp_asan {
 void Check(bool Condition, const char *Message) {
   if (Condition)
     return;
-  android_set_abort_message(Message);
+  if (&android_set_abort_message != nullptr)
+    android_set_abort_message(Message);
   abort();
 }
 #else  // ANDROID


        


More information about the llvm-commits mailing list