[compiler-rt] 1850a7a - [asan][test] Additional test requiring weak symbol for dyld64.

Roy Sundahl via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 13:57:49 PDT 2022


Author: Roy Sundahl
Date: 2022-07-25T13:56:02-07:00
New Revision: 1850a7a9ca355d8edcf80e24cdd4bb6522990664

URL: https://github.com/llvm/llvm-project/commit/1850a7a9ca355d8edcf80e24cdd4bb6522990664
DIFF: https://github.com/llvm/llvm-project/commit/1850a7a9ca355d8edcf80e24cdd4bb6522990664.diff

LOG: [asan][test] Additional test requiring weak symbol for dyld64.

Extension of D127929

rdar://80997227

Differential Revision: https://reviews.llvm.org/D130499

Added: 
    

Modified: 
    compiler-rt/test/asan/TestCases/Posix/free_hook_realloc.cpp
    compiler-rt/test/memprof/TestCases/free_hook_realloc.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/TestCases/Posix/free_hook_realloc.cpp b/compiler-rt/test/asan/TestCases/Posix/free_hook_realloc.cpp
index cbc5d6fed56ef..9242c9477564b 100644
--- a/compiler-rt/test/asan/TestCases/Posix/free_hook_realloc.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/free_hook_realloc.cpp
@@ -8,14 +8,17 @@
 
 static void *glob_ptr;
 
-extern "C" {
-void __sanitizer_free_hook(const volatile void *ptr) {
+// Required for dyld macOS 12.0+
+#if (__APPLE__)
+__attribute__((weak))
+#endif
+extern "C" void
+__sanitizer_free_hook(const volatile void *ptr) {
   if (ptr == glob_ptr) {
     *(int*)ptr = 0;
     write(1, "FreeHook\n", sizeof("FreeHook\n"));
   }
 }
-}
 
 int main() {
   int *x = (int*)malloc(100);

diff  --git a/compiler-rt/test/memprof/TestCases/free_hook_realloc.cpp b/compiler-rt/test/memprof/TestCases/free_hook_realloc.cpp
index 6ed348306a0d4..85e29a372fdff 100644
--- a/compiler-rt/test/memprof/TestCases/free_hook_realloc.cpp
+++ b/compiler-rt/test/memprof/TestCases/free_hook_realloc.cpp
@@ -7,14 +7,18 @@
 
 static void *glob_ptr;
 
-extern "C" {
-void __sanitizer_free_hook(const volatile void *ptr) {
+// (Speculative fix if memprof is enabled on Apple platforms)
+// Required for dyld macOS 12.0+
+#if (__APPLE__)
+__attribute__((weak))
+#endif
+extern "C" void
+__sanitizer_free_hook(const volatile void *ptr) {
   if (ptr == glob_ptr) {
     *(int *)ptr = 0;
     write(1, "FreeHook\n", sizeof("FreeHook\n"));
   }
 }
-}
 
 int main() {
   int *x = (int *)malloc(100);


        


More information about the llvm-commits mailing list