ImageHeader
ImageHeader size 0x80 = 140个字节
// header of image files written by ImageWriter, read and validated by Space. class PACKED(4) ImageHeader { public: ImageHeader() : compile_pic_(0) {} ImageHeader(uint32_t image_begin, uint32_t image_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_); static std::string GetOatLocationFromImageLocation(const std::string& image) { std::string oat_filename = image; if (oat_filename.length() <= 3) { oat_filename += ".oat"; } else { oat_filename.replace(oat_filename.length() - 3, 3, "oat"); } return oat_filename; } enum ImageMethod { kResolutionMethod, kImtConflictMethod, kImtUnimplementedMethod, kCalleeSaveMethod, kRefsOnlySaveMethod, kRefsAndArgsSaveMethod, kImageMethodsCount, // Number of elements in enum. }; enum ImageRoot { kDexCaches, kClassRoots, kImageRootsMax, }; enum ImageSections { kSectionObjects, kSectionArtFields, kSectionArtMethods, kSectionInternedStrings, kSectionImageBitmap, kSectionCount, // Number of elements in enum. }; void RelocateImage(off_t delta); private: static const uint8_t kImageMagic[4]; static const uint8_t kImageVersion[4]; uint8_t magic_[4]; uint8_t version_[4]; // Required base address for mapping the image. uint32_t image_begin_; // Image size, not page aligned. uint32_t image_size_; // Checksum of the oat file we link to for load time sanity check. uint32_t oat_checksum_; // Start address for oat file. Will be before oat_data_begin_ for .so files. uint32_t oat_file_begin_; // Required oat address expected by image Method::GetCode() pointers. uint32_t oat_data_begin_; // End of oat data address range for this image file. uint32_t oat_data_end_; // End of oat file address range. will be after oat_data_end_ for // .so files. Used for positioning a following alloc spaces. uint32_t oat_file_end_; // The total delta that this image has been patched. int32_t patch_delta_; // Absolute address of an Object[] of objects needed to reinitialize from an image. uint32_t image_roots_; // Pointer size, this affects the size of the ArtMethods. uint32_t pointer_size_; // Boolean (0 or 1) to denote if the image was compiled with --compile-pic option const uint32_t compile_pic_; // Image sections ImageSection sections_[kSectionCount]; // Image methods. uint64_t image_methods_[kImageMethodsCount]; };
image_begin_ : image_file映射到内存的绝对地址。是从image_file文件的0位置开始映射的,映射的字节数为image_size_(因为整页映射可能会被修正)
image map
std::unique_ptr<MemMap> map(MemMap::MapFileAtAddress( image_header.GetImageBegin(), image_header.GetImageSize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, file->Fd(), 0, false, image_filename, error_msg));
live_bitmap map
// caoming ImageSection bitmap_section is used to describe live_bitmap const auto& bitmap_section = image_header.GetImageSection(ImageHeader::kSectionImageBitmap); std::unique_ptr<MemMap> image_map(MemMap::MapFileAtAddress( nullptr, bitmap_section.Size(), PROT_READ, MAP_PRIVATE, file->Fd(), bitmap_section.Offset(), false, image_filename, error_msg));
boot.art@class.dex 文件的加载
oat_checksum_: 与Image文件关联的boot.art@classes.oat文件的检验值。
oat_file_begin_: 与Image文件关联的boot.art@classes.oat文件映射到内存的起始位置。
oat_data_begin_: 与Image文件关联的boot.art@classes.oat文件的OATDATA段映射到内存的起始位置。
oat_data_end_: 与Image文件关联的boot.art@classes.oat文件的OATDATA段映射到内存的结束位置。
oat_file_end_: 与Image文件关联的boot.art@classes.oat文件映射到内存的结束位置。
image_roots_: 一个Object对象地址数组地址,这些Object对象就是在Image Space上分配的对象。

浙公网安备 33010602011771号