Add image dependency to oat files
Change-Id: I945356f71357f1aa0092f4fe6c57eccfb029b4a6
diff --git a/src/oat.cc b/src/oat.cc
index e747a8b..d8d01df 100644
--- a/src/oat.cc
+++ b/src/oat.cc
@@ -27,14 +27,28 @@
memset(this, 0, sizeof(*this));
}
-OatHeader::OatHeader(InstructionSet instruction_set, const std::vector<const DexFile*>* dex_files) {
+OatHeader::OatHeader(InstructionSet instruction_set,
+ const std::vector<const DexFile*>* dex_files,
+ uint32_t image_file_location_checksum,
+ const std::string& image_file_location) {
memcpy(magic_, kOatMagic, sizeof(kOatMagic));
memcpy(version_, kOatVersion, sizeof(kOatVersion));
+
adler32_checksum_ = adler32(0L, Z_NULL, 0);
+
instruction_set_ = instruction_set;
UpdateChecksum(&instruction_set_, sizeof(instruction_set_));
+
dex_file_count_ = dex_files->size();
UpdateChecksum(&dex_file_count_, sizeof(dex_file_count_));
+
+ image_file_location_checksum_ = image_file_location_checksum;
+ UpdateChecksum(&image_file_location_checksum_, sizeof(image_file_location_checksum_));
+
+ image_file_location_size_ = image_file_location.size();
+ UpdateChecksum(&image_file_location_size_, sizeof(image_file_location_size_));
+ UpdateChecksum(image_file_location.data(), image_file_location_size_);
+
executable_offset_ = 0;
}
@@ -81,11 +95,33 @@
return executable_offset_;
}
+uint32_t OatHeader::GetImageFileLocationChecksum() const {
+ CHECK(IsValid());
+ return image_file_location_checksum_;
+}
+
+uint32_t OatHeader::GetImageFileLocationSize() const {
+ CHECK(IsValid());
+ return image_file_location_size_;
+}
+
+const uint8_t* OatHeader::GetImageFileLocationData() const {
+ CHECK(IsValid());
+ return image_file_location_data_;
+}
+
+std::string OatHeader::GetImageFileLocation() const {
+ CHECK(IsValid());
+ return std::string(reinterpret_cast<const char*>(GetImageFileLocationData()),
+ GetImageFileLocationSize());
+}
+
void OatHeader::SetExecutableOffset(uint32_t executable_offset) {
DCHECK_ALIGNED(executable_offset, kPageSize);
CHECK_GT(executable_offset, sizeof(OatHeader));
DCHECK(IsValid());
DCHECK_EQ(executable_offset_, 0U);
+
executable_offset_ = executable_offset;
UpdateChecksum(&executable_offset_, sizeof(executable_offset));
}