[compiler-rt] [rtsan] Intercept aligned_alloc on all versions of OSX if available on build machine (PR #112780)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 19:26:30 PDT 2024
================
@@ -461,7 +461,17 @@ INTERCEPTOR(void *, valloc, SIZE_T size) {
return REAL(valloc)(size);
}
-#if SANITIZER_INTERCEPT_ALIGNED_ALLOC
+// aligned_alloc was introduced in OSX 10.15
+// Linking will fail when using an older SDK
+#if defined(__MAC_10_15)
+// macOS 10.15 is greater than our minimal deployment target. To ensure we
+// generate a weak reference so the dylib continues to work on older
+// systems, we need to forward declare the intercepted function as "weak
+// imports".
+SANITIZER_WEAK_IMPORT void *aligned_alloc(SIZE_T __alignment, SIZE_T __size);
+#endif // defined(__MAC_10_15)
+
+#if SANITIZER_INTERCEPT_ALIGNED_ALLOC || SANITIZER_APPLE
----------------
cjappl wrote:
Definitely, but this has a much bigger implications that touch almost all of the other sanitizers. The majority of them that care about allocations assume this is linux only, and don't have this WEAK_IMPORT thing.
I opened this thread to discuss bubbling this up, which I agree is the ideal end goal.
https://discourse.llvm.org/t/should-aligned-alloc-be-intercepted-on-osx/82599
https://github.com/llvm/llvm-project/pull/112780
More information about the llvm-commits
mailing list