1 // RUN: %clang_dfsan -fno-sanitize=dataflow -DCALLOC -c %s -o %t-calloc.o
2 // RUN: %clang_dfsan %s %t-calloc.o -o %t
5 // Tests that calling mmap() during during dfsan initialization works.
7 #include <sanitizer/dfsan_interface.h>
13 extern void exit(int) __attribute__((noreturn
));
15 // dfsan_init() installs interceptors via dlysm(), which calls calloc().
16 // Calling mmap() from here should work even if interceptors haven't been fully
18 void *calloc(size_t Num
, size_t Size
) {
19 size_t PageSize
= getpagesize();
21 Size
= (Size
+ PageSize
- 1) & ~(PageSize
- 1); // Round up to PageSize.
22 void *Ret
= mmap(NULL
, Size
, PROT_READ
| PROT_WRITE
,
23 MAP_PRIVATE
| MAP_ANONYMOUS
, -1, 0);
24 // Use assert may cause link errors that require -Wl,-z,notext.
25 // Do not know the root cause yet.
26 if (Ret
== MAP_FAILED
) exit(-1);
32 int main() { return 0; }