Support booting without functioning boot.oat/art patchoat.
Bug: 17000769
(cherry picked from commit 84d7605f93f1e6e86a16e02017e305c90e93117a)
Change-Id: I89c26a905af12ea288742368c2c038afd57a879a
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 97f20d3..c2a3ab7 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1171,6 +1171,7 @@
error_msg.c_str()));
return nullptr;
} else if (!oat_file->IsExecutable() &&
+ Runtime::Current()->GetHeap()->HasImageSpace() &&
!VerifyOatImageChecksum(oat_file.get(), isa)) {
error_msgs->push_back(StringPrintf("Failed to verify non-executable oat file '%s' found for "
"dex location '%s'. Image checksum incorrect.",
@@ -1253,6 +1254,7 @@
std::string odex_error_msg;
bool should_patch_system = false;
bool odex_checksum_verified = false;
+ bool have_system_odex = false;
{
// There is a high probability that these both these oat files map similar/the same address
// spaces so we must scope them like this so they each gets its turn.
@@ -1263,14 +1265,18 @@
&odex_error_msg)) {
error_msgs->push_back(odex_error_msg);
return odex_oat_file.release();
- } else if (odex_checksum_verified) {
- // We can just relocate
- should_patch_system = true;
- odex_error_msg = "Image Patches are incorrect";
+ } else {
+ if (odex_checksum_verified) {
+ // We can just relocate
+ should_patch_system = true;
+ odex_error_msg = "Image Patches are incorrect";
+ }
+ if (odex_oat_file.get() != nullptr) {
+ have_system_odex = true;
+ }
}
}
-
std::string cache_error_msg;
bool should_patch_cache = false;
bool cache_checksum_verified = false;
@@ -1306,6 +1312,8 @@
CHECK(have_dalvik_cache);
ret = PatchAndRetrieveOat(cache_filename, cache_filename, image_location, isa, &error_msg);
}
+ } else if (have_system_odex) {
+ ret = GetInterpretedOnlyOat(odex_filename, isa, &error_msg);
}
}
if (ret == nullptr && have_dalvik_cache && OS::FileExists(cache_filename.c_str())) {
@@ -1355,7 +1363,8 @@
if (output.get() == nullptr) {
return nullptr;
}
- if (VerifyOatImageChecksum(output.get(), isa)) {
+ if (!Runtime::Current()->GetHeap()->HasImageSpace() ||
+ VerifyOatImageChecksum(output.get(), isa)) {
return output.release();
} else {
*error_msg = StringPrintf("Could not use oat file '%s', image checksum failed to verify.",