1 // Test that a module constructor can not map memory over the MSan heap
2 // (without MAP_FIXED, of course). Current implementation ensures this by
3 // mapping the heap early, in __msan_init.
5 // RUN: %clangxx_msan -O0 %s -o %t_1
6 // RUN: %clangxx_msan -O0 -DHEAP_ADDRESS=$(%run %t_1) %s -o %t_2 && %run %t_2
8 // This test only makes sense for the 64-bit allocator. The 32-bit allocator
9 // does not have a fixed mapping. Exclude platforms that use the 32-bit
11 // UNSUPPORTED: target-is-mips64,target-is-mips64el,target=aarch64{{.*}}
21 void *const hint
= reinterpret_cast<void *>(HEAP_ADDRESS
);
22 void *p
= mmap(hint
, 4096, PROT_READ
| PROT_WRITE
,
23 MAP_PRIVATE
| MAP_ANONYMOUS
, -1, 0);
24 // This address must be already mapped. Check that mmap() succeeds, but at a
26 assert(p
!= reinterpret_cast<void *>(-1));
34 printf("0x%zx\n", reinterpret_cast<size_t>(p
) & (~0xfff));