Set the location checksum in vdex.
The checksum we check against at runtime isn't the dex checksum
if we are compiling a jar/apk, but the crc32 of the entry.
This is to optimize the check at startup and avoid reading the
contents of the zip file.
Because with vdex we do not want to open the zip file, (the test
has been done already in getDexOptNeeded), and cannot rely
on the .oat file for fetching it, put the location checksum in
the vdex directly.
Note for later refactorings: the dex checksum location is now
in the vdex file, but also in the oat file. This can be revisited
after we eventually cleanup OatDexFile.
Test: 629-vdex
bug: 30937355
Change-Id: I7af8ca63b889370c660d694dd4eb95e78f566a1c
diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h
index 0dcf79e..da221d6 100644
--- a/compiler/oat_writer.h
+++ b/compiler/oat_writer.h
@@ -124,7 +124,7 @@
// - Initialize()
// - WriteVerifierDeps()
// - WriteQuickeningInfo()
- // - WriteVdexHeader()
+ // - WriteChecksumsAndVdexHeader()
// - PrepareLayout(),
// - WriteRodata(),
// - WriteCode(),
@@ -168,7 +168,7 @@
/*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files);
bool WriteQuickeningInfo(OutputStream* vdex_out);
bool WriteVerifierDeps(OutputStream* vdex_out, verifier::VerifierDeps* verifier_deps);
- bool WriteVdexHeader(OutputStream* vdex_out);
+ bool WriteChecksumsAndVdexHeader(OutputStream* vdex_out);
// Initialize the writer with the given parameters.
void Initialize(const CompilerDriver* compiler,
ImageWriter* image_writer,
@@ -387,6 +387,7 @@
// output stats
uint32_t size_vdex_header_;
+ uint32_t size_vdex_checksums_;
uint32_t size_dex_file_alignment_;
uint32_t size_executable_offset_alignment_;
uint32_t size_oat_header_;