Store the instruction set in the oat header, and use it in oatdump.
Change-Id: I5cc4b853c3ebf1efcc1feb14ce05c97ceabe2c3e
diff --git a/src/oat.cc b/src/oat.cc
index 1a884e3..e747a8b 100644
--- a/src/oat.cc
+++ b/src/oat.cc
@@ -23,10 +23,16 @@
const uint8_t OatHeader::kOatMagic[] = { 'o', 'a', 't', '\n' };
const uint8_t OatHeader::kOatVersion[] = { '0', '0', '1', '\0' };
-OatHeader::OatHeader(const std::vector<const DexFile*>* dex_files) {
+OatHeader::OatHeader() {
+ memset(this, 0, sizeof(*this));
+}
+
+OatHeader::OatHeader(InstructionSet instruction_set, const std::vector<const DexFile*>* dex_files) {
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_));
executable_offset_ = 0;
@@ -63,6 +69,11 @@
adler32_checksum_ = adler32(adler32_checksum_, bytes, length);
}
+InstructionSet OatHeader::GetInstructionSet() const {
+ CHECK(IsValid());
+ return instruction_set_;
+}
+
uint32_t OatHeader::GetExecutableOffset() const {
DCHECK(IsValid());
DCHECK_ALIGNED(executable_offset_, kPageSize);