"Reland "[hwasan] Provide aliases for c allocation functions for Fuchsia"
authorLeonard Chan <leonardchan@google.com>
Thu, 30 Mar 2023 19:55:05 +0000 (19:55 +0000)
committerLeonard Chan <leonardchan@google.com>
Thu, 30 Mar 2023 19:59:54 +0000 (19:59 +0000)
This reverts commit c5c6781428a70d1fffd00a256a237cbf5a3ccfd3.

This likely broke the android sanitizer builders prior because it
accidentally enabled interceptors for android, which they don't use, so
c-allocation functions like malloc would go through hwasan.

This reland adds the HWASAN_WITH_INTERCEPTORS check.

compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp

index ad359b1..96b57ba 100644 (file)
 #include "interception/interception.h"
 #include "sanitizer_common/sanitizer_allocator_dlsym.h"
 #include "sanitizer_common/sanitizer_allocator_interface.h"
+#include "sanitizer_common/sanitizer_mallinfo.h"
 #include "sanitizer_common/sanitizer_tls_get_addr.h"
 
-#if !SANITIZER_FUCHSIA
-
 using namespace __hwasan;
 
 struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
@@ -155,10 +154,8 @@ void *__sanitizer_malloc(uptr size) {
 
 }  // extern "C"
 
-#if HWASAN_WITH_INTERCEPTORS
+#if HWASAN_WITH_INTERCEPTORS || SANITIZER_FUCHSIA
 #  define INTERCEPTOR_ALIAS(RET, FN, ARGS...)                                 \
-    extern "C" SANITIZER_INTERFACE_ATTRIBUTE RET WRAP(FN)(ARGS)               \
-        ALIAS("__sanitizer_" #FN);                                            \
     extern "C" SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE RET FN( \
         ARGS) ALIAS("__sanitizer_" #FN)
 
@@ -183,5 +180,3 @@ INTERCEPTOR_ALIAS(int, mallopt, int cmd, int value);
 INTERCEPTOR_ALIAS(void, malloc_stats, void);
 #  endif
 #endif  // #if HWASAN_WITH_INTERCEPTORS
-
-#endif  // SANITIZER_FUCHSIA