diff --git a/compiler-rt/lib/dfsan/dfsan.cpp b/compiler-rt/lib/dfsan/dfsan.cpp --- a/compiler-rt/lib/dfsan/dfsan.cpp +++ b/compiler-rt/lib/dfsan/dfsan.cpp @@ -442,8 +442,10 @@ ::InitializePlatformEarly(); - if (!MmapFixedNoReserve(ShadowAddr(), UnusedAddr() - ShadowAddr())) + if (!MmapFixedSuperNoReserve(ShadowAddr(), UnusedAddr() - ShadowAddr())) Die(); + if (common_flags()->use_madv_dontdump) + DontDumpShadowMemory(ShadowAddr(), UnusedAddr() - ShadowAddr()); // Protect the region of memory we don't use, to preserve the one-to-one // mapping from application to shadow memory. But if ASLR is disabled, Linux @@ -451,8 +453,9 @@ // works so long as the program doesn't use too much memory. We support this // case by disabling memory protection when ASLR is disabled. uptr init_addr = (uptr)&dfsan_init; - if (!(init_addr >= UnusedAddr() && init_addr < AppAddr())) + if (!(init_addr >= UnusedAddr() && init_addr < AppAddr())) { MmapFixedNoAccess(UnusedAddr(), AppAddr() - UnusedAddr()); + } InitializeInterceptors(); diff --git a/compiler-rt/test/dfsan/release_shadow_space.c b/compiler-rt/test/dfsan/release_shadow_space.c --- a/compiler-rt/test/dfsan/release_shadow_space.c +++ b/compiler-rt/test/dfsan/release_shadow_space.c @@ -1,4 +1,5 @@ -// RUN: %clang_dfsan %s -o %t && %run %t +// DFSAN_OPTIONS=no_huge_pages_for_shadow=false RUN: %clang_dfsan %s -o %t && %run %t +// DFSAN_OPTIONS=no_huge_pages_for_shadow=true RUN: %clang_dfsan %s -o %t && %run %t #include #include