Dex: Use DexFileContainer instead of begin/size.
Cleanup. The DexFileContainer already specifies memory range
of the dex file, so there is no need to pass it separately.
Remove unused GetPermissions from DexFileContainer.
Bug: 266950186
Test: ./art/test.py -b --host --64
Change-Id: I94e4547edaa807d9b9c082e7c2c4c2493abe3a64
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index 648c52d..a35c652 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -2014,18 +2014,16 @@
DexContainer::Section* const data_section = (*dex_container)->GetDataSection();
DCHECK_EQ(file_size, main_section->Size())
<< main_section->Size() << " " << data_section->Size();
+ auto container = std::make_unique<DexLoaderContainer>(
+ main_section->Begin(), main_section->End(), data_section->Begin(), data_section->End());
std::unique_ptr<const DexFile> output_dex_file(
- dex_file_loader.OpenWithDataSection(
- main_section->Begin(),
- main_section->Size(),
- data_section->Begin(),
- data_section->Size(),
- location,
- /* location_checksum= */ 0,
- /*oat_dex_file=*/ nullptr,
- verify,
- /*verify_checksum=*/ false,
- error_msg));
+ dex_file_loader.Open(std::move(container),
+ location,
+ /* location_checksum= */ 0,
+ /*oat_dex_file=*/nullptr,
+ verify,
+ /*verify_checksum=*/false,
+ error_msg));
CHECK(output_dex_file != nullptr) << "Failed to re-open output file:" << *error_msg;
// Do IR-level comparison between input and output. This check ignores potential differences
diff --git a/dexlayout/dexlayout.h b/dexlayout/dexlayout.h
index bdc7863..767cad0 100644
--- a/dexlayout/dexlayout.h
+++ b/dexlayout/dexlayout.h
@@ -199,6 +199,21 @@
DISALLOW_COPY_AND_ASSIGN(DexLayout);
};
+class DexLoaderContainer : public MemoryDexFileContainer {
+ public:
+ DexLoaderContainer(const uint8_t* begin,
+ const uint8_t* end,
+ const uint8_t* data_begin,
+ const uint8_t* data_end)
+ : MemoryDexFileContainer(begin, end), data_begin_(data_begin), data_end_(data_end) {}
+ const uint8_t* DataBegin() const override { return data_begin_; }
+ const uint8_t* DataEnd() const override { return data_end_; }
+
+ private:
+ const uint8_t* data_begin_;
+ const uint8_t* data_end_;
+};
+
} // namespace art
#endif // ART_DEXLAYOUT_DEXLAYOUT_H_
diff --git a/dexlayout/dexlayout_test.cc b/dexlayout/dexlayout_test.cc
index 3c37e6d..8d034b8 100644
--- a/dexlayout/dexlayout_test.cc
+++ b/dexlayout/dexlayout_test.cc
@@ -14,13 +14,16 @@
* limitations under the License.
*/
-#include <sstream>
-#include <string>
-#include <vector>
+#include "dexlayout.h"
#include <sys/types.h>
#include <unistd.h>
+#include <memory>
+#include <sstream>
+#include <string>
+#include <vector>
+
#include "base/common_art_test.h"
#include "base/unix_file/fd_file.h"
#include "base/utils.h"
@@ -30,7 +33,6 @@
#include "dex/code_item_accessors-inl.h"
#include "dex/dex_file-inl.h"
#include "dex/dex_file_loader.h"
-#include "dexlayout.h"
#include "exec_utils.h"
#include "profile/profile_compilation_info.h"
@@ -802,18 +804,18 @@
&out,
&error_msg);
ASSERT_TRUE(result) << "Failed to run dexlayout " << error_msg;
+ auto container = std::make_unique<DexLoaderContainer>(out->GetMainSection()->Begin(),
+ out->GetMainSection()->End(),
+ out->GetDataSection()->Begin(),
+ out->GetDataSection()->End());
std::unique_ptr<const DexFile> output_dex_file(
- dex_file_loader.OpenWithDataSection(
- out->GetMainSection()->Begin(),
- out->GetMainSection()->Size(),
- out->GetDataSection()->Begin(),
- out->GetDataSection()->Size(),
- dex_file->GetLocation().c_str(),
- /* location_checksum= */ 0,
- /*oat_dex_file=*/ nullptr,
- /* verify= */ true,
- /*verify_checksum=*/ false,
- &error_msg));
+ dex_file_loader.Open(std::move(container),
+ dex_file->GetLocation().c_str(),
+ /* location_checksum= */ 0,
+ /*oat_dex_file=*/nullptr,
+ /* verify= */ true,
+ /*verify_checksum=*/false,
+ &error_msg));
ASSERT_TRUE(output_dex_file != nullptr);
ASSERT_EQ(output_dex_file->NumClassDefs(), options.class_filter_.size());
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index 1aba547..c839216 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -526,7 +526,6 @@
&dex_files);
CHECK(success) << "Failed to open '" << filename << "': " << error_msg;
for (auto& dex_file : dex_files) {
- CHECK_EQ(PROT_READ, dex_file->GetPermissions());
CHECK(dex_file->IsReadOnly());
}
return dex_files;
diff --git a/libdexfile/dex/art_dex_file_loader.cc b/libdexfile/dex/art_dex_file_loader.cc
index 1057bbc..654668e 100644
--- a/libdexfile/dex/art_dex_file_loader.cc
+++ b/libdexfile/dex/art_dex_file_loader.cc
@@ -18,6 +18,8 @@
#include <sys/stat.h>
+#include <memory>
+
#include "android-base/stringprintf.h"
#include "base/file_magic.h"
#include "base/file_utils.h"
@@ -42,7 +44,7 @@
explicit MemMapContainer(MemMap&& mem_map) : mem_map_(std::move(mem_map)) { }
~MemMapContainer() override { }
- int GetPermissions() override {
+ int GetPermissions() const {
if (!mem_map_.IsValid()) {
return 0;
} else {
@@ -50,9 +52,7 @@
}
}
- bool IsReadOnly() override {
- return GetPermissions() == PROT_READ;
- }
+ bool IsReadOnly() const override { return GetPermissions() == PROT_READ; }
bool EnableWrite() override {
CHECK(IsReadOnly());
@@ -72,6 +72,10 @@
}
}
+ const uint8_t* Begin() const override { return mem_map_.Begin(); }
+
+ const uint8_t* End() const override { return mem_map_.End(); }
+
private:
MemMap mem_map_;
DISALLOW_COPY_AND_ASSIGN(MemMapContainer);
@@ -162,29 +166,42 @@
return false;
}
-std::unique_ptr<const DexFile> ArtDexFileLoader::Open(
- const uint8_t* base,
- size_t size,
- const std::string& location,
- uint32_t location_checksum,
- const OatDexFile* oat_dex_file,
- bool verify,
- bool verify_checksum,
- std::string* error_msg,
- std::unique_ptr<DexFileContainer> container) const {
+std::unique_ptr<const DexFile> ArtDexFileLoader::Open(const uint8_t* base,
+ size_t size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg) const {
ScopedTrace trace(std::string("Open dex file from RAM ") + location);
- return OpenCommon(base,
- size,
- /*data_base=*/ nullptr,
- /*data_size=*/ 0u,
- location,
+ auto container = std::make_unique<MemoryDexFileContainer>(base, base + size);
+ return OpenCommon(location,
location_checksum,
oat_dex_file,
verify,
verify_checksum,
error_msg,
std::move(container),
- /*verify_result=*/ nullptr);
+ /*verify_result=*/nullptr);
+}
+
+std::unique_ptr<const DexFile> ArtDexFileLoader::Open(std::unique_ptr<DexFileContainer> container,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg) const {
+ ScopedTrace trace(std::string("Open dex file from ") + location);
+ return OpenCommon(location,
+ location_checksum,
+ oat_dex_file,
+ verify,
+ verify_checksum,
+ error_msg,
+ std::move(container),
+ /*verify_result=*/nullptr);
}
std::unique_ptr<const DexFile> ArtDexFileLoader::Open(const std::string& location,
@@ -204,19 +221,14 @@
return nullptr;
}
- uint8_t* begin = map.Begin();
- std::unique_ptr<DexFile> dex_file = OpenCommon(begin,
- size,
- /*data_base=*/ nullptr,
- /*data_size=*/ 0u,
- location,
+ std::unique_ptr<DexFile> dex_file = OpenCommon(location,
location_checksum,
kNoOatDexFile,
verify,
verify_checksum,
error_msg,
std::make_unique<MemMapContainer>(std::move(map)),
- /*verify_result=*/ nullptr);
+ /*verify_result=*/nullptr);
// Opening CompactDex is only supported from vdex files.
if (dex_file != nullptr && dex_file->IsCompactDexFile()) {
*error_msg = StringPrintf("Opening CompactDex file '%s' is only supported from vdex files",
@@ -404,18 +416,14 @@
const DexFile::Header* dex_header = reinterpret_cast<const DexFile::Header*>(begin);
- std::unique_ptr<DexFile> dex_file = OpenCommon(begin,
- size,
- /*data_base=*/ nullptr,
- /*data_size=*/ 0u,
- location,
+ std::unique_ptr<DexFile> dex_file = OpenCommon(location,
dex_header->checksum_,
kNoOatDexFile,
verify,
verify_checksum,
error_msg,
std::make_unique<MemMapContainer>(std::move(map)),
- /*verify_result=*/ nullptr);
+ /*verify_result=*/nullptr);
// Opening CompactDex is only supported from vdex files.
if (dex_file != nullptr && dex_file->IsCompactDexFile()) {
@@ -483,13 +491,7 @@
return nullptr;
}
VerifyResult verify_result;
- uint8_t* begin = map.Begin();
- size_t size = map.Size();
- std::unique_ptr<DexFile> dex_file = OpenCommon(begin,
- size,
- /*data_base=*/ nullptr,
- /*data_size=*/ 0u,
- location,
+ std::unique_ptr<DexFile> dex_file = OpenCommon(location,
zip_entry->GetCrc32(),
kNoOatDexFile,
verify,
@@ -593,30 +595,4 @@
}
}
-std::unique_ptr<DexFile> ArtDexFileLoader::OpenCommon(const uint8_t* base,
- size_t size,
- const uint8_t* data_base,
- size_t data_size,
- const std::string& location,
- uint32_t location_checksum,
- const OatDexFile* oat_dex_file,
- bool verify,
- bool verify_checksum,
- std::string* error_msg,
- std::unique_ptr<DexFileContainer> container,
- VerifyResult* verify_result) {
- return DexFileLoader::OpenCommon(base,
- size,
- data_base,
- data_size,
- location,
- location_checksum,
- oat_dex_file,
- verify,
- verify_checksum,
- error_msg,
- std::move(container),
- verify_result);
-}
-
} // namespace art
diff --git a/libdexfile/dex/art_dex_file_loader.h b/libdexfile/dex/art_dex_file_loader.h
index 49c81f4..acf7e28 100644
--- a/libdexfile/dex/art_dex_file_loader.h
+++ b/libdexfile/dex/art_dex_file_loader.h
@@ -59,16 +59,23 @@
bool* only_contains_uncompressed_dex = nullptr) const override;
// Opens .dex file, backed by existing memory
- std::unique_ptr<const DexFile> Open(
- const uint8_t* base,
- size_t size,
- const std::string& location,
- uint32_t location_checksum,
- const OatDexFile* oat_dex_file,
- bool verify,
- bool verify_checksum,
- std::string* error_msg,
- std::unique_ptr<DexFileContainer> container = nullptr) const override;
+ std::unique_ptr<const DexFile> Open(const uint8_t* base,
+ size_t size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg) const override;
+
+ // Opens .dex file, backed by existing memory
+ std::unique_ptr<const DexFile> Open(std::unique_ptr<DexFileContainer> container,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg) const;
// Opens .dex file that has been memory-mapped by the caller.
std::unique_ptr<const DexFile> Open(const std::string& location,
@@ -168,19 +175,6 @@
bool verify_checksum,
std::string* error_msg,
std::vector<std::unique_ptr<const DexFile>>* dex_files) const;
-
- static std::unique_ptr<DexFile> OpenCommon(const uint8_t* base,
- size_t size,
- const uint8_t* data_base,
- size_t data_size,
- const std::string& location,
- uint32_t location_checksum,
- const OatDexFile* oat_dex_file,
- bool verify,
- bool verify_checksum,
- std::string* error_msg,
- std::unique_ptr<DexFileContainer> container,
- VerifyResult* verify_result);
};
} // namespace art
diff --git a/libdexfile/dex/compact_dex_file.cc b/libdexfile/dex/compact_dex_file.cc
index 205b829..a14d4ec 100644
--- a/libdexfile/dex/compact_dex_file.cc
+++ b/libdexfile/dex/compact_dex_file.cc
@@ -16,6 +16,8 @@
#include "compact_dex_file.h"
+#include <memory>
+
#include "base/leb128.h"
#include "code_item_accessors-inl.h"
#include "dex_file-inl.h"
@@ -97,7 +99,7 @@
location_checksum,
oat_dex_file,
std::move(container),
- /*is_compact_dex=*/ true),
+ /*is_compact_dex=*/true),
debug_info_offsets_(DataBegin() + GetHeader().debug_info_offsets_pos_,
GetHeader().debug_info_base_,
GetHeader().debug_info_offsets_table_offset_) {}
diff --git a/libdexfile/dex/compact_dex_file.h b/libdexfile/dex/compact_dex_file.h
index 9c3b7a4..6aa0030 100644
--- a/libdexfile/dex/compact_dex_file.h
+++ b/libdexfile/dex/compact_dex_file.h
@@ -17,9 +17,11 @@
#ifndef ART_LIBDEXFILE_DEX_COMPACT_DEX_FILE_H_
#define ART_LIBDEXFILE_DEX_COMPACT_DEX_FILE_H_
+#include <memory>
+
#include "base/casts.h"
-#include "dex_file.h"
#include "dex/compact_offset_table.h"
+#include "dex_file.h"
namespace art {
diff --git a/libdexfile/dex/dex_file.cc b/libdexfile/dex/dex_file.cc
index c9088ed..6ebb5b8 100644
--- a/libdexfile/dex/dex_file.cc
+++ b/libdexfile/dex/dex_file.cc
@@ -74,11 +74,6 @@
return adler32(adler32(0L, Z_NULL, 0), begin, size);
}
-int DexFile::GetPermissions() const {
- CHECK(container_.get() != nullptr);
- return container_->GetPermissions();
-}
-
bool DexFile::IsReadOnly() const {
CHECK(container_.get() != nullptr);
return container_->IsReadOnly();
diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h
index 37a601d..757af71 100644
--- a/libdexfile/dex/dex_file.h
+++ b/libdexfile/dex/dex_file.h
@@ -17,16 +17,17 @@
#ifndef ART_LIBDEXFILE_DEX_DEX_FILE_H_
#define ART_LIBDEXFILE_DEX_DEX_FILE_H_
+#include <android-base/logging.h>
+
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
-#include <android-base/logging.h>
-
#include "base/globals.h"
#include "base/macros.h"
+#include "base/mman.h" // For the PROT_* and MAP_* constants.
#include "base/value_object.h"
#include "dex_file_structs.h"
#include "dex_file_types.h"
@@ -56,16 +57,38 @@
class DexFileContainer {
public:
DexFileContainer() { }
- virtual ~DexFileContainer() { }
- virtual int GetPermissions() = 0;
- virtual bool IsReadOnly() = 0;
+ virtual ~DexFileContainer() {}
+ virtual bool IsReadOnly() const = 0;
virtual bool EnableWrite() = 0;
virtual bool DisableWrite() = 0;
+ virtual const uint8_t* Begin() const = 0;
+ virtual const uint8_t* End() const = 0;
+ size_t Size() const { return End() - Begin(); }
+
+ // TODO: Remove. This is only used by dexlayout to override the data section of the dex header,
+ // and redirect it to intermediate memory buffer at completely unrelated memory location.
+ virtual const uint8_t* DataBegin() const { return nullptr; }
+ virtual const uint8_t* DataEnd() const { return nullptr; }
private:
DISALLOW_COPY_AND_ASSIGN(DexFileContainer);
};
+class MemoryDexFileContainer : public DexFileContainer {
+ public:
+ MemoryDexFileContainer(const uint8_t* begin, const uint8_t* end) : begin_(begin), end_(end) {}
+ bool IsReadOnly() const override { return true; }
+ bool EnableWrite() override { return false; }
+ bool DisableWrite() override { return false; }
+ const uint8_t* Begin() const override { return begin_; }
+ const uint8_t* End() const override { return end_; }
+
+ private:
+ const uint8_t* const begin_;
+ const uint8_t* const end_;
+ DISALLOW_COPY_AND_ASSIGN(MemoryDexFileContainer);
+};
+
// Dex file is the API that exposes native dex files (ordinary dex files) and CompactDex.
// Originally, the dex file format used by ART was mostly the same as APKs. The only change was
// quickened opcodes and layout optimizations.
@@ -709,8 +732,6 @@
}
}
- int GetPermissions() const;
-
bool IsReadOnly() const;
bool EnableWrite() const;
diff --git a/libdexfile/dex/dex_file_loader.cc b/libdexfile/dex/dex_file_loader.cc
index 861f911..541d10b 100644
--- a/libdexfile/dex/dex_file_loader.cc
+++ b/libdexfile/dex/dex_file_loader.cc
@@ -16,8 +16,9 @@
#include "dex_file_loader.h"
-#include "android-base/stringprintf.h"
+#include <memory>
+#include "android-base/stringprintf.h"
#include "base/stl_util.h"
#include "compact_dex_file.h"
#include "dex_file.h"
@@ -34,13 +35,7 @@
explicit VectorContainer(std::vector<uint8_t>&& vector) : vector_(std::move(vector)) { }
~VectorContainer() override { }
- int GetPermissions() override {
- return 0;
- }
-
- bool IsReadOnly() override {
- return true;
- }
+ bool IsReadOnly() const override { return true; }
bool EnableWrite() override {
return false;
@@ -50,6 +45,10 @@
return false;
}
+ const uint8_t* Begin() const override { return vector_.data(); }
+
+ const uint8_t* End() const override { return vector_.data() + vector_.size(); }
+
private:
std::vector<uint8_t> vector_;
DISALLOW_COPY_AND_ASSIGN(VectorContainer);
@@ -227,69 +226,33 @@
bool verify,
bool verify_checksum,
std::string* error_msg) {
- auto memory_data = memory.data();
- auto memory_size = memory.size();
- return OpenCommon(memory_data,
- memory_size,
- /*data_base=*/ nullptr,
- /*data_size=*/ 0,
- location,
+ return OpenCommon(location,
location_checksum,
oat_dex_file,
verify,
verify_checksum,
error_msg,
std::make_unique<VectorContainer>(std::move(memory)),
- /*verify_result=*/ nullptr);
+ /*verify_result=*/nullptr);
}
-std::unique_ptr<const DexFile> DexFileLoader::Open(
- const uint8_t* base,
- size_t size,
- const std::string& location,
- uint32_t location_checksum,
- const OatDexFile* oat_dex_file,
- bool verify,
- bool verify_checksum,
- std::string* error_msg,
- std::unique_ptr<DexFileContainer> container) const {
- return OpenCommon(base,
- size,
- /*data_base=*/ nullptr,
- /*data_size=*/ 0,
- location,
+std::unique_ptr<const DexFile> DexFileLoader::Open(const uint8_t* base,
+ size_t size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg) const {
+ auto container = std::make_unique<MemoryDexFileContainer>(base, base + size);
+ return OpenCommon(location,
location_checksum,
oat_dex_file,
verify,
verify_checksum,
error_msg,
std::move(container),
- /*verify_result=*/ nullptr);
-}
-
-std::unique_ptr<const DexFile> DexFileLoader::OpenWithDataSection(
- const uint8_t* base,
- size_t size,
- const uint8_t* data_base,
- size_t data_size,
- const std::string& location,
- uint32_t location_checksum,
- const OatDexFile* oat_dex_file,
- bool verify,
- bool verify_checksum,
- std::string* error_msg) const {
- return OpenCommon(base,
- size,
- data_base,
- data_size,
- location,
- location_checksum,
- oat_dex_file,
- verify,
- verify_checksum,
- error_msg,
- /*container=*/ nullptr,
- /*verify_result=*/ nullptr);
+ /*verify_result=*/nullptr);
}
bool DexFileLoader::OpenAll(
@@ -338,11 +301,7 @@
return false;
}
-std::unique_ptr<DexFile> DexFileLoader::OpenCommon(const uint8_t* base,
- size_t size,
- const uint8_t* data_base,
- size_t data_size,
- const std::string& location,
+std::unique_ptr<DexFile> DexFileLoader::OpenCommon(const std::string& location,
uint32_t location_checksum,
const OatDexFile* oat_dex_file,
bool verify,
@@ -350,6 +309,11 @@
std::string* error_msg,
std::unique_ptr<DexFileContainer> container,
VerifyResult* verify_result) {
+ CHECK(container != nullptr);
+ const uint8_t* base = container->Begin();
+ size_t size = container->Size();
+ const uint8_t* data_base = container->DataBegin();
+ size_t data_size = container->DataEnd() - container->DataBegin();
if (verify_result != nullptr) {
*verify_result = VerifyResult::kVerifyNotAttempted;
}
@@ -440,21 +404,15 @@
return nullptr;
}
VerifyResult verify_result;
- auto map_data = map.data();
- auto map_size = map.size();
- std::unique_ptr<const DexFile> dex_file = OpenCommon(
- map_data,
- map_size,
- /*data_base=*/ nullptr,
- /*data_size=*/ 0u,
- location,
- zip_entry->GetCrc32(),
- /*oat_dex_file=*/ nullptr,
- verify,
- verify_checksum,
- error_msg,
- std::make_unique<VectorContainer>(std::move(map)),
- &verify_result);
+ std::unique_ptr<const DexFile> dex_file =
+ OpenCommon(location,
+ zip_entry->GetCrc32(),
+ /*oat_dex_file=*/nullptr,
+ verify,
+ verify_checksum,
+ error_msg,
+ std::make_unique<VectorContainer>(std::move(map)),
+ &verify_result);
if (verify_result != VerifyResult::kVerifySucceeded) {
if (verify_result == VerifyResult::kVerifyNotAttempted) {
*error_code = DexFileLoaderErrorCode::kDexFileError;
diff --git a/libdexfile/dex/dex_file_loader.h b/libdexfile/dex/dex_file_loader.h
index d6268bc..ef45aa8 100644
--- a/libdexfile/dex/dex_file_loader.h
+++ b/libdexfile/dex/dex_file_loader.h
@@ -136,30 +136,14 @@
std::string* error_msg);
// Opens .dex file, backed by existing memory.
- virtual std::unique_ptr<const DexFile> Open(
- const uint8_t* base,
- size_t size,
- const std::string& location,
- uint32_t location_checksum,
- const OatDexFile* oat_dex_file,
- bool verify,
- bool verify_checksum,
- std::string* error_msg,
- std::unique_ptr<DexFileContainer> container = nullptr) const;
-
- // Open a dex file with a separate data section.
- virtual std::unique_ptr<const DexFile> OpenWithDataSection(
- const uint8_t* base,
- size_t size,
- const uint8_t* data_base,
- size_t data_size,
- const std::string& location,
- uint32_t location_checksum,
- const OatDexFile* oat_dex_file,
- bool verify,
- bool verify_checksum,
- std::string* error_msg) const;
-
+ virtual std::unique_ptr<const DexFile> Open(const uint8_t* base,
+ size_t size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg) const;
// Opens all .dex files found in the memory map, guessing the container format based on file
// extension.
@@ -179,11 +163,7 @@
kVerifyFailed
};
- static std::unique_ptr<DexFile> OpenCommon(const uint8_t* base,
- size_t size,
- const uint8_t* data_base,
- size_t data_size,
- const std::string& location,
+ static std::unique_ptr<DexFile> OpenCommon(const std::string& location,
uint32_t location_checksum,
const OatDexFile* oat_dex_file,
bool verify,
diff --git a/libdexfile/dex/standard_dex_file.h b/libdexfile/dex/standard_dex_file.h
index 25cf62a..cbd9be9 100644
--- a/libdexfile/dex/standard_dex_file.h
+++ b/libdexfile/dex/standard_dex_file.h
@@ -18,6 +18,7 @@
#define ART_LIBDEXFILE_DEX_STANDARD_DEX_FILE_H_
#include <iosfwd>
+#include <memory>
#include "dex_file.h"
diff --git a/runtime/vdex_file.cc b/runtime/vdex_file.cc
index f07233c..6ad8a0f 100644
--- a/runtime/vdex_file.cc
+++ b/runtime/vdex_file.cc
@@ -224,17 +224,14 @@
// TODO: Supply the location information for a vdex file.
static constexpr char kVdexLocation[] = "";
std::string location = DexFileLoader::GetMultiDexLocation(i, kVdexLocation);
- std::unique_ptr<const DexFile> dex(dex_file_loader.OpenWithDataSection(
- dex_file_start,
- size,
- /*data_base=*/ nullptr,
- /*data_size=*/ 0u,
- location,
- GetLocationChecksum(i),
- /*oat_dex_file=*/ nullptr,
- /*verify=*/ false,
- /*verify_checksum=*/ false,
- error_msg));
+ std::unique_ptr<const DexFile> dex(dex_file_loader.Open(dex_file_start,
+ size,
+ location,
+ GetLocationChecksum(i),
+ /*oat_dex_file=*/nullptr,
+ /*verify=*/false,
+ /*verify_checksum=*/false,
+ error_msg));
if (dex == nullptr) {
return false;
}