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.
This commit is contained in:
Ingo Weinhold 2013-12-01 00:58:28 +01:00
parent 97a4e3202f
commit 84ed99c2aa

View File

@ -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;