Fix dex file verification check for dexlayout output file.

For debug builds, we want to run the output dex file through the dex
file verifier as a sanity check. The initial check was actually checking
the input dex file again...

Bug: 36107940
Test: mm test-art-host
Change-Id: Ibd434d67f661c325a443d4ca9cced481e7a9b02c
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index 3ce7e1a..c0f69f4 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -1725,6 +1725,19 @@
   if (new_file != nullptr) {
     UNUSED(new_file->FlushCloseOrErase());
   }
+  // Verify the output dex file is ok on debug builds.
+  if (kIsDebugBuild) {
+    std::string location = "memory mapped file for " + dex_file_location;
+    std::unique_ptr<const DexFile> dex_file(DexFile::Open(mem_map_->Begin(),
+                                                          mem_map_->Size(),
+                                                          location,
+                                                          header_->Checksum(),
+                                                          /*oat_dex_file*/ nullptr,
+                                                          /*verify*/ true,
+                                                          /*verify_checksum*/ false,
+                                                          &error_msg));
+    DCHECK(dex_file != nullptr) << "Failed to re-open output file:" << error_msg;
+  }
 }
 
 /*
@@ -1757,16 +1770,6 @@
       LayoutOutputFile(dex_file);
     }
     OutputDexFile(dex_file->GetLocation());
-    // Verify the output dex file is ok on debug builds.
-    if (kIsDebugBuild) {
-      std::string error_msg;
-      DCHECK(DexFileVerifier::Verify(dex_file,
-                                     dex_file->Begin(),
-                                     dex_file->Size(),
-                                     dex_file->GetLocation().c_str(),
-                                     false,
-                                     &error_msg));
-    }
   }
 }