[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / mmap_56bit_test.c
blobb14ac7bcf1924f2005a3a64e4e374ad61e0447a8
1 // RUN: %clangxx %s -pie -fPIE -o %t && %run %t
2 // REQUIRES: x86_64-target-arch
4 #include <assert.h>
5 #include <stdio.h>
6 #include <sys/mman.h>
8 int main() {
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++) {
24 ptr [i] = 0;
26 munmap (ptr, 4096);
29 return 0;