am f5f29de6
: Merge "Fix bionic linker to support segments with zero p_filesz"
* commit 'f5f29de6ae5a0b74234f111b5691a1e5588671cb': Fix bionic linker to support segments with zero p_filesz
This commit is contained in:
commit
46bf467a15
1 changed files with 12 additions and 9 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue