[PATCH] D145718: [hwasan] Provide aliases for c allocation functions for Fuchsia

Leonard Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 9 12:27:54 PST 2023


leonardchan created this revision.
leonardchan added reviewers: mcgrathr, vitalybuka, eugenis.
leonardchan added a project: Sanitizers.
Herald added subscribers: Enna1, abrachet, jeroen.dobbelaere.
Herald added a project: All.
leonardchan requested review of this revision.
Herald added a subscriber: Sanitizers.

"Interceptors" in this file aren't like the traditional interceptors used by other sanitizers like asan. They're simply aliases to the equivalent `__sanitizer_*` functions.

This also removes the `WRAP(FN)` declaration since it just creates declarations for `__interceptor_*` functions but they seem to be unused.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145718

Files:
  compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp


Index: compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
===================================================================
--- compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
+++ compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
@@ -18,8 +18,6 @@
 #include "sanitizer_common/sanitizer_allocator_interface.h"
 #include "sanitizer_common/sanitizer_tls_get_addr.h"
 
-#if !SANITIZER_FUCHSIA
-
 using namespace __hwasan;
 
 struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
@@ -106,6 +104,7 @@
   return __sanitizer_get_allocated_size(ptr);
 }
 
+#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
 SANITIZER_INTERFACE_ATTRIBUTE
 struct __sanitizer_struct_mallinfo __sanitizer_mallinfo() {
   __sanitizer_struct_mallinfo sret;
@@ -115,6 +114,7 @@
 
 SANITIZER_INTERFACE_ATTRIBUTE
 int __sanitizer_mallopt(int cmd, int value) { return 0; }
+#endif  // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
 
 SANITIZER_INTERFACE_ATTRIBUTE
 void __sanitizer_malloc_stats(void) {
@@ -155,12 +155,9 @@
 
 }  // extern "C"
 
-#if HWASAN_WITH_INTERCEPTORS
-#  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)
+#define INTERCEPTOR_ALIAS(RET, FN, ARGS...)                                 \
+  extern "C" SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE RET FN( \
+      ARGS) ALIAS("__sanitizer_" #FN)
 
 INTERCEPTOR_ALIAS(int, posix_memalign, void **memptr, SIZE_T alignment,
                   SIZE_T size);
@@ -178,10 +175,9 @@
 INTERCEPTOR_ALIAS(void *, memalign, SIZE_T alignment, SIZE_T size);
 INTERCEPTOR_ALIAS(void *, pvalloc, SIZE_T size);
 INTERCEPTOR_ALIAS(void, cfree, void *ptr);
+#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
 INTERCEPTOR_ALIAS(__sanitizer_struct_mallinfo, mallinfo);
 INTERCEPTOR_ALIAS(int, mallopt, int cmd, int value);
+#endif
 INTERCEPTOR_ALIAS(void, malloc_stats, void);
 #  endif
-#endif  // #if HWASAN_WITH_INTERCEPTORS
-
-#endif  // SANITIZER_FUCHSIA


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145718.503877.patch
Type: text/x-patch
Size: 2202 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230309/344f813d/attachment.bin>


More information about the llvm-commits mailing list