[PATCH] D103564: [NFC][compiler-rt][hwasan] Wrap vfork interceptor with HWASAN_WITH_INTERCEPTORS

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 3 15:34:50 PDT 2021


leonardchan updated this revision to Diff 349712.
leonardchan added a comment.

In D103564#2795287 <https://reviews.llvm.org/D103564#2795287>, @mcgrathr wrote:

> I think probably the better refactoring here would be to split this file in two: one containing just the allocation functions; and a second with everything else.
> On Fuchsia, we'll use the allocation functions but none of the rest of it.  So the second whole file could just be under `#if !SANITIZER_FUCHSIA`.

I don't think we can move the `__sanitizer_*` allocation functions since they're used for aliases for their libc equivalents which require definitions in the same TU:

  /usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-4/compiler-rt/lib/hwasan/hwasan_interceptors.cpp:59:1: error: alias must point to a defined variable or function
  INTERCEPTOR_ALIAS(void *, aligned_alloc, SIZE_T alignment, SIZE_T size);
  ^
  /usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-4/compiler-rt/lib/hwasan/hwasan_interceptors.cpp:53:7: note: expanded from macro 'INTERCEPTOR_ALIAS'
        ALIAS("__sanitizer_" #FN);                                             \
        ^

Perhaps it might just be easier to just wrap the part of `hwasan_interceptors.cpp` that don't include the allocation functions with `#if !SANITIZER_FUCHSIA`, or as @eugenis suggested wrap the fork interceptor with `#if SANITIZER_ANDROID`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103564/new/

https://reviews.llvm.org/D103564

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


Index: compiler-rt/lib/hwasan/hwasan_interceptors.cpp
===================================================================
--- compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -21,6 +21,7 @@
 #include "hwasan_thread.h"
 #include "hwasan_poisoning.h"
 #include "hwasan_report.h"
+#include "sanitizer_common/sanitizer_platform_limits_fuchsia.h"
 #include "sanitizer_common/sanitizer_platform_limits_posix.h"
 #include "sanitizer_common/sanitizer_allocator.h"
 #include "sanitizer_common/sanitizer_allocator_interface.h"
@@ -175,6 +176,7 @@
   return hwasan_malloc(size, &stack);
 }
 
+#if !SANITIZER_FUCHSIA
 #if HWASAN_WITH_INTERCEPTORS
 #define INTERCEPTOR_ALIAS(RET, FN, ARGS...)                                  \
   extern "C" SANITIZER_INTERFACE_ATTRIBUTE RET WRAP(FN)(ARGS)                \
@@ -346,3 +348,11 @@
   inited = 1;
 }
 } // namespace __hwasan
+
+#else  // !SANITIZER_FUCHSIA
+
+namespace __hwasan {
+void InitializeInterceptors() {}
+}  // namespace __hwasan
+
+#endif  // !SANITIZER_FUCHSIA


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103564.349712.patch
Type: text/x-patch
Size: 1060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210603/ea38293b/attachment-0001.bin>


More information about the cfe-commits mailing list