Add ELF loader to OatFile.
Change-Id: I062c3cc78ff9a35d0efcbc9451e7e7ccb055667b
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 344f844..e755cbd 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -645,7 +645,9 @@
std::string oat_filename;
oat_filename += runtime->GetHostPrefix();
oat_filename += oat_location->ToModifiedUtf8();
- OatFile* oat_file = OatFile::Open(oat_filename, oat_filename, image_header.GetOatBegin());
+ OatFile* oat_file = OatFile::Open(oat_filename, oat_filename,
+ image_header.GetOatBegin(),
+ OatFile::kRelocNone);
VLOG(startup) << "ClassLinker::OpenOat entering oat_filename=" << oat_filename;
if (oat_file == NULL) {
LOG(ERROR) << "Failed to open oat file " << oat_filename << " referenced from image.";
@@ -729,7 +731,8 @@
static const DexFile* FindDexFileInOatLocation(const std::string& dex_location,
uint32_t dex_location_checksum,
const std::string& oat_location) {
- UniquePtr<OatFile> oat_file(OatFile::Open(oat_location, oat_location, NULL));
+ UniquePtr<OatFile> oat_file(
+ OatFile::Open(oat_location, oat_location, NULL, OatFile::kRelocAll));
if (oat_file.get() == NULL) {
return NULL;
}
@@ -781,7 +784,8 @@
LOG(ERROR) << "Failed to seek to start of generated oat file: " << oat_location;
return NULL;
}
- const OatFile* oat_file = OatFile::Open(*file.get(), oat_location, NULL);
+ const OatFile* oat_file =
+ OatFile::Open(*file.get(), oat_location, NULL, OatFile::kRelocAll);
if (oat_file == NULL) {
LOG(ERROR) << "Failed to open generated oat file: " << oat_location;
return NULL;
@@ -877,7 +881,8 @@
return oat_file;
}
- oat_file = OatFile::Open(oat_location, oat_location, NULL);
+ oat_file = OatFile::Open(oat_location, oat_location, NULL,
+ OatFile::kRelocAll);
if (oat_file == NULL) {
return NULL;
}
@@ -3513,4 +3518,10 @@
class_roots_->Set(class_root, klass);
}
+void ClassLinker::RelocateExecutable() {
+ for (size_t i = 0; i < oat_files_.size(); ++i) {
+ const_cast<OatFile*>(oat_files_[i])->RelocateExecutable();
+ }
+}
+
} // namespace art