Move .art.rel data to a section in .art, part 2.
And change the encoding to reduce the size of the data.
Keep the checksum in the .art.rel file, it shall be removed
later together with patchoat.
Boot image sizes for aosp_taimen-userdebug:
- before:
arm/boot*.art: 9216000
arm/boot*.art.rel: 700767
arm64/boot*.art: 11399168
arm64/boot*.art.rel: 700808
oat/arm64/services.art: 192512
- after:
arm/boot*.art: 9499351 (+276.7KiB)
arm/boot*.art.rel: 480 (-683.9KiB)
arm64/boot*.art: 11750203 (+342.8KiB)
arm64/boot*.art.rel: 480 (-683.9KiB)
oat/arm64/services.art: 202466 (+9.7KiB)
Note that the new section is currently uncompressed in the
boot image but we have the ability to compress it in the
future using the same compression as the heap data.
The extra data we now encode in app images is unused so far
but it shall permit fast in-memory patching without looking
at object types.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: testrunner.py --target --optimizing
Bug: 77856493
Change-Id: I20c9bed9797ce0f23f39c2fb0d64320b457e18d4
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index cbce940..ef0a564 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -618,10 +618,21 @@
const size_t image_bitmap_offset = RoundUp(sizeof(ImageHeader) + image_header->GetDataSize(),
kPageSize);
const size_t end_of_bitmap = image_bitmap_offset + bitmap_section.Size();
- if (end_of_bitmap != image_file_size) {
+ const ImageSection& relocations_section = image_header->GetImageRelocationsSection();
+ if (relocations_section.Offset() != bitmap_section.Offset() + bitmap_section.Size()) {
*error_msg = StringPrintf(
- "Image file size does not equal end of bitmap: size=%" PRIu64 " vs. %zu.", image_file_size,
- end_of_bitmap);
+ "Relocations do not start immediately after bitmap: %u vs. %u + %u.",
+ relocations_section.Offset(),
+ bitmap_section.Offset(),
+ bitmap_section.Size());
+ return nullptr;
+ }
+ const size_t end_of_relocations = end_of_bitmap + relocations_section.Size();
+ if (end_of_relocations != image_file_size) {
+ *error_msg = StringPrintf(
+ "Image file size does not equal end of relocations: size=%" PRIu64 " vs. %zu.",
+ image_file_size,
+ end_of_relocations);
return nullptr;
}