Merge cherrypicks of [3353959] into oc-m3-release
Change-Id: Icdebab1c6a4525c5c971d59560b8aa6cfef0c010
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index fe0d35f..3aab4c6 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -1574,7 +1574,9 @@
if (!Runtime::Current()->IsImageDex2OatEnabled()) {
local_error_msg = "Patching disabled.";
} else if (secondary_image) {
- local_error_msg = "Cannot patch a secondary image.";
+ // We really want a working image. Prune and restart.
+ PruneDalvikCache(image_isa);
+ _exit(1);
} else if (ImageCreationAllowed(is_global_cache, image_isa, &local_error_msg)) {
bool patch_success =
RelocateImage(image_location, cache_filename.c_str(), image_isa, &local_error_msg);