mirror of
https://github.com/NixOS/patchelf.git
synced 2025-10-23 09:47:51 +08:00
merge from PR243
This commit is contained in:
@@ -772,12 +772,15 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
|
||||
PT_LOAD segment located directly after the last virtual address
|
||||
page of other segments. */
|
||||
Elf_Addr startPage = 0;
|
||||
Elf_Addr firstPage = 0;
|
||||
for (auto & phdr : phdrs) {
|
||||
Elf_Addr thisPage = roundUp(rdi(phdr.p_vaddr) + rdi(phdr.p_memsz), getPageSize());
|
||||
if (thisPage > startPage) startPage = thisPage;
|
||||
if (rdi(phdr.p_type) == PT_PHDR) firstPage = rdi(phdr.p_vaddr) - rdi(phdr.p_offset);
|
||||
}
|
||||
|
||||
debug("last page is 0x%llx\n", (unsigned long long) startPage);
|
||||
debug("first page is 0x%llx\n", (unsigned long long) firstPage);
|
||||
|
||||
/* When normalizing note segments we will in the worst case be adding
|
||||
1 program header for each SHT_NOTE section. */
|
||||
@@ -848,7 +851,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
|
||||
assert(curOff == startOffset + neededSpace);
|
||||
|
||||
/* Write out the updated program and section headers */
|
||||
rewriteHeaders(rdi(hdr->e_phoff));
|
||||
rewriteHeaders(firstPage + hdr->e_phoff);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user