From: Jan Vorlicek Date: Tue, 9 May 2017 18:30:59 +0000 (+0200) Subject: Stop loading crossgen-ed binaries at preferred address on Unix (#11467) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ce30c0e3b17555459b936fe61f527b175b0035e;p=platform%2Fupstream%2Fcoreclr.git Stop loading crossgen-ed binaries at preferred address on Unix (#11467) This change removes attempt to load crossgen-ed binaries at preferred address on Unix and uses whatever address the mmap returns instead. --- diff --git a/src/pal/src/map/map.cpp b/src/pal/src/map/map.cpp index f3172c3bbc..f26293bea3 100644 --- a/src/pal/src/map/map.cpp +++ b/src/pal/src/map/map.cpp @@ -2440,22 +2440,21 @@ void * MAPMapPEFile(HANDLE hFile) // We're going to start adding mappings to the mapping list, so take the critical section InternalEnterCriticalSection(pThread, &mapping_critsec); -#if !defined(_AMD64_) - loadedBase = mmap((void*)preferredBase, virtualSize, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0); -#else // defined(_AMD64_) +#ifdef BIT64 // First try to reserve virtual memory using ExecutableAllcator. This allows all PE images to be // near each other and close to the coreclr library which also allows the runtime to generate // more efficient code (by avoiding usage of jump stubs). Alignment to a 64 KB granularity should // not be necessary (alignment to page size should be sufficient), but see // ExecutableMemoryAllocator::AllocateMemory() for the reason why it is done. loadedBase = ReserveMemoryFromExecutableAllocator(pThread, ALIGN_UP(virtualSize, VIRTUAL_64KB)); +#endif // BIT64 + if (loadedBase == NULL) { // MAC64 requires we pass MAP_SHARED (or MAP_PRIVATE) flags - otherwise, the call is failed. // Refer to mmap documentation at http://www.manpagez.com/man/2/mmap/ for details. - loadedBase = mmap((void*)preferredBase, virtualSize, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0); + loadedBase = mmap(NULL, virtualSize, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0); } -#endif // !defined(_AMD64_) if (MAP_FAILED == loadedBase) {