[compiler-rt] [rtsan] Intercept aligned_alloc on all versions of OSX if available on build machine (PR #112780)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 10:28:46 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
----------------
fmayer wrote:

I meant something like this in appropriate place

```
#if SANITIZER_APPLE
#undef SANITIZER_INTERCEPT_ALIGNED_ALLOC
#define SANITIZER_INTERCEPT_ALIGNED_ALLOC 1
#endif
```

https://github.com/llvm/llvm-project/pull/112780


More information about the llvm-commits mailing list