From c2ccad023fc8c8a9a13adaad654d1a210cf70ec7 Mon Sep 17 00:00:00 2001
From: Jason Hiser <jdhiser@gmail.com>
Date: Thu, 27 Dec 2018 15:19:08 -0500
Subject: [PATCH] plop bytes from scoops into text segment before pinning in
 case scoops overlap text.

---
 src/zipr.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/zipr.cpp b/src/zipr.cpp
index a708a4f..9dd854e 100644
--- a/src/zipr.cpp
+++ b/src/zipr.cpp
@@ -735,6 +735,21 @@ void ZiprImpl_t::FindFreeRanges(const std::string &name)
 	if (m_verbose)
 		printf("Adding (mysterious) free range 0x%p to EOF\n", (void*)new_free_page);
 	start_of_new_space=new_free_page;
+
+	for(auto scoop : m_firp->GetDataScoops())
+	{
+		if(scoop->isExecuteable()) continue;
+		// put scoops in memory to make sure they are busy,
+		// just in case they overlap with free ranges.
+		// this came up on Aarch64 because data is in the .text segment.
+		cout<<"Pre-allocating scoop "<<scoop->GetName() << "=("
+		    << scoop->GetStart()->GetVirtualOffset() << "-" 
+		    << scoop->GetEnd()  ->GetVirtualOffset() << ")"<<endl;
+		memory_space.PlopBytes(scoop->GetStart()->GetVirtualOffset(), 
+		                       scoop->GetContents().c_str(),
+				       scoop->GetContents().size()
+				      );
+	}
 }
 
 
-- 
GitLab