From deb109a10516a9e95563a334c8ab7c3062afbdde Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 6 Apr 2010 09:11:42 +0000 Subject: * Segments can have a zero alignment, causing a divide-by-zero error. Ignore those. (Contributed by Zack Weinberg.) --- src/patchelf.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/patchelf.cc b/src/patchelf.cc index 31da196..26d5805 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -384,7 +384,8 @@ void ElfFile::shiftFile(unsigned int extraPages, Elf_Addr sta /* Update the offsets in the program headers. */ for (int i = 0; i < rdi(hdr->e_phnum); ++i) { wri(phdrs[i].p_offset, rdi(phdrs[i].p_offset) + shift); - if ((phdrs[i].p_vaddr - phdrs[i].p_offset) % phdrs[i].p_align != 0) { + if (phdrs[i].p_align != 0 && + (phdrs[i].p_vaddr - phdrs[i].p_offset) % phdrs[i].p_align != 0) { debug("changing alignment of program header %d from %d to %d\n", i, phdrs[i].p_align, pageSize); phdrs[i].p_align = pageSize; -- cgit v0.12