summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dex2oat/dex2oat_test.cc8
-rw-r--r--dex2oat/linker/oat_writer.cc12
-rw-r--r--dex2oat/linker/oat_writer.h1
-rw-r--r--dexdump/dexdump.cc4
-rw-r--r--dexlayout/dex_ir.h12
-rw-r--r--dexlayout/dex_writer.cc10
-rw-r--r--dexlayout/dexlayout.cc8
-rw-r--r--libdexfile/dex/code_item_accessors_test.cc4
-rw-r--r--libdexfile/dex/compact_dex_file.cc4
-rw-r--r--libdexfile/dex/compact_dex_file.h1
-rw-r--r--libdexfile/dex/dex_file.h4
-rw-r--r--libdexfile/dex/dex_file_loader_test.cc7
-rw-r--r--libdexfile/dex/standard_dex_file.cc4
-rw-r--r--libdexfile/dex/standard_dex_file.h1
-rw-r--r--libdexfile/dex/test_dex_file_builder.h4
-rw-r--r--runtime/oat.h4
-rw-r--r--runtime/oat_file.cc17
-rw-r--r--runtime/oat_file.h5
18 files changed, 71 insertions, 39 deletions
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 56d14a7143..84b133b9a2 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1857,8 +1857,8 @@ TEST_F(Dex2oatTest, CompactDexInvalidSource) {
ZipWriter writer(file);
writer.StartEntry("classes.dex", ZipWriter::kAlign32);
DexFile::Header header = {};
- StandardDexFile::WriteMagic(header.magic_);
- StandardDexFile::WriteCurrentVersion(header.magic_);
+ StandardDexFile::WriteMagic(header.magic_.data());
+ StandardDexFile::WriteCurrentVersion(header.magic_.data());
header.file_size_ = 4 * KB;
header.data_size_ = 4 * KB;
header.data_off_ = 10 * MB;
@@ -1884,8 +1884,8 @@ TEST_F(Dex2oatTest, CompactDexInvalidSource) {
// Test that dex2oat with a CompactDex file in the APK fails.
TEST_F(Dex2oatTest, CompactDexInZip) {
CompactDexFile::Header header = {};
- CompactDexFile::WriteMagic(header.magic_);
- CompactDexFile::WriteCurrentVersion(header.magic_);
+ CompactDexFile::WriteMagic(header.magic_.data());
+ CompactDexFile::WriteCurrentVersion(header.magic_.data());
header.file_size_ = sizeof(CompactDexFile::Header);
header.data_off_ = 10 * MB;
header.map_off_ = 10 * MB;
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 67d200317e..8c1edb8e05 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -276,6 +276,8 @@ class OatWriter::OatDexFile {
const uint32_t dex_file_location_size_;
const char* const dex_file_location_data_;
+ DexFile::Magic dex_file_magic_;
+
// The checksum of the dex file.
const uint32_t dex_file_location_checksum_;
const DexFile::Sha1 dex_file_sha1_;
@@ -2640,6 +2642,7 @@ bool OatWriter::CheckOatSize(OutputStream* out, size_t file_offset, size_t relat
DO_STAT(size_method_info_);
DO_STAT(size_oat_dex_file_location_size_);
DO_STAT(size_oat_dex_file_location_data_);
+ DO_STAT(size_oat_dex_file_magic_);
DO_STAT(size_oat_dex_file_location_checksum_);
DO_STAT(size_oat_dex_file_sha1_);
DO_STAT(size_oat_dex_file_offset_);
@@ -3801,6 +3804,7 @@ OatWriter::OatDexFile::OatDexFile(std::unique_ptr<const DexFile> dex_file)
offset_(0),
dex_file_location_size_(strlen(dex_file_location_->c_str())),
dex_file_location_data_(dex_file_location_->c_str()),
+ dex_file_magic_(dex_file_->GetHeader().magic_),
dex_file_location_checksum_(dex_file_->GetLocationChecksum()),
dex_file_sha1_(dex_file_->GetSha1()),
dex_file_offset_(0u),
@@ -3815,7 +3819,7 @@ OatWriter::OatDexFile::OatDexFile(std::unique_ptr<const DexFile> dex_file)
class_offsets_() {}
size_t OatWriter::OatDexFile::SizeOf() const {
- return sizeof(dex_file_location_size_) + dex_file_location_size_ +
+ return sizeof(dex_file_location_size_) + dex_file_location_size_ + sizeof(dex_file_magic_) +
sizeof(dex_file_location_checksum_) + sizeof(dex_file_sha1_) + sizeof(dex_file_offset_) +
sizeof(class_offsets_offset_) + sizeof(lookup_table_offset_) +
sizeof(method_bss_mapping_offset_) + sizeof(type_bss_mapping_offset_) +
@@ -3839,6 +3843,12 @@ bool OatWriter::OatDexFile::Write(OatWriter* oat_writer, OutputStream* out) cons
}
oat_writer->size_oat_dex_file_location_data_ += dex_file_location_size_;
+ if (!out->WriteFully(&dex_file_magic_, sizeof(dex_file_magic_))) {
+ PLOG(ERROR) << "Failed to write dex file magic to " << out->GetLocation();
+ return false;
+ }
+ oat_writer->size_oat_dex_file_magic_ += sizeof(dex_file_magic_);
+
if (!out->WriteFully(&dex_file_location_checksum_, sizeof(dex_file_location_checksum_))) {
PLOG(ERROR) << "Failed to write dex file location checksum to " << out->GetLocation();
return false;
diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h
index 623c4db211..1b07d3796c 100644
--- a/dex2oat/linker/oat_writer.h
+++ b/dex2oat/linker/oat_writer.h
@@ -525,6 +525,7 @@ class OatWriter {
uint32_t size_method_info_;
uint32_t size_oat_dex_file_location_size_;
uint32_t size_oat_dex_file_location_data_;
+ uint32_t size_oat_dex_file_magic_ = 0;
uint32_t size_oat_dex_file_location_checksum_;
uint32_t size_oat_dex_file_sha1_ = 0;
uint32_t size_oat_dex_file_offset_;
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc
index b273a5c768..635734bcce 100644
--- a/dexdump/dexdump.cc
+++ b/dexdump/dexdump.cc
@@ -654,7 +654,7 @@ static void dumpFileHeader(const DexFile* pDexFile) {
const DexFile::Header& pHeader = pDexFile->GetHeader();
char sanitized[sizeof(pHeader.magic_) * 2 + 1];
fprintf(gOutFile, "DEX file header:\n");
- asciify(sanitized, pHeader.magic_, sizeof(pHeader.magic_));
+ asciify(sanitized, pHeader.magic_.data(), pHeader.magic_.size());
fprintf(gOutFile, "magic : '%s'\n", sanitized);
fprintf(gOutFile, "checksum : %08x\n", pHeader.checksum_);
fprintf(gOutFile, "signature : %02x%02x...%02x%02x\n",
@@ -1943,7 +1943,7 @@ static void processDexFile(const char* fileName,
if (n > 1) {
fprintf(gOutFile, ":%s", DexFileLoader::GetMultiDexClassesDexName(i).c_str());
}
- fprintf(gOutFile, "', DEX version '%.3s'\n", pDexFile->GetHeader().magic_ + 4);
+ fprintf(gOutFile, "', DEX version '%.3s'\n", pDexFile->GetHeader().magic_.data() + 4);
}
// Headers.
diff --git a/dexlayout/dex_ir.h b/dexlayout/dex_ir.h
index 2471aae8fa..a4b43b6055 100644
--- a/dexlayout/dex_ir.h
+++ b/dexlayout/dex_ir.h
@@ -357,7 +357,7 @@ class IndexedItem : public Item {
class Header : public Item {
public:
- Header(const uint8_t* magic,
+ Header(DexFile::Magic magic,
uint32_t checksum,
DexFile::Sha1 signature,
uint32_t endian_tag,
@@ -381,7 +381,7 @@ class Header : public Item {
data_offset);
}
- Header(const uint8_t* magic,
+ Header(DexFile::Magic magic,
uint32_t checksum,
DexFile::Sha1 signature,
uint32_t endian_tag,
@@ -421,7 +421,7 @@ class Header : public Item {
static size_t ItemSize() { return kHeaderItemSize; }
- const uint8_t* Magic() const { return magic_; }
+ DexFile::Magic Magic() const { return magic_; }
uint32_t Checksum() const { return checksum_; }
DexFile::Sha1 Signature() const { return signature_; }
uint32_t EndianTag() const { return endian_tag_; }
@@ -518,7 +518,7 @@ class Header : public Item {
}
private:
- uint8_t magic_[8];
+ DexFile::Magic magic_;
uint32_t checksum_;
DexFile::Sha1 signature_;
uint32_t endian_tag_;
@@ -530,7 +530,7 @@ class Header : public Item {
uint32_t data_offset_;
const bool support_default_methods_;
- void ConstructorHelper(const uint8_t* magic,
+ void ConstructorHelper(DexFile::Magic magic,
uint32_t checksum,
DexFile::Sha1 signature,
uint32_t endian_tag,
@@ -548,7 +548,7 @@ class Header : public Item {
link_offset_ = link_offset;
data_size_ = data_size;
data_offset_ = data_offset;
- memcpy(magic_, magic, sizeof(magic_));
+ magic_ = magic;
signature_ = signature;
}
diff --git a/dexlayout/dex_writer.cc b/dexlayout/dex_writer.cc
index 3966753ef3..96fa9f2110 100644
--- a/dexlayout/dex_writer.cc
+++ b/dexlayout/dex_writer.cc
@@ -791,17 +791,15 @@ void DexWriter::GenerateAndWriteMapItems(Stream* stream) {
void DexWriter::WriteHeader(Stream* stream) {
StandardDexFile::Header header;
if (CompactDexFile::IsMagicValid(header_->Magic())) {
- StandardDexFile::WriteMagic(header.magic_);
+ StandardDexFile::WriteMagic(header.magic_.data());
if (header_->SupportDefaultMethods()) {
- StandardDexFile::WriteCurrentVersion(header.magic_);
+ StandardDexFile::WriteCurrentVersion(header.magic_.data());
} else {
- StandardDexFile::WriteVersionBeforeDefaultMethods(header.magic_);
+ StandardDexFile::WriteVersionBeforeDefaultMethods(header.magic_.data());
}
} else {
// Standard dex -> standard dex, just reuse the same header.
- static constexpr size_t kMagicAndVersionLen =
- StandardDexFile::kDexMagicSize + StandardDexFile::kDexVersionLen;
- std::copy_n(header_->Magic(), kMagicAndVersionLen, header.magic_);
+ header.magic_ = header_->Magic();
}
header.checksum_ = header_->Checksum();
header.signature_ = header_->Signature();
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index 9152c18b1f..3db9cf3c54 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -654,7 +654,7 @@ void DexLayout::DumpEncodedValue(const dex_ir::EncodedValue* data) {
void DexLayout::DumpFileHeader() {
char sanitized[8 * 2 + 1];
fprintf(out_file_, "DEX file header:\n");
- Asciify(sanitized, header_->Magic(), 8);
+ Asciify(sanitized, header_->Magic().data(), header_->Magic().size());
fprintf(out_file_, "magic : '%s'\n", sanitized);
fprintf(out_file_, "checksum : %08x\n", header_->Checksum());
fprintf(out_file_, "signature : %02x%02x...%02x%02x\n",
@@ -2198,8 +2198,10 @@ bool DexLayout::ProcessDexFile(const char* file_name,
SetHeader(header.get());
if (options_.verbose_) {
- fprintf(out_file_, "Opened '%s', DEX version '%.3s'\n",
- file_name, dex_file->GetHeader().magic_ + 4);
+ fprintf(out_file_,
+ "Opened '%s', DEX version '%.3s'\n",
+ file_name,
+ dex_file->GetHeader().magic_.data() + 4);
}
if (options_.visualize_pattern_) {
diff --git a/libdexfile/dex/code_item_accessors_test.cc b/libdexfile/dex/code_item_accessors_test.cc
index 7cb2fe0eab..a923d042b5 100644
--- a/libdexfile/dex/code_item_accessors_test.cc
+++ b/libdexfile/dex/code_item_accessors_test.cc
@@ -32,8 +32,8 @@ std::unique_ptr<const DexFile> CreateFakeDex(bool compact_dex, std::vector<uint8
if (compact_dex) {
CompactDexFile::Header* header =
const_cast<CompactDexFile::Header*>(CompactDexFile::Header::At(data->data()));
- CompactDexFile::WriteMagic(header->magic_);
- CompactDexFile::WriteCurrentVersion(header->magic_);
+ CompactDexFile::WriteMagic(header->magic_.data());
+ CompactDexFile::WriteCurrentVersion(header->magic_.data());
header->data_off_ = 0;
header->data_size_ = data->size();
header->file_size_ = data->size();
diff --git a/libdexfile/dex/compact_dex_file.cc b/libdexfile/dex/compact_dex_file.cc
index 9c7000f7e3..4fad26c140 100644
--- a/libdexfile/dex/compact_dex_file.cc
+++ b/libdexfile/dex/compact_dex_file.cc
@@ -45,9 +45,7 @@ bool CompactDexFile::IsMagicValid() const {
return IsMagicValid(header_->magic_);
}
-bool CompactDexFile::IsVersionValid() const {
- return IsVersionValid(header_->magic_);
-}
+bool CompactDexFile::IsVersionValid() const { return IsVersionValid(header_->magic_.data()); }
bool CompactDexFile::SupportsDefaultMethods() const {
return (GetHeader().GetFeatureFlags() &
diff --git a/libdexfile/dex/compact_dex_file.h b/libdexfile/dex/compact_dex_file.h
index 22f6c207b0..53af501a28 100644
--- a/libdexfile/dex/compact_dex_file.h
+++ b/libdexfile/dex/compact_dex_file.h
@@ -273,6 +273,7 @@ class CompactDexFile : public DexFile {
// Returns true if the byte string points to the magic value.
static bool IsMagicValid(const uint8_t* magic);
+ static bool IsMagicValid(DexFile::Magic magic) { return IsMagicValid(magic.data()); }
bool IsMagicValid() const override;
// Returns true if the byte string after the magic is the correct value.
diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h
index af2bb7406e..dcf1a5d935 100644
--- a/libdexfile/dex/dex_file.h
+++ b/libdexfile/dex/dex_file.h
@@ -125,6 +125,8 @@ class DexFile {
static constexpr uint16_t kDexNoIndex16 = 0xFFFF;
static constexpr uint32_t kDexNoIndex32 = 0xFFFFFFFF;
+ using Magic = std::array<uint8_t, 8>;
+
struct Sha1 : public std::array<uint8_t, kSha1DigestSize> {
std::string ToString() const;
};
@@ -133,7 +135,7 @@ class DexFile {
// Raw header_item.
struct Header {
- uint8_t magic_[8] = {};
+ Magic magic_ = {};
uint32_t checksum_ = 0; // See also location_checksum_
Sha1 signature_ = {};
uint32_t file_size_ = 0; // size of entire file
diff --git a/libdexfile/dex/dex_file_loader_test.cc b/libdexfile/dex/dex_file_loader_test.cc
index 515ec1a6ea..d69e4a0c00 100644
--- a/libdexfile/dex/dex_file_loader_test.cc
+++ b/libdexfile/dex/dex_file_loader_test.cc
@@ -354,9 +354,8 @@ static std::unique_ptr<const DexFile> OpenDexFileInMemoryBase64(const char* base
}
static void ValidateDexFileHeader(std::unique_ptr<const DexFile> dex_file) {
- static const uint8_t kExpectedDexFileMagic[8] = {
- /* d */ 0x64, /* e */ 0x64, /* x */ 0x78, /* \n */ 0x0d,
- /* 0 */ 0x30, /* 3 */ 0x33, /* 5 */ 0x35, /* \0 */ 0x00
+ static const DexFile::Magic kExpectedDexFileMagic = {
+ 0x64, 0x65, 0x78, 0x0a, 0x30, 0x33, 0x35, 0x00, // "dex\n035\0".
};
static const DexFile::Sha1 kExpectedSha1 = {
0x7b, 0xb8, 0x0c, 0xd4, 0x1f, 0xd6, 0x1e, 0xc5, 0x89, 0xe8,
@@ -364,7 +363,7 @@ static void ValidateDexFileHeader(std::unique_ptr<const DexFile> dex_file) {
};
const DexFile::Header& header = dex_file->GetHeader();
- EXPECT_EQ(*kExpectedDexFileMagic, *header.magic_);
+ EXPECT_EQ(kExpectedDexFileMagic, header.magic_);
EXPECT_EQ(0x00d87910U, header.checksum_);
EXPECT_EQ(kExpectedSha1, header.signature_);
EXPECT_EQ(904U, header.file_size_);
diff --git a/libdexfile/dex/standard_dex_file.cc b/libdexfile/dex/standard_dex_file.cc
index 1f1bc19ae2..912cff6084 100644
--- a/libdexfile/dex/standard_dex_file.cc
+++ b/libdexfile/dex/standard_dex_file.cc
@@ -71,9 +71,7 @@ bool StandardDexFile::IsMagicValid() const {
return IsMagicValid(header_->magic_);
}
-bool StandardDexFile::IsVersionValid() const {
- return IsVersionValid(header_->magic_);
-}
+bool StandardDexFile::IsVersionValid() const { return IsVersionValid(header_->magic_.data()); }
bool StandardDexFile::SupportsDefaultMethods() const {
return GetDexVersion() >= DexFile::kDefaultMethodsVersion;
diff --git a/libdexfile/dex/standard_dex_file.h b/libdexfile/dex/standard_dex_file.h
index 4ab27ef8c2..52c76842c1 100644
--- a/libdexfile/dex/standard_dex_file.h
+++ b/libdexfile/dex/standard_dex_file.h
@@ -94,6 +94,7 @@ class StandardDexFile : public DexFile {
// Returns true if the byte string points to the magic value.
static bool IsMagicValid(const uint8_t* magic);
+ static bool IsMagicValid(DexFile::Magic magic) { return IsMagicValid(magic.data()); }
bool IsMagicValid() const override;
// Returns true if the byte string after the magic is the correct value.
diff --git a/libdexfile/dex/test_dex_file_builder.h b/libdexfile/dex/test_dex_file_builder.h
index 964f196ac7..fb0e4c5706 100644
--- a/libdexfile/dex/test_dex_file_builder.h
+++ b/libdexfile/dex/test_dex_file_builder.h
@@ -88,8 +88,8 @@ class TestDexFileBuilder {
} header_data;
std::memset(header_data.data, 0, sizeof(header_data.data));
DexFile::Header* header = reinterpret_cast<DexFile::Header*>(&header_data.data);
- std::copy_n(StandardDexFile::kDexMagic, 4u, header->magic_);
- std::copy_n(StandardDexFile::kDexMagicVersions[0], 4u, header->magic_ + 4u);
+ std::copy_n(StandardDexFile::kDexMagic, 4u, header->magic_.data());
+ std::copy_n(StandardDexFile::kDexMagicVersions[0], 4u, header->magic_.data() + 4u);
header->header_size_ = sizeof(DexFile::Header);
header->endian_tag_ = DexFile::kDexEndianConstant;
header->link_size_ = 0u; // Unused.
diff --git a/runtime/oat.h b/runtime/oat.h
index 65d3a5ebd3..d041726bfb 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -44,8 +44,8 @@ std::ostream& operator<<(std::ostream& stream, StubType stub_type);
class PACKED(4) OatHeader {
public:
static constexpr std::array<uint8_t, 4> kOatMagic { { 'o', 'a', 't', '\n' } };
- // Last oat version changed reason: Add DEX SHA1 to oat files.
- static constexpr std::array<uint8_t, 4> kOatVersion{{'2', '3', '2', '\0'}};
+ // Last oat version changed reason: Add DEX magic to oat files.
+ static constexpr std::array<uint8_t, 4> kOatVersion{{'2', '3', '3', '\0'}};
static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline";
static constexpr const char* kDebuggableKey = "debuggable";
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 1d8a76a5e0..afb5e2df68 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -549,6 +549,7 @@ bool OatFileBase::Setup(const std::vector<const DexFile*>& dex_files, std::strin
// Create an OatDexFile and add it to the owning container.
OatDexFile* oat_dex_file = new OatDexFile(this,
dex_file->Begin(),
+ dex_file->GetHeader().magic_,
dex_file->GetLocationChecksum(),
dex_file->GetSha1(),
dex_location,
@@ -743,6 +744,16 @@ bool OatFileBase::Setup(int zip_fd,
}
}
+ DexFile::Magic dex_file_magic;
+ if (UNLIKELY(!ReadOatDexFileData(*this, &oat, &dex_file_magic))) {
+ *error_msg = StringPrintf(
+ "In oat file '%s' found OatDexFile #%zu for '%s' truncated after dex file magic",
+ GetLocation().c_str(),
+ i,
+ dex_file_location.c_str());
+ return false;
+ }
+
uint32_t dex_file_checksum;
if (UNLIKELY(!ReadOatDexFileData(*this, &oat, &dex_file_checksum))) {
*error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zu for '%s' truncated after "
@@ -1017,6 +1028,7 @@ bool OatFileBase::Setup(int zip_fd,
new OatDexFile(this,
dex_file_location,
DexFileLoader::GetDexCanonicalLocation(dex_file_name.c_str()),
+ dex_file_magic,
dex_file_checksum,
dex_file_sha1,
dex_file_pointer,
@@ -1795,6 +1807,7 @@ class OatFileBackedByVdex final : public OatFileBase {
OatDexFile* oat_dex_file = new OatDexFile(oat_file.get(),
dex_file_start,
+ header->magic_,
vdex_file->GetLocationChecksum(i),
header->signature_,
location,
@@ -2156,6 +2169,7 @@ const OatDexFile* OatFile::GetOatDexFile(const char* dex_location, std::string*
OatDexFile::OatDexFile(const OatFile* oat_file,
const std::string& dex_file_location,
const std::string& canonical_dex_file_location,
+ DexFile::Magic dex_file_magic,
uint32_t dex_file_location_checksum,
DexFile::Sha1 dex_file_sha1,
const uint8_t* dex_file_pointer,
@@ -2170,6 +2184,7 @@ OatDexFile::OatDexFile(const OatFile* oat_file,
: oat_file_(oat_file),
dex_file_location_(dex_file_location),
canonical_dex_file_location_(canonical_dex_file_location),
+ dex_file_magic_(dex_file_magic),
dex_file_location_checksum_(dex_file_location_checksum),
dex_file_sha1_(dex_file_sha1),
dex_file_pointer_(dex_file_pointer),
@@ -2208,6 +2223,7 @@ void OatDexFile::InitializeTypeLookupTable() {
OatDexFile::OatDexFile(const OatFile* oat_file,
const uint8_t* dex_file_pointer,
+ DexFile::Magic dex_file_magic,
uint32_t dex_file_location_checksum,
DexFile::Sha1 dex_file_sha1,
const std::string& dex_file_location,
@@ -2216,6 +2232,7 @@ OatDexFile::OatDexFile(const OatFile* oat_file,
: oat_file_(oat_file),
dex_file_location_(dex_file_location),
canonical_dex_file_location_(canonical_dex_file_location),
+ dex_file_magic_(dex_file_magic),
dex_file_location_checksum_(dex_file_location_checksum),
dex_file_sha1_(dex_file_sha1),
dex_file_pointer_(dex_file_pointer),
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index 7ceafac2db..0fa740c1c2 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -521,6 +521,8 @@ class OatDexFile final {
return canonical_dex_file_location_;
}
+ DexFile::Magic GetMagic() const { return dex_file_magic_; }
+
// Returns checksum of original DexFile that was the source of this OatDexFile;
uint32_t GetDexFileLocationChecksum() const {
return dex_file_location_checksum_;
@@ -589,6 +591,7 @@ class OatDexFile final {
OatDexFile(const OatFile* oat_file,
const std::string& dex_file_location,
const std::string& canonical_dex_file_location,
+ DexFile::Magic dex_file_magic,
uint32_t dex_file_checksum,
DexFile::Sha1 dex_file_sha1,
const uint8_t* dex_file_pointer,
@@ -605,6 +608,7 @@ class OatDexFile final {
// pointer in the DexFile.
OatDexFile(const OatFile* oat_file,
const uint8_t* dex_file_pointer,
+ DexFile::Magic dex_file_magic,
uint32_t dex_file_checksum,
DexFile::Sha1 dex_file_sha1,
const std::string& dex_file_location,
@@ -619,6 +623,7 @@ class OatDexFile final {
const OatFile* const oat_file_ = nullptr;
const std::string dex_file_location_;
const std::string canonical_dex_file_location_;
+ const DexFile::Magic dex_file_magic_ = {};
const uint32_t dex_file_location_checksum_ = 0u;
const DexFile::Sha1 dex_file_sha1_ = {};
const uint8_t* const dex_file_pointer_ = nullptr;