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

Mitch Phillips via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 6 10:23:00 PST 2020


hctim created this revision.
hctim added a reviewer: eugenis.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74142

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


Index: compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp
===================================================================
--- compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp
+++ compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp
@@ -6,11 +6,13 @@
 //
 //===----------------------------------------------------------------------===//
 
+#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
@@ -19,7 +21,7 @@
 
 #ifdef ANDROID
 void Check(bool Condition, const char *Message) {
-  if (Condition)
+  if (Condition || &android_set_abort_message == nullptr)
     return;
   android_set_abort_message(Message);
   abort();
Index: compiler-rt/lib/gwp_asan/definitions.h
===================================================================
--- compiler-rt/lib/gwp_asan/definitions.h
+++ 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_


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74142.242939.patch
Type: text/x-patch
Size: 1300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200206/5887a445/attachment.bin>


More information about the llvm-commits mailing list