Add low_4gb support to MapFile and MapFileAtAddress

Motivation is to use this for loading app images in low 4GB at a
non fixed address.

Added test.

Bug: 22858531
Change-Id: I0f79a4a7bfbfbdfc112e41b25c8682b1fb932ab7
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index 88622cc..64b4722 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -177,8 +177,12 @@
   t.NewTiming("Image and oat Patching setup");
   // Create the map where we will write the image patches to.
   std::string error_msg;
-  std::unique_ptr<MemMap> image(MemMap::MapFile(image_len, PROT_READ | PROT_WRITE, MAP_PRIVATE,
-                                                input_image->Fd(), 0,
+  std::unique_ptr<MemMap> image(MemMap::MapFile(image_len,
+                                                PROT_READ | PROT_WRITE,
+                                                MAP_PRIVATE,
+                                                input_image->Fd(),
+                                                0,
+                                                /*low_4gb*/false,
                                                 input_image->GetPath().c_str(),
                                                 &error_msg));
   if (image.get() == nullptr) {
@@ -187,8 +191,7 @@
   }
   gc::space::ImageSpace* ispc = Runtime::Current()->GetHeap()->GetImageSpace();
 
-  PatchOat p(isa, image.release(), ispc->GetLiveBitmap(), ispc->GetMemMap(),
-             delta, timings);
+  PatchOat p(isa, image.release(), ispc->GetLiveBitmap(), ispc->GetMemMap(), delta, timings);
   t.NewTiming("Patching files");
   if (!p.PatchImage()) {
     LOG(ERROR) << "Failed to patch image file " << input_image->GetPath();
@@ -273,8 +276,12 @@
   t.NewTiming("Image and oat Patching setup");
   // Create the map where we will write the image patches to.
   std::string error_msg;
-  std::unique_ptr<MemMap> image(MemMap::MapFile(image_len, PROT_READ | PROT_WRITE, MAP_PRIVATE,
-                                                input_image->Fd(), 0,
+  std::unique_ptr<MemMap> image(MemMap::MapFile(image_len,
+                                                PROT_READ | PROT_WRITE,
+                                                MAP_PRIVATE,
+                                                input_image->Fd(),
+                                                0,
+                                                /*low_4gb*/false,
                                                 input_image->GetPath().c_str(),
                                                 &error_msg));
   if (image.get() == nullptr) {