Chromium Code Reviews| Index: third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.cpp |
| diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.cpp |
| index 13221817c946c383a81e414ac03814bc93471a57..03589fc944bf654b4db0c5c4768b4c5170b557a8 100644 |
| --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.cpp |
| +++ b/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.cpp |
| @@ -181,7 +181,9 @@ bool ElfLoader::ReadProgramHeader(Error* error) { |
| // segments of a program header table. This is done by creating a |
| // private anonymous mmap() with PROT_NONE. |
| // |
| -// This will use the wanted_load_address_ value, |
| +// This will use the wanted_load_address_ value. Fails if the requested |
| +// address range cannot be reserved. Typically this would be because |
| +// it overlaps an existing, possibly system, mapping. |
| bool ElfLoader::ReserveAddressSpace(Error* error) { |
| ELF::Addr min_vaddr; |
| load_size_ = |
| @@ -197,7 +199,6 @@ bool ElfLoader::ReserveAddressSpace(Error* error) { |
| // Support loading at a fixed address. |
| if (wanted_load_address_) { |
| addr = static_cast<uint8_t*>(wanted_load_address_); |
| - mmap_flags |= MAP_FIXED; |
| } |
| LOG("%s: address=%p size=%p\n", __FUNCTION__, addr, load_size_); |
| @@ -206,6 +207,11 @@ bool ElfLoader::ReserveAddressSpace(Error* error) { |
| error->Format("Could not reserve %d bytes of address space", load_size_); |
| return false; |
|
pasko
2014/09/10 18:46:17
Random suggestion:
Printing /proc/self/maps to lo
|
| } |
| + if (wanted_load_address_ && start != addr) { |
| + error->Format("Could not map at %p requested, backing out", addr); |
| + munmap(start, load_size_); |
| + return false; |
| + } |
| load_start_ = start; |
| load_bias_ = reinterpret_cast<ELF::Addr>(start) - min_vaddr; |