summaryrefslogtreecommitdiffstats
path: root/runtime/oat_file.cc
diff options
context:
space:
mode:
authorAlex Light <allight@google.com>2014-08-14 14:16:26 -0700
committerAlex Light <allight@google.com>2014-08-19 14:07:49 -0700
commit9dcc4572949f6a8231a1b4ed859676ba6f411726 (patch)
tree127ad110c7bd5fa865de2dd64e8658e73d95ddc0 /runtime/oat_file.cc
parent57101be6db093d9d27776f77eb8880ae5bae9913 (diff)
downloadart-9dcc4572949f6a8231a1b4ed859676ba6f411726.zip
art-9dcc4572949f6a8231a1b4ed859676ba6f411726.tar.gz
art-9dcc4572949f6a8231a1b4ed859676ba6f411726.tar.bz2
Make apps able to run with a failing patchoat
Bug: 17000769 Change-Id: I0a1a4dc7f5d4bb268530840302ecfb1555231e05
Diffstat (limited to 'runtime/oat_file.cc')
-rw-r--r--runtime/oat_file.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index b74b10f..7d9922d 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -45,7 +45,7 @@ OatFile* OatFile::OpenMemory(std::vector<uint8_t>& oat_contents,
std::string* error_msg) {
CHECK(!oat_contents.empty()) << location;
CheckLocation(location);
- std::unique_ptr<OatFile> oat_file(new OatFile(location));
+ std::unique_ptr<OatFile> oat_file(new OatFile(location, false));
oat_file->begin_ = &oat_contents[0];
oat_file->end_ = &oat_contents[oat_contents.size()];
return oat_file->Setup(error_msg) ? oat_file.release() : nullptr;
@@ -97,7 +97,7 @@ OatFile* OatFile::OpenDlopen(const std::string& elf_filename,
const std::string& location,
byte* requested_base,
std::string* error_msg) {
- std::unique_ptr<OatFile> oat_file(new OatFile(location));
+ std::unique_ptr<OatFile> oat_file(new OatFile(location, true));
bool success = oat_file->Dlopen(elf_filename, requested_base, error_msg);
if (!success) {
return nullptr;
@@ -111,7 +111,7 @@ OatFile* OatFile::OpenElfFile(File* file,
bool writable,
bool executable,
std::string* error_msg) {
- std::unique_ptr<OatFile> oat_file(new OatFile(location));
+ std::unique_ptr<OatFile> oat_file(new OatFile(location, executable));
bool success = oat_file->ElfFileOpen(file, requested_base, writable, executable, error_msg);
if (!success) {
CHECK(!error_msg->empty());
@@ -120,8 +120,9 @@ OatFile* OatFile::OpenElfFile(File* file,
return oat_file.release();
}
-OatFile::OatFile(const std::string& location)
- : location_(location), begin_(NULL), end_(NULL), dlopen_handle_(NULL),
+OatFile::OatFile(const std::string& location, bool is_executable)
+ : location_(location), begin_(NULL), end_(NULL), is_executable_(is_executable),
+ dlopen_handle_(NULL),
secondary_lookup_lock_("OatFile secondary lookup lock", kOatFileSecondaryLookupLock) {
CHECK(!location_.empty());
}
@@ -533,10 +534,15 @@ const OatFile::OatMethod OatFile::OatClass::GetOatMethod(uint32_t method_index)
methods_pointer_index = num_set_bits;
}
const OatMethodOffsets& oat_method_offsets = methods_pointer_[methods_pointer_index];
- return OatMethod(
- oat_file_->Begin(),
- oat_method_offsets.code_offset_,
- oat_method_offsets.gc_map_offset_);
+ if (oat_file_->IsExecutable() || Runtime::Current()->IsCompiler()) {
+ return OatMethod(
+ oat_file_->Begin(),
+ oat_method_offsets.code_offset_,
+ oat_method_offsets.gc_map_offset_);
+ } else {
+ // We aren't allowed to use the compiled code. We just force it down the interpreted version.
+ return OatMethod(oat_file_->Begin(), 0, 0);
+ }
}