am 46bf467a: am f5f29de6: Merge "Fix bionic linker to support segments with zero p_filesz"

* commit '46bf467a151eafaf37f6e3578d8d9bad705b8e44':
  Fix bionic linker to support segments with zero p_filesz
This commit is contained in:
Brian Carlstrom 2013-05-21 17:28:40 -07:00 committed by Android Git Automerger
commit 47b2e046cd

View File

@ -320,16 +320,19 @@ bool ElfReader::LoadSegments() {
Elf32_Addr file_end = file_start + phdr->p_filesz;
Elf32_Addr file_page_start = PAGE_START(file_start);
Elf32_Addr file_length = file_end - file_page_start;
void* seg_addr = mmap((void*)seg_page_start,
file_end - file_page_start,
PFLAGS_TO_PROT(phdr->p_flags),
MAP_FIXED|MAP_PRIVATE,
fd_,
file_page_start);
if (seg_addr == MAP_FAILED) {
DL_ERR("couldn't map \"%s\" segment %d: %s", name_, i, strerror(errno));
return false;
if (file_length != 0) {
void* seg_addr = mmap((void*)seg_page_start,
file_length,
PFLAGS_TO_PROT(phdr->p_flags),
MAP_FIXED|MAP_PRIVATE,
fd_,
file_page_start);
if (seg_addr == MAP_FAILED) {
DL_ERR("couldn't map \"%s\" segment %d: %s", name_, i, strerror(errno));
return false;
}
}
// if the segment is writable, and does not end on a page boundary,