Single-image boot image extensions.
Allow boot image extensions to be compiled into a single
art/oat/vdex triplet for any number of input dex files.
Support argument --image-fd so that this can be done with
file descriptors. This is intended for creating a boot
image extension in memory when starting zygote.
Remove the possibility to specify multiple oat or image
files. It was unused and untested.
Test: New test in dex2oat_image_test
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I78e5410642a5df14c0891d87f27eefcb02156764
diff --git a/runtime/image.cc b/runtime/image.cc
index 07fcc8b..782c0c6 100644
--- a/runtime/image.cc
+++ b/runtime/image.cc
@@ -29,7 +29,7 @@
namespace art {
const uint8_t ImageHeader::kImageMagic[] = { 'a', 'r', 't', '\n' };
-const uint8_t ImageHeader::kImageVersion[] = { '0', '8', '4', '\0' }; // FP16 gt/ge/lt/le intrinsic
+const uint8_t ImageHeader::kImageVersion[] = { '0', '8', '5', '\0' }; // Single-image.
ImageHeader::ImageHeader(uint32_t image_reservation_size,
uint32_t component_count,
@@ -104,6 +104,14 @@
return image_reservation_size_ == RoundUp(image_size_, kPageSize);
}
+uint32_t ImageHeader::GetImageSpaceCount() const {
+ DCHECK(!IsAppImage());
+ DCHECK_NE(component_count_, 0u); // Must be the header for the first component.
+ // For images compiled with --single-image, there is only one oat file. To detect
+ // that, check whether the reservation ends at the end of the first oat file.
+ return (image_begin_ + image_reservation_size_ == oat_file_end_) ? 1u : component_count_;
+}
+
bool ImageHeader::IsValid() const {
if (memcmp(magic_, kImageMagic, sizeof(kImageMagic)) != 0) {
return false;