blob: af092ad3fea18f26fd3e04e9caf637d8be6b6b51 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
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 Carlstrom4a289ed2011-08-16 17:17:49 -070016
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_IMAGE_H_
18#define ART_RUNTIME_IMAGE_H_
Brian Carlstrom4a289ed2011-08-16 17:17:49 -070019
20#include <string.h>
21
Andreas Gampe542451c2016-07-26 09:02:02 -070022#include "base/enums.h"
David Sehr1979c642018-04-26 14:41:18 -070023#include "base/globals.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080024#include "mirror/object.h"
Brian Carlstrom4a289ed2011-08-16 17:17:49 -070025
26namespace art {
27
Mathieu Chartier54d220e2015-07-30 16:20:06 -070028class ArtField;
29class ArtMethod;
Vladimir Markoc13fbd82018-06-04 16:16:28 +010030template <class MirrorType> class ObjPtr;
Mathieu Chartier54d220e2015-07-30 16:20:06 -070031
Vladimir Marko74527972016-11-29 15:57:32 +000032namespace linker {
33class ImageWriter;
34} // namespace linker
35
David Sehra49e0532017-08-25 08:05:29 -070036class ObjectVisitor {
37 public:
38 virtual ~ObjectVisitor() {}
39
40 virtual void Visit(mirror::Object* object) = 0;
41};
42
Mathieu Chartier54d220e2015-07-30 16:20:06 -070043class ArtMethodVisitor {
44 public:
45 virtual ~ArtMethodVisitor() {}
46
47 virtual void Visit(ArtMethod* method) = 0;
48};
49
50class ArtFieldVisitor {
51 public:
52 virtual ~ArtFieldVisitor() {}
53
54 virtual void Visit(ArtField* method) = 0;
55};
56
Mathieu Chartiere401d142015-04-22 13:56:20 -070057class PACKED(4) ImageSection {
58 public:
59 ImageSection() : offset_(0), size_(0) { }
60 ImageSection(uint32_t offset, uint32_t size) : offset_(offset), size_(size) { }
61 ImageSection(const ImageSection& section) = default;
62 ImageSection& operator=(const ImageSection& section) = default;
63
64 uint32_t Offset() const {
65 return offset_;
66 }
67
68 uint32_t Size() const {
69 return size_;
70 }
71
72 uint32_t End() const {
73 return Offset() + Size();
74 }
75
76 bool Contains(uint64_t offset) const {
77 return offset - offset_ < size_;
78 }
79
80 private:
81 uint32_t offset_;
82 uint32_t size_;
83};
84
Brian Carlstrom4a289ed2011-08-16 17:17:49 -070085// header of image files written by ImageWriter, read and validated by Space.
Ian Rogersdf1ce912012-11-27 17:07:11 -080086class PACKED(4) ImageHeader {
Brian Carlstrom4a289ed2011-08-16 17:17:49 -070087 public:
Mathieu Chartierceb07b32015-12-10 09:33:21 -080088 enum StorageMode : uint32_t {
89 kStorageModeUncompressed,
90 kStorageModeLZ4,
Mathieu Chartiera6e81ed2016-02-25 13:52:10 -080091 kStorageModeLZ4HC,
Mathieu Chartierceb07b32015-12-10 09:33:21 -080092 kStorageModeCount, // Number of elements in enum.
93 };
94 static constexpr StorageMode kDefaultStorageMode = kStorageModeUncompressed;
95
Sebastien Hertzaa50d3a2015-08-25 15:25:41 +020096 ImageHeader()
Mathieu Chartierceb07b32015-12-10 09:33:21 -080097 : image_begin_(0U),
98 image_size_(0U),
99 oat_checksum_(0U),
100 oat_file_begin_(0U),
101 oat_data_begin_(0U),
102 oat_data_end_(0U),
103 oat_file_end_(0U),
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800104 boot_image_begin_(0U),
105 boot_image_size_(0U),
106 boot_oat_begin_(0U),
107 boot_oat_size_(0U),
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800108 patch_delta_(0),
109 image_roots_(0U),
110 pointer_size_(0U),
111 compile_pic_(0),
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800112 is_pic_(0),
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800113 storage_mode_(kDefaultStorageMode),
114 data_size_(0) {}
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700115
Ian Rogers30fab402012-01-23 15:43:46 -0800116 ImageHeader(uint32_t image_begin,
Mathieu Chartier763a31e2015-11-16 16:05:55 -0800117 uint32_t image_size,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700118 ImageSection* sections,
Brian Carlstrome24fa612011-09-29 00:53:55 -0700119 uint32_t image_roots,
120 uint32_t oat_checksum,
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800121 uint32_t oat_file_begin,
122 uint32_t oat_data_begin,
123 uint32_t oat_data_end,
Igor Murashkin46774762014-10-22 11:37:02 -0700124 uint32_t oat_file_end,
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800125 uint32_t boot_image_begin,
126 uint32_t boot_image_size,
127 uint32_t boot_oat_begin,
128 uint32_t boot_oat_size,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700129 uint32_t pointer_size,
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800130 bool compile_pic,
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800131 bool is_pic,
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800132 StorageMode storage_mode,
133 size_t data_size);
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700134
Brian Carlstrom68708f52013-09-03 14:15:31 -0700135 bool IsValid() const;
136 const char* GetMagic() const;
Brian Carlstrom78128a62011-09-15 17:21:19 -0700137
Ian Rogers13735952014-10-08 12:43:28 -0700138 uint8_t* GetImageBegin() const {
139 return reinterpret_cast<uint8_t*>(image_begin_);
Brian Carlstrome24fa612011-09-29 00:53:55 -0700140 }
141
Mathieu Chartier31e89252013-08-28 11:29:12 -0700142 size_t GetImageSize() const {
143 return static_cast<uint32_t>(image_size_);
144 }
145
Brian Carlstrome24fa612011-09-29 00:53:55 -0700146 uint32_t GetOatChecksum() const {
147 return oat_checksum_;
148 }
149
Brian Carlstroma85b8372012-10-18 17:00:32 -0700150 void SetOatChecksum(uint32_t oat_checksum) {
151 oat_checksum_ = oat_checksum;
152 }
153
Mathieu Chartier5351da02016-02-17 16:19:53 -0800154 // The location that the oat file was expected to be when the image was created. The actual
155 // oat file may be at a different location for application images.
Ian Rogers13735952014-10-08 12:43:28 -0700156 uint8_t* GetOatFileBegin() const {
157 return reinterpret_cast<uint8_t*>(oat_file_begin_);
Brian Carlstrome24fa612011-09-29 00:53:55 -0700158 }
159
Ian Rogers13735952014-10-08 12:43:28 -0700160 uint8_t* GetOatDataBegin() const {
161 return reinterpret_cast<uint8_t*>(oat_data_begin_);
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800162 }
163
Ian Rogers13735952014-10-08 12:43:28 -0700164 uint8_t* GetOatDataEnd() const {
165 return reinterpret_cast<uint8_t*>(oat_data_end_);
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800166 }
167
Ian Rogers13735952014-10-08 12:43:28 -0700168 uint8_t* GetOatFileEnd() const {
169 return reinterpret_cast<uint8_t*>(oat_file_end_);
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700170 }
171
Andreas Gampebda1d602016-08-29 17:43:45 -0700172 PointerSize GetPointerSize() const;
Andreas Gampe542451c2016-07-26 09:02:02 -0700173
174 uint32_t GetPointerSizeUnchecked() const {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700175 return pointer_size_;
176 }
177
Alex Light53cb16b2014-06-12 11:26:29 -0700178 off_t GetPatchDelta() const {
179 return patch_delta_;
180 }
181
Alex Klyubind1d5c952017-12-15 12:57:33 -0800182 void SetPatchDelta(off_t patch_delta) {
183 patch_delta_ = patch_delta;
184 }
185
Nicolas Geoffray9583fbc2014-02-28 15:21:07 +0000186 static std::string GetOatLocationFromImageLocation(const std::string& image) {
David Brazdil7b49e6c2016-09-01 11:06:18 +0100187 return GetLocationFromImageLocation(image, "oat");
188 }
189
190 static std::string GetVdexLocationFromImageLocation(const std::string& image) {
191 return GetLocationFromImageLocation(image, "vdex");
Nicolas Geoffray9583fbc2014-02-28 15:21:07 +0000192 }
193
Mathieu Chartiere401d142015-04-22 13:56:20 -0700194 enum ImageMethod {
Ian Rogers19846512012-02-24 11:42:47 -0800195 kResolutionMethod,
Jeff Hao88474b42013-10-23 16:24:40 -0700196 kImtConflictMethod,
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700197 kImtUnimplementedMethod,
Vladimir Markofd36f1f2016-08-03 18:49:58 +0100198 kSaveAllCalleeSavesMethod,
199 kSaveRefsOnlyMethod,
200 kSaveRefsAndArgsMethod,
Vladimir Marko952dbb12016-07-28 12:01:51 +0100201 kSaveEverythingMethod,
Mingyao Yang0a87a652017-04-12 13:43:15 -0700202 kSaveEverythingMethodForClinit,
203 kSaveEverythingMethodForSuspendCheck,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700204 kImageMethodsCount, // Number of elements in enum.
205 };
206
207 enum ImageRoot {
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700208 kDexCaches,
Brian Carlstrom34f426c2011-10-04 12:58:02 -0700209 kClassRoots,
Vladimir Markoc13fbd82018-06-04 16:16:28 +0100210 kOomeWhenThrowingException, // Pre-allocated OOME when throwing exception.
211 kOomeWhenThrowingOome, // Pre-allocated OOME when throwing OOME.
212 kOomeWhenHandlingStackOverflow, // Pre-allocated OOME when handling StackOverflowError.
213 kNoClassDefFoundError, // Pre-allocated NoClassDefFoundError.
Vladimir Markof75613c2018-06-05 12:51:04 +0100214 kSpecialRoots, // Different for boot image and app image, see aliases below.
Brian Carlstrom16192862011-09-12 17:50:06 -0700215 kImageRootsMax,
Vladimir Markof75613c2018-06-05 12:51:04 +0100216
217 // Aliases.
218 kAppImageClassLoader = kSpecialRoots, // The class loader used to build the app image.
219 kBootImageLiveObjects = kSpecialRoots, // Array of boot image objects that must be kept live.
Brian Carlstrom16192862011-09-12 17:50:06 -0700220 };
221
Mathieu Chartiere401d142015-04-22 13:56:20 -0700222 enum ImageSections {
223 kSectionObjects,
224 kSectionArtFields,
225 kSectionArtMethods,
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700226 kSectionRuntimeMethods,
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000227 kSectionImTables,
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700228 kSectionIMTConflictTables,
Vladimir Marko05792b92015-08-03 11:56:49 +0100229 kSectionDexCacheArrays,
Mathieu Chartierd39645e2015-06-09 17:50:29 -0700230 kSectionInternedStrings,
Mathieu Chartier208a5cb2015-12-02 15:44:07 -0800231 kSectionClassTable,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700232 kSectionImageBitmap,
Vladimir Marko6121aa62018-07-06 10:04:35 +0100233 kSectionImageRelocations,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700234 kSectionCount, // Number of elements in enum.
235 };
236
Vladimir Markof75613c2018-06-05 12:51:04 +0100237 static size_t NumberOfImageRoots(bool app_image ATTRIBUTE_UNUSED) {
238 // At the moment, boot image and app image have the same number of roots,
239 // though the meaning of the kSpecialRoots is different.
240 return kImageRootsMax;
Vladimir Markoeca3eda2016-11-09 16:26:44 +0000241 }
242
Mathieu Chartiere401d142015-04-22 13:56:20 -0700243 ArtMethod* GetImageMethod(ImageMethod index) const;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700244
Vladimir Markocd87c3e2017-09-05 13:11:57 +0100245 const ImageSection& GetImageSection(ImageSections index) const {
246 DCHECK_LT(static_cast<size_t>(index), kSectionCount);
247 return sections_[index];
248 }
249
250 const ImageSection& GetObjectsSection() const {
251 return GetImageSection(kSectionObjects);
252 }
253
254 const ImageSection& GetFieldsSection() const {
255 return GetImageSection(ImageHeader::kSectionArtFields);
256 }
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700257
Mathieu Chartiere401d142015-04-22 13:56:20 -0700258 const ImageSection& GetMethodsSection() const {
259 return GetImageSection(kSectionArtMethods);
260 }
261
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700262 const ImageSection& GetRuntimeMethodsSection() const {
263 return GetImageSection(kSectionRuntimeMethods);
264 }
265
Vladimir Markocd87c3e2017-09-05 13:11:57 +0100266 const ImageSection& GetImTablesSection() const {
267 return GetImageSection(kSectionImTables);
268 }
269
270 const ImageSection& GetIMTConflictTablesSection() const {
271 return GetImageSection(kSectionIMTConflictTables);
272 }
273
274 const ImageSection& GetDexCacheArraysSection() const {
275 return GetImageSection(kSectionDexCacheArrays);
276 }
277
278 const ImageSection& GetInternedStringsSection() const {
279 return GetImageSection(kSectionInternedStrings);
280 }
281
282 const ImageSection& GetClassTableSection() const {
283 return GetImageSection(kSectionClassTable);
284 }
285
286 const ImageSection& GetImageBitmapSection() const {
287 return GetImageSection(kSectionImageBitmap);
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700288 }
289
Vladimir Marko6121aa62018-07-06 10:04:35 +0100290 const ImageSection& GetImageRelocationsSection() const {
291 return GetImageSection(kSectionImageRelocations);
292 }
293
Mathieu Chartier4a26f172016-01-26 14:26:18 -0800294 template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Vladimir Markoc13fbd82018-06-04 16:16:28 +0100295 ObjPtr<mirror::Object> GetImageRoot(ImageRoot image_root) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700296 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4a26f172016-01-26 14:26:18 -0800297
298 template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Vladimir Markoc13fbd82018-06-04 16:16:28 +0100299 ObjPtr<mirror::ObjectArray<mirror::Object>> GetImageRoots() const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700300 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700301
Alex Light53cb16b2014-06-12 11:26:29 -0700302 void RelocateImage(off_t delta);
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800303 void RelocateImageMethods(off_t delta);
304 void RelocateImageObjects(off_t delta);
Alex Light53cb16b2014-06-12 11:26:29 -0700305
Igor Murashkin46774762014-10-22 11:37:02 -0700306 bool CompilePic() const {
307 return compile_pic_ != 0;
308 }
309
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800310 bool IsPic() const {
311 return is_pic_ != 0;
312 }
313
314 uint32_t GetBootImageBegin() const {
315 return boot_image_begin_;
316 }
317
318 uint32_t GetBootImageSize() const {
319 return boot_image_size_;
320 }
321
322 uint32_t GetBootOatBegin() const {
323 return boot_oat_begin_;
324 }
325
326 uint32_t GetBootOatSize() const {
327 return boot_oat_size_;
328 }
329
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800330 StorageMode GetStorageMode() const {
331 return storage_mode_;
332 }
333
334 uint64_t GetDataSize() const {
335 return data_size_;
336 }
337
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800338 bool IsAppImage() const {
339 // App images currently require a boot image, if the size is non zero then it is an app image
340 // header.
341 return boot_image_size_ != 0u;
342 }
343
David Sehra49e0532017-08-25 08:05:29 -0700344 // Visit mirror::Objects in the section starting at base.
345 // TODO: Delete base parameter if it is always equal to GetImageBegin.
346 void VisitObjects(ObjectVisitor* visitor,
347 uint8_t* base,
348 PointerSize pointer_size) const
349 REQUIRES_SHARED(Locks::mutator_lock_);
350
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700351 // Visit ArtMethods in the section starting at base. Includes runtime methods.
352 // TODO: Delete base parameter if it is always equal to GetImageBegin.
Andreas Gampe542451c2016-07-26 09:02:02 -0700353 void VisitPackedArtMethods(ArtMethodVisitor* visitor,
354 uint8_t* base,
355 PointerSize pointer_size) const;
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700356
357 // Visit ArtMethods in the section starting at base.
358 // TODO: Delete base parameter if it is always equal to GetImageBegin.
359 void VisitPackedArtFields(ArtFieldVisitor* visitor, uint8_t* base) const;
360
361 template <typename Visitor>
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000362 void VisitPackedImTables(const Visitor& visitor,
363 uint8_t* base,
Andreas Gampe542451c2016-07-26 09:02:02 -0700364 PointerSize pointer_size) const;
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000365
366 template <typename Visitor>
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700367 void VisitPackedImtConflictTables(const Visitor& visitor,
368 uint8_t* base,
Andreas Gampe542451c2016-07-26 09:02:02 -0700369 PointerSize pointer_size) const;
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700370
Alex Light53cb16b2014-06-12 11:26:29 -0700371 private:
Ian Rogers13735952014-10-08 12:43:28 -0700372 static const uint8_t kImageMagic[4];
373 static const uint8_t kImageVersion[4];
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700374
David Brazdil7b49e6c2016-09-01 11:06:18 +0100375 static std::string GetLocationFromImageLocation(const std::string& image,
376 const std::string& extension) {
377 std::string filename = image;
378 if (filename.length() <= 3) {
379 filename += "." + extension;
380 } else {
381 filename.replace(filename.length() - 3, 3, extension);
382 }
383 return filename;
384 }
385
Ian Rogers13735952014-10-08 12:43:28 -0700386 uint8_t magic_[4];
387 uint8_t version_[4];
Brian Carlstroma663ea52011-08-19 23:33:41 -0700388
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800389 // Required base address for mapping the image.
Ian Rogers30fab402012-01-23 15:43:46 -0800390 uint32_t image_begin_;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700391
Mathieu Chartier31e89252013-08-28 11:29:12 -0700392 // Image size, not page aligned.
393 uint32_t image_size_;
394
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800395 // Checksum of the oat file we link to for load time sanity check.
Brian Carlstrome24fa612011-09-29 00:53:55 -0700396 uint32_t oat_checksum_;
397
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800398 // Start address for oat file. Will be before oat_data_begin_ for .so files.
399 uint32_t oat_file_begin_;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700400
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800401 // Required oat address expected by image Method::GetCode() pointers.
402 uint32_t oat_data_begin_;
Brian Carlstrom16192862011-09-12 17:50:06 -0700403
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800404 // End of oat data address range for this image file.
405 uint32_t oat_data_end_;
406
407 // End of oat file address range. will be after oat_data_end_ for
408 // .so files. Used for positioning a following alloc spaces.
409 uint32_t oat_file_end_;
410
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800411 // Boot image begin and end (app image headers only).
412 uint32_t boot_image_begin_;
413 uint32_t boot_image_size_;
414
415 // Boot oat begin and end (app image headers only).
416 uint32_t boot_oat_begin_;
417 uint32_t boot_oat_size_;
418
419 // TODO: We should probably insert a boot image checksum for app images.
420
Alex Light53cb16b2014-06-12 11:26:29 -0700421 // The total delta that this image has been patched.
422 int32_t patch_delta_;
423
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800424 // Absolute address of an Object[] of objects needed to reinitialize from an image.
Brian Carlstrom16192862011-09-12 17:50:06 -0700425 uint32_t image_roots_;
426
Mathieu Chartiere401d142015-04-22 13:56:20 -0700427 // Pointer size, this affects the size of the ArtMethods.
428 uint32_t pointer_size_;
429
Igor Murashkin46774762014-10-22 11:37:02 -0700430 // Boolean (0 or 1) to denote if the image was compiled with --compile-pic option
431 const uint32_t compile_pic_;
432
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800433 // Boolean (0 or 1) to denote if the image can be mapped at a random address, this only refers to
434 // the .art file. Currently, app oat files do not depend on their app image. There are no pointers
435 // from the app oat code to the app image.
436 const uint32_t is_pic_;
437
Mathieu Chartier67ad20e2015-12-09 15:41:09 -0800438 // Image section sizes/offsets correspond to the uncompressed form.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700439 ImageSection sections_[kSectionCount];
440
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800441 // Image methods, may be inside of the boot image for app images.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700442 uint64_t image_methods_[kImageMethodsCount];
443
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800444 // Storage method for the image, the image may be compressed.
445 StorageMode storage_mode_;
446
447 // Data size for the image data excluding the bitmap and the header. For compressed images, this
448 // is the compressed size in the file.
449 uint32_t data_size_;
450
Vladimir Marko74527972016-11-29 15:57:32 +0000451 friend class linker::ImageWriter;
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700452};
453
Mathieu Chartiere401d142015-04-22 13:56:20 -0700454std::ostream& operator<<(std::ostream& os, const ImageHeader::ImageMethod& policy);
455std::ostream& operator<<(std::ostream& os, const ImageHeader::ImageRoot& policy);
456std::ostream& operator<<(std::ostream& os, const ImageHeader::ImageSections& section);
457std::ostream& operator<<(std::ostream& os, const ImageSection& section);
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800458std::ostream& operator<<(std::ostream& os, const ImageHeader::StorageMode& mode);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700459
Brian Carlstrom4a289ed2011-08-16 17:17:49 -0700460} // namespace art
461
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700462#endif // ART_RUNTIME_IMAGE_H_