[compiler-rt] 87a6325 - [dfsan] Rename and fix an internal test issue for mmap+calloc

Jianzhou Zhao via llvm-commits llvm-commits at lists.llvm.org
Thu May 6 17:58:49 PDT 2021


Author: Jianzhou Zhao
Date: 2021-05-07T00:57:21Z
New Revision: 87a6325fbe4315f3f24555797f216e96539a9397

URL: https://github.com/llvm/llvm-project/commit/87a6325fbe4315f3f24555797f216e96539a9397
DIFF: https://github.com/llvm/llvm-project/commit/87a6325fbe4315f3f24555797f216e96539a9397.diff

LOG: [dfsan] Rename and fix an internal test issue for mmap+calloc

The linker suggests using -Wl,-z,notext.

Replaced assert by exit also fixed this.

After renaming, interceptor.c would be used to test interceptors in general by D101204.

Reviewed By: morehouse

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

Added: 
    compiler-rt/test/dfsan/mmap_at_init.c

Modified: 
    

Removed: 
    compiler-rt/test/dfsan/interceptors.c


################################################################################
diff  --git a/compiler-rt/test/dfsan/interceptors.c b/compiler-rt/test/dfsan/mmap_at_init.c
similarity index 86%
rename from compiler-rt/test/dfsan/interceptors.c
rename to compiler-rt/test/dfsan/mmap_at_init.c
index d0961383e93f..913602e13e7c 100644
--- a/compiler-rt/test/dfsan/interceptors.c
+++ b/compiler-rt/test/dfsan/mmap_at_init.c
@@ -6,9 +6,7 @@
 //
 // Tests that calling mmap() during during dfsan initialization works.
 
-#include <assert.h>
 #include <sanitizer/dfsan_interface.h>
-#include <string.h>
 #include <sys/mman.h>
 #include <unistd.h>
 
@@ -23,7 +21,9 @@ void *calloc(size_t Num, size_t Size) {
   Size = (Size + PageSize - 1) & ~(PageSize - 1); // Round up to PageSize.
   void *Ret = mmap(NULL, Size, PROT_READ | PROT_WRITE,
                    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-  assert(Ret != MAP_FAILED);
+  // Use assert may cause link errors that require -Wl,-z,notext.
+  // Do not know the root cause yet.
+  if (Ret == MAP_FAILED) exit(-1);
   return Ret;
 }
 


        


More information about the llvm-commits mailing list