From 4fb5df8453367aa3f160ac230c03a7a98a28e562 Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Thu, 13 Mar 2014 15:10:27 -0700 Subject: Make MemMap::MapAnonymous() fail if the requested address is not available. Change MapAnonymous() so that a requested address vs. actual map address mismatch will cause a failure. The existing MapAnonymous() call sites do not check this. This should prevent potential rare case bugs where mmap does not happen to map a region at an specified address. There's a potential bug that if MapAnonymous() does not guarantee the requested address (and there's a gap between the image/oat files and the zygote/malloc space), then GC could in theory allocate a large object space in the gap. This would break the GC notion of the immune space. This change will prevent this by causing all non-moving spaces to be (really) adjacent, with no gaps in between, which CL 87711 missed. Change-Id: Id4adb0e30adbad497334d7e00def4c0c66b15719 --- runtime/elf_file.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/elf_file.cc') diff --git a/runtime/elf_file.cc b/runtime/elf_file.cc index 4de46e368b..0c8a4f044b 100644 --- a/runtime/elf_file.cc +++ b/runtime/elf_file.cc @@ -835,7 +835,7 @@ bool ElfFile::Load(bool executable, std::string* error_msg) { if ((program_header.p_flags & PF_R) != 0) { prot |= PROT_READ; } - int flags = MAP_FIXED; + int flags = 0; if (writable_) { prot |= PROT_WRITE; flags |= MAP_SHARED; @@ -853,7 +853,7 @@ bool ElfFile::Load(bool executable, std::string* error_msg) { program_header.p_memsz, prot, flags, file_->Fd(), program_header.p_offset, - true, + true, // implies MAP_FIXED file_->GetPath().c_str(), error_msg)); if (segment.get() == nullptr) { -- cgit v1.2.3-59-g8ed1b