1 // RUN: %clangxx %s -pie -fPIE -o %t && %run %t
2 // REQUIRES: x86_64-target-arch
9 for (int j
= 0; j
< 1024; j
++) {
10 // Try 1TB offsets. This attempts to find memory addresses where the
11 // shadow mappings - which assume a 47-bit address space - are invalid.
12 unsigned long long target
= (1ULL << 56) - (2 * 4096) - (j
* (1ULL << 40));
14 // Since we don't use MAP_FIXED, mmap might return an address that is
15 // lower in the address space (due to sanitizer and/or kernel limits).
16 // That is fine - if the app is also restricted from making high
17 // allocations, then they are safe.
18 char* ptr
= (char*) mmap ((void*) target
, 4096, PROT_READ
| PROT_WRITE
,
19 MAP_PRIVATE
| MAP_ANONYMOUS
, -1, 0);
20 printf ("Allocated at %p\n", ptr
);
22 assert (ptr
!= MAP_FAILED
);
23 for (int i
= 0; i
< 100; i
++) {