Extract dex file if it is uncompressed but unaligned
A dex file would normally only be left in the zip file if it was both
uncompressed and unaligned, but explicitly setting CopyOptions::kNever
through --copy-dex-file=false would only check if the dex file was
uncompressed, not if it was aligned. Add a required alignment
argument to ZipEntry::MapDirectlyOrExtract so that the contents
will be extracted into memory if they don't meet the alignment
requirement.
Bug: 119412419
Test: m test-art-host-gtest-oat_writer_test
Change-Id: I4587e22165ee0a951ffca7db9a6f5c0d1ed2e56a
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 12a8354..904ed7f 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1400,7 +1400,8 @@
MemMap input_file = zip_entry->MapDirectlyOrExtract(
VdexFile::kVdexNameInDmFile,
kDexMetadata,
- &error_msg);
+ &error_msg,
+ alignof(VdexFile));
if (!input_file.IsValid()) {
LOG(WARNING) << "Could not open vdex file in DexMetadata archive: " << error_msg;
} else {