From 709cd64ca1d3442cc396f14cfb38d2f6b1196351 Mon Sep 17 00:00:00 2001
From: Jason Hiser <jdh8d@virginia.edu>
Date: Fri, 26 Oct 2018 08:00:46 -0400
Subject: [PATCH] fixed off-by-one error in getting segment to be extended in
 gapallocate

---
 src/elfwrite.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/elfwrite.cpp b/src/elfwrite.cpp
index a22fd61..89e68b2 100644
--- a/src/elfwrite.cpp
+++ b/src/elfwrite.cpp
@@ -406,7 +406,7 @@ bool ElfWriterImpl<T_Elf_Ehdr,T_Elf_Phdr,T_Elf_Addr,T_Elf_Shdr,T_Elf_Sym, T_Elf_
 	}
 
 	// find segment
-	int new_phdr_segment_index=locate_segment_index(new_phdr_addr);
+	int new_phdr_segment_index=locate_segment_index(new_phdr_addr-1);
 
 	// if there's no segment for the start, we'll have to allocate a page anyhow.  just use the _Preallocate routine.
 	if(new_phdr_segment_index==-1)
-- 
GitLab