diff options
Diffstat (limited to 'runtime/image.cc')
| -rw-r--r-- | runtime/image.cc | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/runtime/image.cc b/runtime/image.cc index d9bd2a8937..947c914de6 100644 --- a/runtime/image.cc +++ b/runtime/image.cc @@ -24,27 +24,21 @@ namespace art { const uint8_t ImageHeader::kImageMagic[] = { 'a', 'r', 't', '\n' }; -const uint8_t ImageHeader::kImageVersion[] = { '0', '1', '5', '\0' }; +const uint8_t ImageHeader::kImageVersion[] = { '0', '1', '6', '\0' }; ImageHeader::ImageHeader(uint32_t image_begin, uint32_t image_size, - uint32_t art_fields_offset, - uint32_t art_fields_size, - uint32_t image_bitmap_offset, - uint32_t image_bitmap_size, + ImageSection* sections, uint32_t image_roots, uint32_t oat_checksum, uint32_t oat_file_begin, uint32_t oat_data_begin, uint32_t oat_data_end, uint32_t oat_file_end, + uint32_t pointer_size, bool compile_pic) : image_begin_(image_begin), image_size_(image_size), - art_fields_offset_(art_fields_offset), - art_fields_size_(art_fields_size), - image_bitmap_offset_(image_bitmap_offset), - image_bitmap_size_(image_bitmap_size), oat_checksum_(oat_checksum), oat_file_begin_(oat_file_begin), oat_data_begin_(oat_data_begin), @@ -52,6 +46,7 @@ ImageHeader::ImageHeader(uint32_t image_begin, oat_file_end_(oat_file_end), patch_delta_(0), image_roots_(image_roots), + pointer_size_(pointer_size), compile_pic_(compile_pic) { CHECK_EQ(image_begin, RoundUp(image_begin, kPageSize)); CHECK_EQ(oat_file_begin, RoundUp(oat_file_begin, kPageSize)); @@ -61,8 +56,10 @@ ImageHeader::ImageHeader(uint32_t image_begin, CHECK_LE(oat_file_begin, oat_data_begin); CHECK_LT(oat_data_begin, oat_data_end); CHECK_LE(oat_data_end, oat_file_end); + CHECK(ValidPointerSize(pointer_size_)) << pointer_size_; memcpy(magic_, kImageMagic, sizeof(kImageMagic)); memcpy(version_, kImageVersion, sizeof(kImageVersion)); + std::copy_n(sections, kSectionCount, sections_); } void ImageHeader::RelocateImage(off_t delta) { @@ -74,6 +71,9 @@ void ImageHeader::RelocateImage(off_t delta) { oat_file_end_ += delta; image_roots_ += delta; patch_delta_ += delta; + for (size_t i = 0; i < kImageMethodsCount; ++i) { + image_methods_[i] += delta; + } } bool ImageHeader::IsValid() const { @@ -128,4 +128,23 @@ mirror::ObjectArray<mirror::Object>* ImageHeader::GetImageRoots() const { return result; } +ArtMethod* ImageHeader::GetImageMethod(ImageMethod index) const { + CHECK_LT(static_cast<size_t>(index), kImageMethodsCount); + return reinterpret_cast<ArtMethod*>(image_methods_[index]); +} + +void ImageHeader::SetImageMethod(ImageMethod index, ArtMethod* method) { + CHECK_LT(static_cast<size_t>(index), kImageMethodsCount); + image_methods_[index] = reinterpret_cast<uint64_t>(method); +} + +const ImageSection& ImageHeader::GetImageSection(ImageSections index) const { + CHECK_LT(static_cast<size_t>(index), kSectionCount); + return sections_[index]; +} + +std::ostream& operator<<(std::ostream& os, const ImageSection& section) { + return os << "size=" << section.Size() << " range=" << section.Offset() << "-" << section.End(); +} + } // namespace art |