summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sebastian Pickl <spickl@google.com> 2023-07-20 12:20:07 +0000
committer David Srbecky <dsrbecky@google.com> 2023-07-20 13:11:56 +0000
commit0d59061cfaf5e60a4fe21f9031492b2a808bb37d (patch)
tree64604be5ddd23ac6e97b3237b037f9a19e8288e4
parent80d8a59a9dfba3a7f40a4b97d2809ab1142ba999 (diff)
Revert "Add DEX SHA1 to oat files."
This reverts commit ba2222f1e114603b42dfdb6dd1d11012d32a2739. Reason for revert: breaking aosp cf targets b/292059778 Bug:292059778 Change-Id: Ia26f8e297a2eb8455df759e92490789f08b41906
-rw-r--r--dex2oat/linker/oat_writer.cc28
-rw-r--r--dex2oat/linker/oat_writer.h1
-rw-r--r--dex2oat/linker/oat_writer_test.cc4
-rw-r--r--dexlayout/compact_dex_writer.cc2
-rw-r--r--dexlayout/dex_ir.h16
-rw-r--r--dexlayout/dex_writer.cc2
-rw-r--r--libdexfile/dex/dex_file.cc7
-rw-r--r--libdexfile/dex/dex_file.h11
-rw-r--r--libdexfile/dex/dex_file_loader_test.cc9
-rw-r--r--runtime/class_linker.cc4
-rw-r--r--runtime/oat.h4
-rw-r--r--runtime/oat_file.cc76
-rw-r--r--runtime/oat_file.h10
-rw-r--r--runtime/oat_file_assistant.cc7
14 files changed, 78 insertions, 103 deletions
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 67d200317e..41e9cdb841 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -278,7 +278,6 @@ class OatWriter::OatDexFile {
// The checksum of the dex file.
const uint32_t dex_file_location_checksum_;
- const DexFile::Sha1 dex_file_sha1_;
// Offset of the dex file in the vdex file. Set when writing dex files in
// SeekToDexFile.
@@ -2641,7 +2640,6 @@ bool OatWriter::CheckOatSize(OutputStream* out, size_t file_offset, size_t relat
DO_STAT(size_oat_dex_file_location_size_);
DO_STAT(size_oat_dex_file_location_data_);
DO_STAT(size_oat_dex_file_location_checksum_);
- DO_STAT(size_oat_dex_file_sha1_);
DO_STAT(size_oat_dex_file_offset_);
DO_STAT(size_oat_dex_file_class_offsets_offset_);
DO_STAT(size_oat_dex_file_lookup_table_offset_);
@@ -3423,7 +3421,6 @@ bool OatWriter::LayoutDexFile(OatDexFile* oat_dex_file) {
}
}
CHECK_EQ(oat_dex_file->dex_file_location_checksum_, dex_file->GetLocationChecksum());
- CHECK(oat_dex_file->dex_file_sha1_ == dex_file->GetSha1());
return true;
}
@@ -3802,7 +3799,6 @@ OatWriter::OatDexFile::OatDexFile(std::unique_ptr<const DexFile> dex_file)
dex_file_location_size_(strlen(dex_file_location_->c_str())),
dex_file_location_data_(dex_file_location_->c_str()),
dex_file_location_checksum_(dex_file_->GetLocationChecksum()),
- dex_file_sha1_(dex_file_->GetSha1()),
dex_file_offset_(0u),
lookup_table_offset_(0u),
class_offsets_offset_(0u),
@@ -3815,12 +3811,18 @@ 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_ +
- 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_) +
- sizeof(public_type_bss_mapping_offset_) + sizeof(package_type_bss_mapping_offset_) +
- sizeof(string_bss_mapping_offset_) + sizeof(dex_sections_layout_offset_);
+ return sizeof(dex_file_location_size_)
+ + dex_file_location_size_
+ + sizeof(dex_file_location_checksum_)
+ + sizeof(dex_file_offset_)
+ + sizeof(class_offsets_offset_)
+ + sizeof(lookup_table_offset_)
+ + sizeof(method_bss_mapping_offset_)
+ + sizeof(type_bss_mapping_offset_)
+ + sizeof(public_type_bss_mapping_offset_)
+ + sizeof(package_type_bss_mapping_offset_)
+ + sizeof(string_bss_mapping_offset_)
+ + sizeof(dex_sections_layout_offset_);
}
bool OatWriter::OatDexFile::Write(OatWriter* oat_writer, OutputStream* out) const {
@@ -3845,12 +3847,6 @@ bool OatWriter::OatDexFile::Write(OatWriter* oat_writer, OutputStream* out) cons
}
oat_writer->size_oat_dex_file_location_checksum_ += sizeof(dex_file_location_checksum_);
- if (!out->WriteFully(&dex_file_sha1_, sizeof(dex_file_sha1_))) {
- PLOG(ERROR) << "Failed to write dex file sha1 to " << out->GetLocation();
- return false;
- }
- oat_writer->size_oat_dex_file_sha1_ += sizeof(dex_file_sha1_);
-
if (!out->WriteFully(&dex_file_offset_, sizeof(dex_file_offset_))) {
PLOG(ERROR) << "Failed to write dex file offset to " << out->GetLocation();
return false;
diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h
index 623c4db211..a10572af8b 100644
--- a/dex2oat/linker/oat_writer.h
+++ b/dex2oat/linker/oat_writer.h
@@ -526,7 +526,6 @@ class OatWriter {
uint32_t size_oat_dex_file_location_size_;
uint32_t size_oat_dex_file_location_data_;
uint32_t size_oat_dex_file_location_checksum_;
- uint32_t size_oat_dex_file_sha1_ = 0;
uint32_t size_oat_dex_file_offset_;
uint32_t size_oat_dex_file_class_offsets_offset_;
uint32_t size_oat_dex_file_lookup_table_offset_;
diff --git a/dex2oat/linker/oat_writer_test.cc b/dex2oat/linker/oat_writer_test.cc
index 6ec15e2161..6742cf77a0 100644
--- a/dex2oat/linker/oat_writer_test.cc
+++ b/dex2oat/linker/oat_writer_test.cc
@@ -463,7 +463,9 @@ TEST_F(OatTest, WriteRead) {
ASSERT_TRUE(java_lang_dex_file_ != nullptr);
const DexFile& dex_file = *java_lang_dex_file_;
- const OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_file.GetLocation().c_str());
+ uint32_t dex_file_checksum = dex_file.GetLocationChecksum();
+ const OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_file.GetLocation().c_str(),
+ &dex_file_checksum);
ASSERT_TRUE(oat_dex_file != nullptr);
CHECK_EQ(dex_file.GetLocationChecksum(), oat_dex_file->GetDexFileLocationChecksum());
ScopedObjectAccess soa(Thread::Current());
diff --git a/dexlayout/compact_dex_writer.cc b/dexlayout/compact_dex_writer.cc
index b07a956ce4..b8c6ebe2c9 100644
--- a/dexlayout/compact_dex_writer.cc
+++ b/dexlayout/compact_dex_writer.cc
@@ -270,7 +270,7 @@ void CompactDexWriter::WriteHeader(Stream* stream) {
CompactDexFile::WriteMagic(&header.magic_[0]);
CompactDexFile::WriteCurrentVersion(&header.magic_[0]);
header.checksum_ = header_->Checksum();
- header.signature_ = header_->Signature();
+ std::copy_n(header_->Signature(), DexFile::kSha1DigestSize, header.signature_);
header.file_size_ = header_->FileSize();
// Since we are not necessarily outputting the same format as the input, avoid using the stored
// header size.
diff --git a/dexlayout/dex_ir.h b/dexlayout/dex_ir.h
index 2471aae8fa..c819c672e3 100644
--- a/dexlayout/dex_ir.h
+++ b/dexlayout/dex_ir.h
@@ -359,7 +359,7 @@ class Header : public Item {
public:
Header(const uint8_t* magic,
uint32_t checksum,
- DexFile::Sha1 signature,
+ const uint8_t* signature,
uint32_t endian_tag,
uint32_t file_size,
uint32_t header_size,
@@ -383,7 +383,7 @@ class Header : public Item {
Header(const uint8_t* magic,
uint32_t checksum,
- DexFile::Sha1 signature,
+ const uint8_t* signature,
uint32_t endian_tag,
uint32_t file_size,
uint32_t header_size,
@@ -423,7 +423,7 @@ class Header : public Item {
const uint8_t* Magic() const { return magic_; }
uint32_t Checksum() const { return checksum_; }
- DexFile::Sha1 Signature() const { return signature_; }
+ const uint8_t* Signature() const { return signature_; }
uint32_t EndianTag() const { return endian_tag_; }
uint32_t FileSize() const { return file_size_; }
uint32_t HeaderSize() const { return header_size_; }
@@ -433,7 +433,9 @@ class Header : public Item {
uint32_t DataOffset() const { return data_offset_; }
void SetChecksum(uint32_t new_checksum) { checksum_ = new_checksum; }
- void SetSignature(DexFile::Sha1 new_signature) { signature_ = new_signature; }
+ void SetSignature(const uint8_t* new_signature) {
+ memcpy(signature_, new_signature, sizeof(signature_));
+ }
void SetFileSize(uint32_t new_file_size) { file_size_ = new_file_size; }
void SetHeaderSize(uint32_t new_header_size) { header_size_ = new_header_size; }
void SetLinkSize(uint32_t new_link_size) { link_size_ = new_link_size; }
@@ -520,7 +522,7 @@ class Header : public Item {
private:
uint8_t magic_[8];
uint32_t checksum_;
- DexFile::Sha1 signature_;
+ uint8_t signature_[DexFile::kSha1DigestSize];
uint32_t endian_tag_;
uint32_t file_size_;
uint32_t header_size_;
@@ -532,7 +534,7 @@ class Header : public Item {
void ConstructorHelper(const uint8_t* magic,
uint32_t checksum,
- DexFile::Sha1 signature,
+ const uint8_t* signature,
uint32_t endian_tag,
uint32_t file_size,
uint32_t header_size,
@@ -549,7 +551,7 @@ class Header : public Item {
data_size_ = data_size;
data_offset_ = data_offset;
memcpy(magic_, magic, sizeof(magic_));
- signature_ = signature;
+ memcpy(signature_, signature, sizeof(signature_));
}
// Collection vectors own the IR data.
diff --git a/dexlayout/dex_writer.cc b/dexlayout/dex_writer.cc
index 3966753ef3..e7473c0a60 100644
--- a/dexlayout/dex_writer.cc
+++ b/dexlayout/dex_writer.cc
@@ -804,7 +804,7 @@ void DexWriter::WriteHeader(Stream* stream) {
std::copy_n(header_->Magic(), kMagicAndVersionLen, header.magic_);
}
header.checksum_ = header_->Checksum();
- header.signature_ = header_->Signature();
+ std::copy_n(header_->Signature(), DexFile::kSha1DigestSize, header.signature_);
header.file_size_ = header_->FileSize();
header.header_size_ = GetHeaderSize();
header.endian_tag_ = header_->EndianTag();
diff --git a/libdexfile/dex/dex_file.cc b/libdexfile/dex/dex_file.cc
index 55a9c08662..8179559337 100644
--- a/libdexfile/dex/dex_file.cc
+++ b/libdexfile/dex/dex_file.cc
@@ -61,13 +61,6 @@ static_assert(std::is_trivially_copyable<dex::StringIndex>::value, "StringIndex
static_assert(sizeof(dex::TypeIndex) == sizeof(uint16_t), "TypeIndex size is wrong");
static_assert(std::is_trivially_copyable<dex::TypeIndex>::value, "TypeIndex not trivial");
-// Print the SHA1 as 20-byte hexadecimal string.
-std::string DexFile::Sha1::ToString() const {
- auto data = this->data();
- auto part = [d = data](int i) { return d[i] << 24 | d[i + 1] << 16 | d[i + 2] << 8 | d[i + 3]; };
- return StringPrintf("%08x%08x%08x%08x%08x", part(0), part(4), part(8), part(12), part(16));
-}
-
uint32_t DexFile::CalculateChecksum() const {
return CalculateChecksum(Begin(), Size());
}
diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h
index af2bb7406e..1d1b016739 100644
--- a/libdexfile/dex/dex_file.h
+++ b/libdexfile/dex/dex_file.h
@@ -19,7 +19,6 @@
#include <android-base/logging.h>
-#include <array>
#include <memory>
#include <optional>
#include <string>
@@ -125,17 +124,11 @@ class DexFile {
static constexpr uint16_t kDexNoIndex16 = 0xFFFF;
static constexpr uint32_t kDexNoIndex32 = 0xFFFFFFFF;
- struct Sha1 : public std::array<uint8_t, kSha1DigestSize> {
- std::string ToString() const;
- };
-
- static_assert(std::is_standard_layout_v<Sha1>);
-
// Raw header_item.
struct Header {
uint8_t magic_[8] = {};
uint32_t checksum_ = 0; // See also location_checksum_
- Sha1 signature_ = {};
+ uint8_t signature_[kSha1DigestSize] = {};
uint32_t file_size_ = 0; // size of entire file
uint32_t header_size_ = 0; // offset to start of next section
uint32_t endian_tag_ = 0;
@@ -252,8 +245,6 @@ class DexFile {
return location_checksum_;
}
- Sha1 GetSha1() const { return header_->signature_; }
-
const Header& GetHeader() const {
DCHECK(header_ != nullptr) << GetLocation();
return *header_;
diff --git a/libdexfile/dex/dex_file_loader_test.cc b/libdexfile/dex/dex_file_loader_test.cc
index 515ec1a6ea..8abe9a4e95 100644
--- a/libdexfile/dex/dex_file_loader_test.cc
+++ b/libdexfile/dex/dex_file_loader_test.cc
@@ -358,15 +358,16 @@ static void ValidateDexFileHeader(std::unique_ptr<const DexFile> dex_file) {
/* d */ 0x64, /* e */ 0x64, /* x */ 0x78, /* \n */ 0x0d,
/* 0 */ 0x30, /* 3 */ 0x33, /* 5 */ 0x35, /* \0 */ 0x00
};
- static const DexFile::Sha1 kExpectedSha1 = {
- 0x7b, 0xb8, 0x0c, 0xd4, 0x1f, 0xd6, 0x1e, 0xc5, 0x89, 0xe8,
- 0xbe, 0xe5, 0x18, 0x02, 0x12, 0x18, 0x2e, 0xf2, 0x8c, 0x3d,
+ static const uint8_t kExpectedSha1[DexFile::kSha1DigestSize] = {
+ 0x7b, 0xb8, 0x0c, 0xd4, 0x1f, 0xd6, 0x1e, 0xc5,
+ 0x89, 0xe8, 0xbe, 0xe5, 0x18, 0x02, 0x12, 0x18,
+ 0x2e, 0xf2, 0x8c, 0x3d,
};
const DexFile::Header& header = dex_file->GetHeader();
EXPECT_EQ(*kExpectedDexFileMagic, *header.magic_);
EXPECT_EQ(0x00d87910U, header.checksum_);
- EXPECT_EQ(kExpectedSha1, header.signature_);
+ EXPECT_EQ(*kExpectedSha1, *header.signature_);
EXPECT_EQ(904U, header.file_size_);
EXPECT_EQ(112U, header.header_size_);
EXPECT_EQ(0U, header.link_size_);
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index f307d71996..eb75c6bdaf 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1824,7 +1824,7 @@ static std::unique_ptr<const DexFile> OpenOatDexFile(const OatFile* oat_file,
REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK(error_msg != nullptr);
std::unique_ptr<const DexFile> dex_file;
- const OatDexFile* oat_dex_file = oat_file->GetOatDexFile(location, error_msg);
+ const OatDexFile* oat_dex_file = oat_file->GetOatDexFile(location, nullptr, error_msg);
if (oat_dex_file == nullptr) {
return std::unique_ptr<const DexFile>();
}
@@ -1839,14 +1839,12 @@ static std::unique_ptr<const DexFile> OpenOatDexFile(const OatFile* oat_file,
}
if (dex_file->GetLocationChecksum() != oat_dex_file->GetDexFileLocationChecksum()) {
- CHECK(dex_file->GetSha1() != oat_dex_file->GetSha1());
*error_msg = StringPrintf("Checksums do not match for %s: %x vs %x",
location,
dex_file->GetLocationChecksum(),
oat_dex_file->GetDexFileLocationChecksum());
return std::unique_ptr<const DexFile>();
}
- CHECK(dex_file->GetSha1() == oat_dex_file->GetSha1());
return dex_file;
}
diff --git a/runtime/oat.h b/runtime/oat.h
index 65d3a5ebd3..d65f19a42b 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: Reduce multidex checksum to single scalar value.
+ static constexpr std::array<uint8_t, 4> kOatVersion{{'2', '3', '1', '\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..c75a9ec19d 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -547,13 +547,13 @@ bool OatFileBase::Setup(const std::vector<const DexFile*>& dex_files, std::strin
return false;
}
// Create an OatDexFile and add it to the owning container.
- OatDexFile* oat_dex_file = new OatDexFile(this,
- dex_file->Begin(),
- dex_file->GetLocationChecksum(),
- dex_file->GetSha1(),
- dex_location,
- canonical_location,
- type_lookup_table_data);
+ OatDexFile* oat_dex_file = new OatDexFile(
+ this,
+ dex_file->Begin(),
+ dex_file->GetLocationChecksum(),
+ dex_location,
+ canonical_location,
+ type_lookup_table_data);
oat_dex_files_storage_.push_back(oat_dex_file);
// Add the location and canonical location (if different) to the oat_dex_files_ table.
@@ -753,16 +753,6 @@ bool OatFileBase::Setup(int zip_fd,
return false;
}
- DexFile::Sha1 dex_file_sha1;
- if (UNLIKELY(!ReadOatDexFileData(*this, &oat, &dex_file_sha1))) {
- *error_msg = StringPrintf(
- "In oat file '%s' found OatDexFile #%zu for '%s' truncated after dex file sha1",
- GetLocation().c_str(),
- i,
- dex_file_location.c_str());
- return false;
- }
-
uint32_t dex_file_offset;
if (UNLIKELY(!ReadOatDexFileData(*this, &oat, &dex_file_offset))) {
*error_msg = StringPrintf("In oat file '%s' found OatDexFile #%zu for '%s' truncated "
@@ -858,7 +848,6 @@ bool OatFileBase::Setup(int zip_fd,
// expects this check to happen during oat file setup when the oat file
// does not contain dex code.
if (dex_file_checksum != external_dex_files_[i]->GetLocationChecksum()) {
- CHECK(dex_file_sha1 != external_dex_files_[i]->GetSha1());
*error_msg = StringPrintf("In oat file '%s', dex file checksum 0x%08x does not match"
" checksum 0x%08x of external dex file '%s'",
GetLocation().c_str(),
@@ -867,7 +856,6 @@ bool OatFileBase::Setup(int zip_fd,
external_dex_files_[i]->GetLocation().c_str());
return false;
}
- CHECK(dex_file_sha1 == external_dex_files_[i]->GetSha1());
dex_file_pointer = external_dex_files_[i]->Begin();
} else {
// Do not support mixed-mode oat files.
@@ -1013,21 +1001,20 @@ bool OatFileBase::Setup(int zip_fd,
}
// Create the OatDexFile and add it to the owning container.
- OatDexFile* oat_dex_file =
- new OatDexFile(this,
- dex_file_location,
- DexFileLoader::GetDexCanonicalLocation(dex_file_name.c_str()),
- dex_file_checksum,
- dex_file_sha1,
- dex_file_pointer,
- lookup_table_data,
- method_bss_mapping,
- type_bss_mapping,
- public_type_bss_mapping,
- package_type_bss_mapping,
- string_bss_mapping,
- class_offsets_pointer,
- dex_layout_sections);
+ OatDexFile* oat_dex_file = new OatDexFile(
+ this,
+ dex_file_location,
+ DexFileLoader::GetDexCanonicalLocation(dex_file_name.c_str()),
+ dex_file_checksum,
+ dex_file_pointer,
+ lookup_table_data,
+ method_bss_mapping,
+ type_bss_mapping,
+ public_type_bss_mapping,
+ package_type_bss_mapping,
+ string_bss_mapping,
+ class_offsets_pointer,
+ dex_layout_sections);
oat_dex_files_storage_.push_back(oat_dex_file);
// Add the location and canonical location (if different) to the oat_dex_files_ table.
@@ -1796,7 +1783,6 @@ class OatFileBackedByVdex final : public OatFileBase {
OatDexFile* oat_dex_file = new OatDexFile(oat_file.get(),
dex_file_start,
vdex_file->GetLocationChecksum(i),
- header->signature_,
location,
canonical_location,
type_lookup_table_data);
@@ -2098,7 +2084,9 @@ ArrayRef<GcRoot<mirror::Object>> OatFile::GetBssGcRoots() const {
}
}
-const OatDexFile* OatFile::GetOatDexFile(const char* dex_location, std::string* error_msg) const {
+const OatDexFile* OatFile::GetOatDexFile(const char* dex_location,
+ const uint32_t* dex_location_checksum,
+ std::string* error_msg) const {
// NOTE: We assume here that the canonical location for a given dex_location never
// changes. If it does (i.e. some symlink used by the filename changes) we may return
// an incorrect OatDexFile. As long as we have a checksum to check, we shall return
@@ -2150,6 +2138,18 @@ const OatDexFile* OatFile::GetOatDexFile(const char* dex_location, std::string*
return nullptr;
}
+ if (dex_location_checksum != nullptr &&
+ oat_dex_file->GetDexFileLocationChecksum() != *dex_location_checksum) {
+ if (error_msg != nullptr) {
+ std::string dex_canonical_location = DexFileLoader::GetDexCanonicalLocation(dex_location);
+ std::string checksum = StringPrintf("0x%08x", oat_dex_file->GetDexFileLocationChecksum());
+ std::string required_checksum = StringPrintf("0x%08x", *dex_location_checksum);
+ *error_msg = "OatDexFile for DexFile " + std::string(dex_location)
+ + " (canonical path " + dex_canonical_location + ") in OatFile " + GetLocation()
+ + " has checksum " + checksum + " but " + required_checksum + " was required";
+ }
+ return nullptr;
+ }
return oat_dex_file;
}
@@ -2157,7 +2157,6 @@ OatDexFile::OatDexFile(const OatFile* oat_file,
const std::string& dex_file_location,
const std::string& canonical_dex_file_location,
uint32_t dex_file_location_checksum,
- DexFile::Sha1 dex_file_sha1,
const uint8_t* dex_file_pointer,
const uint8_t* lookup_table_data,
const IndexBssMapping* method_bss_mapping_data,
@@ -2171,7 +2170,6 @@ OatDexFile::OatDexFile(const OatFile* oat_file,
dex_file_location_(dex_file_location),
canonical_dex_file_location_(canonical_dex_file_location),
dex_file_location_checksum_(dex_file_location_checksum),
- dex_file_sha1_(dex_file_sha1),
dex_file_pointer_(dex_file_pointer),
lookup_table_data_(lookup_table_data),
method_bss_mapping_(method_bss_mapping_data),
@@ -2209,7 +2207,6 @@ void OatDexFile::InitializeTypeLookupTable() {
OatDexFile::OatDexFile(const OatFile* oat_file,
const uint8_t* dex_file_pointer,
uint32_t dex_file_location_checksum,
- DexFile::Sha1 dex_file_sha1,
const std::string& dex_file_location,
const std::string& canonical_dex_file_location,
const uint8_t* lookup_table_data)
@@ -2217,7 +2214,6 @@ OatDexFile::OatDexFile(const OatFile* oat_file,
dex_file_location_(dex_file_location),
canonical_dex_file_location_(canonical_dex_file_location),
dex_file_location_checksum_(dex_file_location_checksum),
- dex_file_sha1_(dex_file_sha1),
dex_file_pointer_(dex_file_pointer),
lookup_table_data_(lookup_table_data) {
InitializeTypeLookupTable();
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index 7ceafac2db..4fdbb75a3a 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -29,7 +29,6 @@
#include "base/safe_map.h"
#include "base/tracking_safe_map.h"
#include "class_status.h"
-#include "dex/dex_file.h"
#include "dex/dex_file_layout.h"
#include "dex/type_lookup_table.h"
#include "dex/utf.h"
@@ -39,6 +38,7 @@
namespace art {
class BitVector;
+class DexFile;
class ClassLoaderContext;
class ElfFile;
class DexLayoutSections;
@@ -302,7 +302,8 @@ class OatFile {
// If error_msg is non-null and no OatDexFile is returned, error_msg will
// be updated with a description of why no OatDexFile was returned.
const OatDexFile* GetOatDexFile(const char* dex_location,
- /*out*/ std::string* error_msg = nullptr) const
+ const uint32_t* const dex_location_checksum,
+ /*out*/std::string* error_msg = nullptr) const
REQUIRES(!secondary_lookup_lock_);
const std::vector<const OatDexFile*>& GetOatDexFiles() const {
@@ -529,8 +530,6 @@ class OatDexFile final {
// Returns checksum of original DexFile that was the source of this OatDexFile;
uint32_t GetLocationChecksum() const { return dex_file_location_checksum_; }
- DexFile::Sha1 GetSha1() const { return dex_file_sha1_; }
-
// Returns the OatClass for the class specified by the given DexFile class_def_index.
OatFile::OatClass GetOatClass(uint16_t class_def_index) const;
@@ -590,7 +589,6 @@ class OatDexFile final {
const std::string& dex_file_location,
const std::string& canonical_dex_file_location,
uint32_t dex_file_checksum,
- DexFile::Sha1 dex_file_sha1,
const uint8_t* dex_file_pointer,
const uint8_t* lookup_table_data,
const IndexBssMapping* method_bss_mapping,
@@ -606,7 +604,6 @@ class OatDexFile final {
OatDexFile(const OatFile* oat_file,
const uint8_t* dex_file_pointer,
uint32_t dex_file_checksum,
- DexFile::Sha1 dex_file_sha1,
const std::string& dex_file_location,
const std::string& canonical_dex_file_location,
const uint8_t* lookup_table_data);
@@ -620,7 +617,6 @@ class OatDexFile final {
const std::string dex_file_location_;
const std::string canonical_dex_file_location_;
const uint32_t dex_file_location_checksum_ = 0u;
- const DexFile::Sha1 dex_file_sha1_ = {};
const uint8_t* const dex_file_pointer_ = nullptr;
const uint8_t* const lookup_table_data_ = nullptr;
const IndexBssMapping* const method_bss_mapping_ = nullptr;
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 5d035f554f..5024335d89 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -418,7 +418,8 @@ bool OatFileAssistant::LoadDexFiles(const OatFile& oat_file,
std::vector<std::unique_ptr<const DexFile>>* out_dex_files) {
// Load the main dex file.
std::string error_msg;
- const OatDexFile* oat_dex_file = oat_file.GetOatDexFile(dex_location.c_str(), &error_msg);
+ const OatDexFile* oat_dex_file =
+ oat_file.GetOatDexFile(dex_location.c_str(), nullptr, &error_msg);
if (oat_dex_file == nullptr) {
LOG(WARNING) << error_msg;
return false;
@@ -434,7 +435,7 @@ bool OatFileAssistant::LoadDexFiles(const OatFile& oat_file,
// Load the rest of the multidex entries
for (size_t i = 1;; i++) {
std::string multidex_dex_location = DexFileLoader::GetMultiDexLocation(i, dex_location.c_str());
- oat_dex_file = oat_file.GetOatDexFile(multidex_dex_location.c_str());
+ oat_dex_file = oat_file.GetOatDexFile(multidex_dex_location.c_str(), nullptr);
if (oat_dex_file == nullptr) {
// There are no more multidex entries to load.
break;
@@ -483,7 +484,7 @@ bool OatFileAssistant::DexChecksumUpToDate(const OatFile& file, std::string* err
uint32_t number_of_dex_files = file.GetOatHeader().GetDexFileCount();
for (uint32_t i = 0; i < number_of_dex_files; i++) {
std::string dex = DexFileLoader::GetMultiDexLocation(i, dex_location_.c_str());
- const OatDexFile* oat_dex_file = file.GetOatDexFile(dex.c_str());
+ const OatDexFile* oat_dex_file = file.GetOatDexFile(dex.c_str(), nullptr);
if (oat_dex_file == nullptr) {
*error_msg = StringPrintf("failed to find %s in %s", dex.c_str(), file.GetLocation().c_str());
return false;