Support booting without functioning boot.oat/art patchoat.
Bug: 17000769
(cherry picked from commit 84d7605f93f1e6e86a16e02017e305c90e93117a)
Change-Id: I89c26a905af12ea288742368c2c038afd57a879a
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 6305994..2ebdebd 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -24,6 +24,7 @@
#include "base/stl_util.h"
#include "base/unix_file/fd_file.h"
#include "elf_file.h"
+#include "elf_utils.h"
#include "oat.h"
#include "mirror/art_method.h"
#include "mirror/art_method-inl.h"
@@ -40,6 +41,17 @@
CHECK(!location.empty());
}
+OatFile* OatFile::OpenWithElfFile(ElfFile* elf_file,
+ const std::string& location,
+ std::string* error_msg) {
+ std::unique_ptr<OatFile> oat_file(new OatFile(location, false));
+ oat_file->elf_file_.reset(elf_file);
+ Elf32_Shdr* hdr = elf_file->FindSectionByName(".rodata");
+ oat_file->begin_ = elf_file->Begin() + hdr->sh_offset;
+ oat_file->end_ = elf_file->Begin() + hdr->sh_size + hdr->sh_offset;
+ return oat_file->Setup(error_msg) ? oat_file.release() : nullptr;
+}
+
OatFile* OatFile::OpenMemory(std::vector<uint8_t>& oat_contents,
const std::string& location,
std::string* error_msg) {