Add shared separate data section for compact dex
Added a shared dex data buffer for compact dex files, this buffer
is referenced by all compact dex files in a vdex file. Repurposed
the existing data_off / data_size fields in the header.
After the shared buffer is filled up, it is placed after the dex
files in the oat writer and the dex file headers are fixed up to have
the correct offsets / sizes to the shared buffer.
Motivation:
Make it easy to deduplicate data across dexes.
Bug: 63756964
Test: test-art-host
Change-Id: I17855a0c78b20be3d323d12dedb9c695962be3ed
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index f2a69f3..f7151b3 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -1156,6 +1156,7 @@
// Vdex unquicken output should match original input bytecode
uint32_t orig_checksum =
reinterpret_cast<DexFile::Header*>(const_cast<uint8_t*>(dex_file->Begin()))->checksum_;
+ CHECK_EQ(orig_checksum, dex_file->CalculateChecksum());
if (orig_checksum != dex_file->CalculateChecksum()) {
os << "Unexpected checksum from unquicken dex file '" << dex_file_location << "'\n";
return false;
@@ -1208,7 +1209,11 @@
return false;
}
- if (!file->WriteFully(dex_file->Begin(), fsize)) {
+ bool success = false;
+ success = file->WriteFully(dex_file->Begin(), fsize);
+ // }
+
+ if (!success) {
os << "Failed to write dex file";
file->Erase();
return false;