Store additional information in image header.
Store the reservation needed for loading the boot image and
the number of boot class path components. The former helps
avoid one extra file open+read+close when loading the boot
image and the latter shall be used in subsequent CLs to load
boot image for a partial boot class path.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Bug: 119868597
Change-Id: I01dba923cfa3f8faf0e41a4139b8913c78404d54
diff --git a/runtime/image.cc b/runtime/image.cc
index fb581f9..fe1d88f 100644
--- a/runtime/image.cc
+++ b/runtime/image.cc
@@ -29,9 +29,11 @@
namespace art {
const uint8_t ImageHeader::kImageMagic[] = { 'a', 'r', 't', '\n' };
-const uint8_t ImageHeader::kImageVersion[] = { '0', '7', '2', '\0' }; // CRC32UpdateBytes intrinsic
+const uint8_t ImageHeader::kImageVersion[] = { '0', '7', '3', '\0' }; // Image reservation.
-ImageHeader::ImageHeader(uint32_t image_begin,
+ImageHeader::ImageHeader(uint32_t image_reservation_size,
+ uint32_t component_count,
+ uint32_t image_begin,
uint32_t image_size,
ImageSection* sections,
uint32_t image_roots,
@@ -43,7 +45,9 @@
uint32_t boot_image_begin,
uint32_t boot_image_size,
uint32_t pointer_size)
- : image_begin_(image_begin),
+ : image_reservation_size_(image_reservation_size),
+ component_count_(component_count),
+ image_begin_(image_begin),
image_size_(image_size),
image_checksum_(0u),
oat_checksum_(oat_checksum),
@@ -96,6 +100,9 @@
if (memcmp(version_, kImageVersion, sizeof(kImageVersion)) != 0) {
return false;
}
+ if (!IsAligned<kPageSize>(image_reservation_size_)) {
+ return false;
+ }
// Unsigned so wraparound is well defined.
if (image_begin_ >= image_begin_ + image_size_) {
return false;