From 84ed99c2aadf0a4fd233e134f8205a17219101d8 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 1 Dec 2013 00:58:28 +0100 Subject: [PATCH] mmap(): Fix !MAP_FIXED with non-NULL address case In that case the caller ideally wants to obtain an allocation at the specified address, which was thwarted by using B_RANDOMIZED_BASE_ADDRESS. Use B_BASE_ADDRESS instead. This improves the experience with the gcc 4 pre-compiled headers implementation (which expects to be able to map the PCH file at the same address where it was located originally when it had been created), but doesn't fix it completely. As long as ASLR is active, it is always possible that something else (mapped shared objects, heap, stack) is in the way. --- src/system/libroot/posix/sys/mman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/libroot/posix/sys/mman.cpp b/src/system/libroot/posix/sys/mman.cpp index 68dbf0a7a2..af23c37e69 100644 --- a/src/system/libroot/posix/sys/mman.cpp +++ b/src/system/libroot/posix/sys/mman.cpp @@ -117,7 +117,7 @@ mmap(void* address, size_t length, int protection, int flags, int fd, if ((flags & MAP_FIXED) != 0) addressSpec = B_EXACT_ADDRESS; else if (address != NULL) - addressSpec = B_RANDOMIZED_BASE_ADDRESS; + addressSpec = B_BASE_ADDRESS; else addressSpec = B_RANDOMIZED_ANY_ADDRESS;