Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_IMAGE_H_ |
| 18 | #define ART_RUNTIME_IMAGE_H_ |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 19 | |
| 20 | #include <string.h> |
| 21 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 22 | #include "base/enums.h" |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 23 | #include "globals.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 24 | #include "mirror/object.h" |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 25 | |
| 26 | namespace art { |
| 27 | |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 28 | class ArtField; |
| 29 | class ArtMethod; |
| 30 | |
| 31 | class ArtMethodVisitor { |
| 32 | public: |
| 33 | virtual ~ArtMethodVisitor() {} |
| 34 | |
| 35 | virtual void Visit(ArtMethod* method) = 0; |
| 36 | }; |
| 37 | |
| 38 | class ArtFieldVisitor { |
| 39 | public: |
| 40 | virtual ~ArtFieldVisitor() {} |
| 41 | |
| 42 | virtual void Visit(ArtField* method) = 0; |
| 43 | }; |
| 44 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 45 | class PACKED(4) ImageSection { |
| 46 | public: |
| 47 | ImageSection() : offset_(0), size_(0) { } |
| 48 | ImageSection(uint32_t offset, uint32_t size) : offset_(offset), size_(size) { } |
| 49 | ImageSection(const ImageSection& section) = default; |
| 50 | ImageSection& operator=(const ImageSection& section) = default; |
| 51 | |
| 52 | uint32_t Offset() const { |
| 53 | return offset_; |
| 54 | } |
| 55 | |
| 56 | uint32_t Size() const { |
| 57 | return size_; |
| 58 | } |
| 59 | |
| 60 | uint32_t End() const { |
| 61 | return Offset() + Size(); |
| 62 | } |
| 63 | |
| 64 | bool Contains(uint64_t offset) const { |
| 65 | return offset - offset_ < size_; |
| 66 | } |
| 67 | |
| 68 | private: |
| 69 | uint32_t offset_; |
| 70 | uint32_t size_; |
| 71 | }; |
| 72 | |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 73 | // header of image files written by ImageWriter, read and validated by Space. |
Ian Rogers | df1ce91 | 2012-11-27 17:07:11 -0800 | [diff] [blame] | 74 | class PACKED(4) ImageHeader { |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 75 | public: |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 76 | enum StorageMode : uint32_t { |
| 77 | kStorageModeUncompressed, |
| 78 | kStorageModeLZ4, |
Mathieu Chartier | a6e81ed | 2016-02-25 13:52:10 -0800 | [diff] [blame] | 79 | kStorageModeLZ4HC, |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 80 | kStorageModeCount, // Number of elements in enum. |
| 81 | }; |
| 82 | static constexpr StorageMode kDefaultStorageMode = kStorageModeUncompressed; |
| 83 | |
Sebastien Hertz | aa50d3a | 2015-08-25 15:25:41 +0200 | [diff] [blame] | 84 | ImageHeader() |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 85 | : image_begin_(0U), |
| 86 | image_size_(0U), |
| 87 | oat_checksum_(0U), |
| 88 | oat_file_begin_(0U), |
| 89 | oat_data_begin_(0U), |
| 90 | oat_data_end_(0U), |
| 91 | oat_file_end_(0U), |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 92 | boot_image_begin_(0U), |
| 93 | boot_image_size_(0U), |
| 94 | boot_oat_begin_(0U), |
| 95 | boot_oat_size_(0U), |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 96 | patch_delta_(0), |
| 97 | image_roots_(0U), |
| 98 | pointer_size_(0U), |
| 99 | compile_pic_(0), |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 100 | is_pic_(0), |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 101 | storage_mode_(kDefaultStorageMode), |
| 102 | data_size_(0) {} |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 103 | |
Ian Rogers | 30fab40 | 2012-01-23 15:43:46 -0800 | [diff] [blame] | 104 | ImageHeader(uint32_t image_begin, |
Mathieu Chartier | 763a31e | 2015-11-16 16:05:55 -0800 | [diff] [blame] | 105 | uint32_t image_size, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 106 | ImageSection* sections, |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 107 | uint32_t image_roots, |
| 108 | uint32_t oat_checksum, |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 109 | uint32_t oat_file_begin, |
| 110 | uint32_t oat_data_begin, |
| 111 | uint32_t oat_data_end, |
Igor Murashkin | 4677476 | 2014-10-22 11:37:02 -0700 | [diff] [blame] | 112 | uint32_t oat_file_end, |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 113 | uint32_t boot_image_begin, |
| 114 | uint32_t boot_image_size, |
| 115 | uint32_t boot_oat_begin, |
| 116 | uint32_t boot_oat_size, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 117 | uint32_t pointer_size, |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 118 | bool compile_pic, |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 119 | bool is_pic, |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 120 | StorageMode storage_mode, |
| 121 | size_t data_size); |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 122 | |
Brian Carlstrom | 68708f5 | 2013-09-03 14:15:31 -0700 | [diff] [blame] | 123 | bool IsValid() const; |
| 124 | const char* GetMagic() const; |
Brian Carlstrom | 78128a6 | 2011-09-15 17:21:19 -0700 | [diff] [blame] | 125 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 126 | uint8_t* GetImageBegin() const { |
| 127 | return reinterpret_cast<uint8_t*>(image_begin_); |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Mathieu Chartier | 31e8925 | 2013-08-28 11:29:12 -0700 | [diff] [blame] | 130 | size_t GetImageSize() const { |
| 131 | return static_cast<uint32_t>(image_size_); |
| 132 | } |
| 133 | |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 134 | uint32_t GetOatChecksum() const { |
| 135 | return oat_checksum_; |
| 136 | } |
| 137 | |
Brian Carlstrom | a85b837 | 2012-10-18 17:00:32 -0700 | [diff] [blame] | 138 | void SetOatChecksum(uint32_t oat_checksum) { |
| 139 | oat_checksum_ = oat_checksum; |
| 140 | } |
| 141 | |
Mathieu Chartier | 5351da0 | 2016-02-17 16:19:53 -0800 | [diff] [blame] | 142 | // The location that the oat file was expected to be when the image was created. The actual |
| 143 | // oat file may be at a different location for application images. |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 144 | uint8_t* GetOatFileBegin() const { |
| 145 | return reinterpret_cast<uint8_t*>(oat_file_begin_); |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 146 | } |
| 147 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 148 | uint8_t* GetOatDataBegin() const { |
| 149 | return reinterpret_cast<uint8_t*>(oat_data_begin_); |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 150 | } |
| 151 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 152 | uint8_t* GetOatDataEnd() const { |
| 153 | return reinterpret_cast<uint8_t*>(oat_data_end_); |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 154 | } |
| 155 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 156 | uint8_t* GetOatFileEnd() const { |
| 157 | return reinterpret_cast<uint8_t*>(oat_file_end_); |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 160 | PointerSize GetPointerSize() const { |
| 161 | return ConvertToPointerSize(pointer_size_); |
| 162 | } |
| 163 | |
| 164 | uint32_t GetPointerSizeUnchecked() const { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 165 | return pointer_size_; |
| 166 | } |
| 167 | |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 168 | off_t GetPatchDelta() const { |
| 169 | return patch_delta_; |
| 170 | } |
| 171 | |
Nicolas Geoffray | 9583fbc | 2014-02-28 15:21:07 +0000 | [diff] [blame] | 172 | static std::string GetOatLocationFromImageLocation(const std::string& image) { |
| 173 | std::string oat_filename = image; |
| 174 | if (oat_filename.length() <= 3) { |
Ian Rogers | b9beb2e | 2014-05-09 16:57:40 -0700 | [diff] [blame] | 175 | oat_filename += ".oat"; |
Nicolas Geoffray | 9583fbc | 2014-02-28 15:21:07 +0000 | [diff] [blame] | 176 | } else { |
| 177 | oat_filename.replace(oat_filename.length() - 3, 3, "oat"); |
| 178 | } |
| 179 | return oat_filename; |
| 180 | } |
| 181 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 182 | enum ImageMethod { |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 183 | kResolutionMethod, |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 184 | kImtConflictMethod, |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 185 | kImtUnimplementedMethod, |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 186 | kSaveAllCalleeSavesMethod, |
| 187 | kSaveRefsOnlyMethod, |
| 188 | kSaveRefsAndArgsMethod, |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 189 | kSaveEverythingMethod, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 190 | kImageMethodsCount, // Number of elements in enum. |
| 191 | }; |
| 192 | |
| 193 | enum ImageRoot { |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 194 | kDexCaches, |
Brian Carlstrom | 34f426c | 2011-10-04 12:58:02 -0700 | [diff] [blame] | 195 | kClassRoots, |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 196 | kImageRootsMax, |
| 197 | }; |
| 198 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 199 | enum ImageSections { |
| 200 | kSectionObjects, |
| 201 | kSectionArtFields, |
| 202 | kSectionArtMethods, |
Mathieu Chartier | e42888f | 2016-04-14 10:49:19 -0700 | [diff] [blame] | 203 | kSectionRuntimeMethods, |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 204 | kSectionImTables, |
Mathieu Chartier | e42888f | 2016-04-14 10:49:19 -0700 | [diff] [blame] | 205 | kSectionIMTConflictTables, |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 206 | kSectionDexCacheArrays, |
Mathieu Chartier | d39645e | 2015-06-09 17:50:29 -0700 | [diff] [blame] | 207 | kSectionInternedStrings, |
Mathieu Chartier | 208a5cb | 2015-12-02 15:44:07 -0800 | [diff] [blame] | 208 | kSectionClassTable, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 209 | kSectionImageBitmap, |
| 210 | kSectionCount, // Number of elements in enum. |
| 211 | }; |
| 212 | |
| 213 | ArtMethod* GetImageMethod(ImageMethod index) const; |
| 214 | void SetImageMethod(ImageMethod index, ArtMethod* method); |
| 215 | |
| 216 | const ImageSection& GetImageSection(ImageSections index) const; |
Mathieu Chartier | e42888f | 2016-04-14 10:49:19 -0700 | [diff] [blame] | 217 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 218 | const ImageSection& GetMethodsSection() const { |
| 219 | return GetImageSection(kSectionArtMethods); |
| 220 | } |
| 221 | |
Mathieu Chartier | e42888f | 2016-04-14 10:49:19 -0700 | [diff] [blame] | 222 | const ImageSection& GetRuntimeMethodsSection() const { |
| 223 | return GetImageSection(kSectionRuntimeMethods); |
| 224 | } |
| 225 | |
| 226 | const ImageSection& GetFieldsSection() const { |
| 227 | return GetImageSection(ImageHeader::kSectionArtFields); |
| 228 | } |
| 229 | |
Mathieu Chartier | 4a26f17 | 2016-01-26 14:26:18 -0800 | [diff] [blame] | 230 | template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 231 | mirror::Object* GetImageRoot(ImageRoot image_root) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 232 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | 4a26f17 | 2016-01-26 14:26:18 -0800 | [diff] [blame] | 233 | |
| 234 | template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Hiroshi Yamauchi | 2cd334a | 2015-01-09 14:03:35 -0800 | [diff] [blame] | 235 | mirror::ObjectArray<mirror::Object>* GetImageRoots() const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 236 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 237 | |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 238 | void RelocateImage(off_t delta); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 239 | void RelocateImageMethods(off_t delta); |
| 240 | void RelocateImageObjects(off_t delta); |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 241 | |
Igor Murashkin | 4677476 | 2014-10-22 11:37:02 -0700 | [diff] [blame] | 242 | bool CompilePic() const { |
| 243 | return compile_pic_ != 0; |
| 244 | } |
| 245 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 246 | bool IsPic() const { |
| 247 | return is_pic_ != 0; |
| 248 | } |
| 249 | |
| 250 | uint32_t GetBootImageBegin() const { |
| 251 | return boot_image_begin_; |
| 252 | } |
| 253 | |
| 254 | uint32_t GetBootImageSize() const { |
| 255 | return boot_image_size_; |
| 256 | } |
| 257 | |
| 258 | uint32_t GetBootOatBegin() const { |
| 259 | return boot_oat_begin_; |
| 260 | } |
| 261 | |
| 262 | uint32_t GetBootOatSize() const { |
| 263 | return boot_oat_size_; |
| 264 | } |
| 265 | |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 266 | StorageMode GetStorageMode() const { |
| 267 | return storage_mode_; |
| 268 | } |
| 269 | |
| 270 | uint64_t GetDataSize() const { |
| 271 | return data_size_; |
| 272 | } |
| 273 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 274 | bool IsAppImage() const { |
| 275 | // App images currently require a boot image, if the size is non zero then it is an app image |
| 276 | // header. |
| 277 | return boot_image_size_ != 0u; |
| 278 | } |
| 279 | |
Mathieu Chartier | e42888f | 2016-04-14 10:49:19 -0700 | [diff] [blame] | 280 | // Visit ArtMethods in the section starting at base. Includes runtime methods. |
| 281 | // TODO: Delete base parameter if it is always equal to GetImageBegin. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 282 | void VisitPackedArtMethods(ArtMethodVisitor* visitor, |
| 283 | uint8_t* base, |
| 284 | PointerSize pointer_size) const; |
Mathieu Chartier | e42888f | 2016-04-14 10:49:19 -0700 | [diff] [blame] | 285 | |
| 286 | // Visit ArtMethods in the section starting at base. |
| 287 | // TODO: Delete base parameter if it is always equal to GetImageBegin. |
| 288 | void VisitPackedArtFields(ArtFieldVisitor* visitor, uint8_t* base) const; |
| 289 | |
| 290 | template <typename Visitor> |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 291 | void VisitPackedImTables(const Visitor& visitor, |
| 292 | uint8_t* base, |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 293 | PointerSize pointer_size) const; |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 294 | |
| 295 | template <typename Visitor> |
Mathieu Chartier | e42888f | 2016-04-14 10:49:19 -0700 | [diff] [blame] | 296 | void VisitPackedImtConflictTables(const Visitor& visitor, |
| 297 | uint8_t* base, |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 298 | PointerSize pointer_size) const; |
Mathieu Chartier | e42888f | 2016-04-14 10:49:19 -0700 | [diff] [blame] | 299 | |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 300 | private: |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 301 | static const uint8_t kImageMagic[4]; |
| 302 | static const uint8_t kImageVersion[4]; |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 303 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 304 | uint8_t magic_[4]; |
| 305 | uint8_t version_[4]; |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 306 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 307 | // Required base address for mapping the image. |
Ian Rogers | 30fab40 | 2012-01-23 15:43:46 -0800 | [diff] [blame] | 308 | uint32_t image_begin_; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 309 | |
Mathieu Chartier | 31e8925 | 2013-08-28 11:29:12 -0700 | [diff] [blame] | 310 | // Image size, not page aligned. |
| 311 | uint32_t image_size_; |
| 312 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 313 | // Checksum of the oat file we link to for load time sanity check. |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 314 | uint32_t oat_checksum_; |
| 315 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 316 | // Start address for oat file. Will be before oat_data_begin_ for .so files. |
| 317 | uint32_t oat_file_begin_; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 318 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 319 | // Required oat address expected by image Method::GetCode() pointers. |
| 320 | uint32_t oat_data_begin_; |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 321 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 322 | // End of oat data address range for this image file. |
| 323 | uint32_t oat_data_end_; |
| 324 | |
| 325 | // End of oat file address range. will be after oat_data_end_ for |
| 326 | // .so files. Used for positioning a following alloc spaces. |
| 327 | uint32_t oat_file_end_; |
| 328 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 329 | // Boot image begin and end (app image headers only). |
| 330 | uint32_t boot_image_begin_; |
| 331 | uint32_t boot_image_size_; |
| 332 | |
| 333 | // Boot oat begin and end (app image headers only). |
| 334 | uint32_t boot_oat_begin_; |
| 335 | uint32_t boot_oat_size_; |
| 336 | |
| 337 | // TODO: We should probably insert a boot image checksum for app images. |
| 338 | |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 339 | // The total delta that this image has been patched. |
| 340 | int32_t patch_delta_; |
| 341 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 342 | // Absolute address of an Object[] of objects needed to reinitialize from an image. |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 343 | uint32_t image_roots_; |
| 344 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 345 | // Pointer size, this affects the size of the ArtMethods. |
| 346 | uint32_t pointer_size_; |
| 347 | |
Igor Murashkin | 4677476 | 2014-10-22 11:37:02 -0700 | [diff] [blame] | 348 | // Boolean (0 or 1) to denote if the image was compiled with --compile-pic option |
| 349 | const uint32_t compile_pic_; |
| 350 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 351 | // Boolean (0 or 1) to denote if the image can be mapped at a random address, this only refers to |
| 352 | // the .art file. Currently, app oat files do not depend on their app image. There are no pointers |
| 353 | // from the app oat code to the app image. |
| 354 | const uint32_t is_pic_; |
| 355 | |
Mathieu Chartier | 67ad20e | 2015-12-09 15:41:09 -0800 | [diff] [blame] | 356 | // Image section sizes/offsets correspond to the uncompressed form. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 357 | ImageSection sections_[kSectionCount]; |
| 358 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 359 | // Image methods, may be inside of the boot image for app images. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 360 | uint64_t image_methods_[kImageMethodsCount]; |
| 361 | |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 362 | // Storage method for the image, the image may be compressed. |
| 363 | StorageMode storage_mode_; |
| 364 | |
| 365 | // Data size for the image data excluding the bitmap and the header. For compressed images, this |
| 366 | // is the compressed size in the file. |
| 367 | uint32_t data_size_; |
| 368 | |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 369 | friend class ImageWriter; |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 370 | }; |
| 371 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 372 | std::ostream& operator<<(std::ostream& os, const ImageHeader::ImageMethod& policy); |
| 373 | std::ostream& operator<<(std::ostream& os, const ImageHeader::ImageRoot& policy); |
| 374 | std::ostream& operator<<(std::ostream& os, const ImageHeader::ImageSections& section); |
| 375 | std::ostream& operator<<(std::ostream& os, const ImageSection& section); |
Mathieu Chartier | ceb07b3 | 2015-12-10 09:33:21 -0800 | [diff] [blame] | 376 | std::ostream& operator<<(std::ostream& os, const ImageHeader::StorageMode& mode); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 377 | |
Brian Carlstrom | 4a289ed | 2011-08-16 17:17:49 -0700 | [diff] [blame] | 378 | } // namespace art |
| 379 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 380 | #endif // ART_RUNTIME_IMAGE_H_ |