Fix bionic linker to support segments with zero p_filesz

(cherry picked from commit 96362fb9d11beef6233aa03db396f25688e70860)

Change-Id: Ib075a6dfc45d5d0746d8b278f317dd9b8d772f2a
This commit is contained in:
Brian Carlstrom
2013-05-21 16:49:24 -07:00
parent 2e317075b0
commit 82dcc7910d

View File

@@ -320,9 +320,11 @@ 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;
if (file_length != 0) {
void* seg_addr = mmap((void*)seg_page_start,
file_end - file_page_start,
file_length,
PFLAGS_TO_PROT(phdr->p_flags),
MAP_FIXED|MAP_PRIVATE,
fd_,
@@ -331,6 +333,7 @@ bool ElfReader::LoadSegments() {
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,
// zero-fill it until the page limit.