summaryrefslogtreecommitdiff
path: root/src/patchelf.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/patchelf.cc')
-rw-r--r--src/patchelf.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc
index 62af389..1a90edb 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -1019,7 +1019,9 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
/* Calculate how many bytes are needed out of the additional pages. */
size_t extraSpace = neededSpace - startOffset;
- unsigned int neededPages = roundUp(extraSpace, getPageSize()) / getPageSize();
+ // Always give one extra page to avoid colliding with segments that start at
+ // unaligned addresses and will be rounded down when loaded
+ unsigned int neededPages = 1 + roundUp(extraSpace, getPageSize()) / getPageSize();
debug("needed pages is %d\n", neededPages);
if (neededPages * getPageSize() > firstPage)
error("virtual address space underrun!");