ART: Reinstate secondary-image-patching exit

Do not attempt imageless running with a stale secondary image. Instead
prune the cache and exit, relying on init restarting the process.

The combined image checksum is not written down into the boot image
itself, only into apps. This should really be fixed.

Follow-up to commit a463b6a920a2a0bf14f9cca20a561b412b9349d1.

(cherry picked from commit 8d8a005ae3ae355dee88b3cb1351b93a070d4209)

Bug: 30832951
Bug: 69428309
Bug: 70213235
Bug: 70498154
Test: m test-art-host
Merged-In: I27ab3384ce4ffd93efb00a2e216cb839fe4357d5
Change-Id: I27ab3384ce4ffd93efb00a2e216cb839fe4357d5
(cherry picked from commit 8187e0baaa634151a070dfbf6f933e1f529d7ef6)
diff --git a/runtime/gc/space/ b/runtime/gc/space/
index fe0d35f..3aab4c6 100644
--- a/runtime/gc/space/
+++ b/runtime/gc/space/
@@ -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);