Skip to content

Commit 91f2078

Browse files
committed
Seems hackish
1 parent 5908e16 commit 91f2078

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/patchelf.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,9 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
914914

915915
/* Calculate how many bytes are needed out of the additional pages. */
916916
size_t extraSpace = neededSpace - startOffset;
917-
unsigned int neededPages = roundUp(extraSpace, getPageSize()) / getPageSize();
917+
// Always give one extra page to avoid colliding with segments that start at
918+
// unaligned addresses and will be rounded down when loaded
919+
unsigned int neededPages = 1 + roundUp(extraSpace, getPageSize()) / getPageSize();
918920
debug("needed pages is %d\n", neededPages);
919921
if (neededPages * getPageSize() > firstPage)
920922
error("virtual address space underrun!");

0 commit comments

Comments
 (0)