• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
16 
17 #ifndef ART_DEX2OAT_LINKER_OAT_WRITER_H_
18 #define ART_DEX2OAT_LINKER_OAT_WRITER_H_
19 
20 #include <stdint.h>
21 #include <cstddef>
22 #include <list>
23 #include <memory>
24 #include <vector>
25 
26 #include "base/array_ref.h"
27 #include "base/dchecked_vector.h"
28 #include "base/os.h"
29 #include "base/mem_map.h"
30 #include "base/safe_map.h"
31 #include "debug/debug_info.h"
32 #include "dex/compact_dex_level.h"
33 #include "dex/method_reference.h"
34 #include "dex/string_reference.h"
35 #include "dex/type_reference.h"
36 #include "linker/relative_patcher.h"  // For RelativePatcherTargetProvider.
37 #include "mirror/class.h"
38 
39 namespace art {
40 
41 class BitVector;
42 class CompiledMethod;
43 class CompilerDriver;
44 class CompilerOptions;
45 class DexContainer;
46 class OatHeader;
47 class OutputStream;
48 class ProfileCompilationInfo;
49 class TimingLogger;
50 class TypeLookupTable;
51 class VdexFile;
52 class VerificationResults;
53 class ZipEntry;
54 
55 namespace debug {
56 struct MethodDebugInfo;
57 }  // namespace debug
58 
59 namespace verifier {
60 class VerifierDeps;
61 }  // namespace verifier
62 
63 namespace linker {
64 
65 class ImageWriter;
66 class MultiOatRelativePatcher;
67 
68 enum class CopyOption {
69   kNever,
70   kAlways,
71   kOnlyIfCompressed
72 };
73 
74 // OatHeader         variable length with count of D OatDexFiles
75 //
76 // TypeLookupTable[0] one descriptor to class def index hash table for each OatDexFile.
77 // TypeLookupTable[1]
78 // ...
79 // TypeLookupTable[D]
80 //
81 // ClassOffsets[0]   one table of OatClass offsets for each class def for each OatDexFile.
82 // ClassOffsets[1]
83 // ...
84 // ClassOffsets[D]
85 //
86 // OatClass[0]       one variable sized OatClass for each of C DexFile::ClassDefs
87 // OatClass[1]       contains OatClass entries with class status, offsets to code, etc.
88 // ...
89 // OatClass[C]
90 //
91 // MethodBssMapping  one variable sized MethodBssMapping for each dex file, optional.
92 // MethodBssMapping
93 // ...
94 // MethodBssMapping
95 //
96 // VmapTable         one variable sized VmapTable blob (CodeInfo or QuickeningInfo).
97 // VmapTable         VmapTables are deduplicated.
98 // ...
99 // VmapTable
100 //
101 // OatDexFile[0]     one variable sized OatDexFile with offsets to Dex and OatClasses
102 // OatDexFile[1]
103 // ...
104 // OatDexFile[D]
105 //
106 // padding           if necessary so that the following code will be page aligned
107 //
108 // OatMethodHeader   fixed size header for a CompiledMethod including the size of the MethodCode.
109 // MethodCode        one variable sized blob with the code of a CompiledMethod.
110 // OatMethodHeader   (OatMethodHeader, MethodCode) pairs are deduplicated.
111 // MethodCode
112 // ...
113 // OatMethodHeader
114 // MethodCode
115 //
116 class OatWriter {
117  public:
118   OatWriter(const CompilerOptions& compiler_options,
119             const VerificationResults* verification_results,
120             TimingLogger* timings,
121             ProfileCompilationInfo* info,
122             CompactDexLevel compact_dex_level);
123 
124   // To produce a valid oat file, the user must first add sources with any combination of
125   //   - AddDexFileSource(),
126   //   - AddRawDexFileSource(),
127   //   - AddVdexDexFilesSource().
128   // Then the user must call in order
129   //   - WriteAndOpenDexFiles()
130   //   - StartRoData()
131   //   - FinishVdexFile()
132   //   - PrepareLayout(),
133   //   - WriteRodata(),
134   //   - WriteCode(),
135   //   - WriteDataBimgRelRo() iff GetDataBimgRelRoSize() != 0,
136   //   - WriteHeader().
137 
138   // Add dex file source(s) from a file, either a plain dex file or
139   // a zip file with one or more dex files.
140   bool AddDexFileSource(
141       const char* filename,
142       const char* location);
143   // Add dex file source(s) from a file specified by a file handle.
144   // Note: The `dex_file_fd` specifies a plain dex file or a zip file.
145   bool AddDexFileSource(
146       File&& dex_file_fd,
147       const char* location);
148   // Add dex file source from raw memory.
149   bool AddRawDexFileSource(
150       const ArrayRef<const uint8_t>& data,
151       const char* location,
152       uint32_t location_checksum);
153   // Add dex file source(s) from a vdex file.
154   bool AddVdexDexFilesSource(
155       const VdexFile& vdex_file,
156       const char* location);
157   dchecked_vector<std::string> GetSourceLocations() const;
158 
159   // Write raw dex files to the vdex file, mmap the file and open the dex files from it.
160   // The `verify` setting dictates whether the dex file verifier should check the dex files.
161   // This is generally the case, and should only be false for tests.
162   // If `use_existing_vdex` is true, then this method won't actually write the dex files,
163   // and the compiler will just re-use the existing vdex file.
164   bool WriteAndOpenDexFiles(File* vdex_file,
165                             bool verify,
166                             bool use_existing_vdex,
167                             CopyOption copy_dex_files,
168                             /*out*/ std::vector<MemMap>* opened_dex_files_map,
169                             /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files);
170   // Start writing .rodata, including supporting data structures for dex files.
171   bool StartRoData(const std::vector<const DexFile*>& dex_files,
172                    OutputStream* oat_rodata,
173                    SafeMap<std::string, std::string>* key_value_store);
174   // Initialize the writer with the given parameters.
175   void Initialize(const CompilerDriver* compiler_driver,
176                   ImageWriter* image_writer,
177                   const std::vector<const DexFile*>& dex_files);
178   bool FinishVdexFile(File* vdex_file, verifier::VerifierDeps* verifier_deps);
179 
180   // Prepare layout of remaining data.
181   void PrepareLayout(MultiOatRelativePatcher* relative_patcher);
182   // Write the rest of .rodata section (ClassOffsets[], OatClass[], maps).
183   bool WriteRodata(OutputStream* out);
184   // Write the code to the .text section.
185   bool WriteCode(OutputStream* out);
186   // Write the boot image relocation data to the .data.bimg.rel.ro section.
187   bool WriteDataBimgRelRo(OutputStream* out);
188   // Check the size of the written oat file.
189   bool CheckOatSize(OutputStream* out, size_t file_offset, size_t relative_offset);
190   // Write the oat header. This finalizes the oat file.
191   bool WriteHeader(OutputStream* out);
192 
193   // Returns whether the oat file has an associated image.
HasImage()194   bool HasImage() const {
195     // Since the image is being created at the same time as the oat file,
196     // check if there's an image writer.
197     return image_writer_ != nullptr;
198   }
199 
GetOatHeader()200   const OatHeader& GetOatHeader() const {
201     return *oat_header_;
202   }
203 
GetCodeSize()204   size_t GetCodeSize() const {
205     return code_size_;
206   }
207 
GetOatSize()208   size_t GetOatSize() const {
209     return oat_size_;
210   }
211 
GetDataBimgRelRoSize()212   size_t GetDataBimgRelRoSize() const {
213     return data_bimg_rel_ro_size_;
214   }
215 
GetBssSize()216   size_t GetBssSize() const {
217     return bss_size_;
218   }
219 
GetBssMethodsOffset()220   size_t GetBssMethodsOffset() const {
221     return bss_methods_offset_;
222   }
223 
GetBssRootsOffset()224   size_t GetBssRootsOffset() const {
225     return bss_roots_offset_;
226   }
227 
GetVdexSize()228   size_t GetVdexSize() const {
229     return vdex_size_;
230   }
231 
GetOatDataOffset()232   size_t GetOatDataOffset() const {
233     return oat_data_offset_;
234   }
235 
236   ~OatWriter();
237 
238   debug::DebugInfo GetDebugInfo() const;
239 
GetCompilerDriver()240   const CompilerDriver* GetCompilerDriver() const {
241     return compiler_driver_;
242   }
243 
GetCompilerOptions()244   const CompilerOptions& GetCompilerOptions() const {
245     return compiler_options_;
246   }
247 
248  private:
249   struct BssMappingInfo;
250   class ChecksumUpdatingOutputStream;
251   class OatClassHeader;
252   class OatClass;
253   class OatDexFile;
254 
255   // The function VisitDexMethods() below iterates through all the methods in all
256   // the compiled dex files in order of their definitions. The method visitor
257   // classes provide individual bits of processing for each of the passes we need to
258   // first collect the data we want to write to the oat file and then, in later passes,
259   // to actually write it.
260   class DexMethodVisitor;
261   class OatDexMethodVisitor;
262   class InitBssLayoutMethodVisitor;
263   class InitOatClassesMethodVisitor;
264   class LayoutCodeMethodVisitor;
265   class LayoutReserveOffsetCodeMethodVisitor;
266   struct OrderedMethodData;
267   class OrderedMethodVisitor;
268   class InitCodeMethodVisitor;
269   template <bool kDeduplicate> class InitMapMethodVisitor;
270   class InitImageMethodVisitor;
271   class WriteCodeMethodVisitor;
272   class WriteMapMethodVisitor;
273 
274   // Visit all the methods in all the compiled dex files in their definition order
275   // with a given DexMethodVisitor.
276   bool VisitDexMethods(DexMethodVisitor* visitor);
277 
278   // If `update_input_vdex` is true, then this method won't actually write the dex files,
279   // and the compiler will just re-use the existing vdex file.
280   bool WriteDexFiles(File* file,
281                      bool verify,
282                      bool use_existing_vdex,
283                      CopyOption copy_dex_files,
284                      /*out*/ std::vector<MemMap>* opened_dex_files_map);
285   bool LayoutDexFile(OatDexFile* oat_dex_file);
286   bool OpenDexFiles(File* file,
287                     /*inout*/ std::vector<MemMap>* opened_dex_files_map,
288                     /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files);
289   void WriteQuickeningInfo(/*out*/std::vector<uint8_t>* buffer);
290   void WriteTypeLookupTables(/*out*/std::vector<uint8_t>* buffer);
291   void WriteVerifierDeps(verifier::VerifierDeps* verifier_deps,
292                          /*out*/std::vector<uint8_t>* buffer);
293 
294   size_t InitOatHeader(uint32_t num_dex_files, SafeMap<std::string, std::string>* key_value_store);
295   size_t InitClassOffsets(size_t offset);
296   size_t InitOatClasses(size_t offset);
297   size_t InitOatMaps(size_t offset);
298   size_t InitIndexBssMappings(size_t offset);
299   size_t InitOatDexFiles(size_t offset);
300   size_t InitBcpBssInfo(size_t offset);
301   size_t InitOatCode(size_t offset);
302   size_t InitOatCodeDexFiles(size_t offset);
303   size_t InitDataBimgRelRoLayout(size_t offset);
304   void InitBssLayout(InstructionSet instruction_set);
305 
306   size_t WriteClassOffsets(OutputStream* out, size_t file_offset, size_t relative_offset);
307   size_t WriteClasses(OutputStream* out, size_t file_offset, size_t relative_offset);
308   size_t WriteMaps(OutputStream* out, size_t file_offset, size_t relative_offset);
309   size_t WriteIndexBssMappings(OutputStream* out, size_t file_offset, size_t relative_offset);
310   size_t WriteOatDexFiles(OutputStream* out, size_t file_offset, size_t relative_offset);
311   size_t WriteBcpBssInfo(OutputStream* out, size_t file_offset, size_t relative_offset);
312   size_t WriteCode(OutputStream* out, size_t file_offset, size_t relative_offset);
313   size_t WriteCodeDexFiles(OutputStream* out, size_t file_offset, size_t relative_offset);
314   size_t WriteDataBimgRelRo(OutputStream* out, size_t file_offset, size_t relative_offset);
315   // These helpers extract common code from BCP and non-BCP DexFiles from its corresponding methods.
316   size_t WriteIndexBssMappingsHelper(OutputStream* out,
317                                      size_t file_offset,
318                                      size_t relative_offset,
319                                      const DexFile* dex_file,
320                                      uint32_t method_bss_mapping_offset,
321                                      uint32_t type_bss_mapping_offset,
322                                      uint32_t public_type_bss_mapping_offset,
323                                      uint32_t package_type_bss_mapping_offset,
324                                      uint32_t string_bss_mapping_offset);
325   size_t InitIndexBssMappingsHelper(size_t offset,
326                                     const DexFile* dex_file,
327                                     /*inout*/ size_t& number_of_method_dex_files,
328                                     /*inout*/ size_t& number_of_type_dex_files,
329                                     /*inout*/ size_t& number_of_public_type_dex_files,
330                                     /*inout*/ size_t& number_of_package_type_dex_files,
331                                     /*inout*/ size_t& number_of_string_dex_files,
332                                     /*inout*/ uint32_t& method_bss_mapping_offset,
333                                     /*inout*/ uint32_t& type_bss_mapping_offset,
334                                     /*inout*/ uint32_t& public_type_bss_mapping_offset,
335                                     /*inout*/ uint32_t& package_type_bss_mapping_offset,
336                                     /*inout*/ uint32_t& string_bss_mapping_offset);
337 
338   bool RecordOatDataOffset(OutputStream* out);
339   void InitializeTypeLookupTables(
340       const std::vector<std::unique_ptr<const DexFile>>& opened_dex_files);
341   bool WriteDexLayoutSections(OutputStream* oat_rodata,
342                               const std::vector<const DexFile*>& opened_dex_files);
343   bool WriteCodeAlignment(OutputStream* out, uint32_t aligned_code_delta);
344   bool WriteUpTo16BytesAlignment(OutputStream* out, uint32_t size, uint32_t* stat);
345   void SetMultiOatRelativePatcherAdjustment();
346   void CloseSources();
347 
348   bool MayHaveCompiledMethods() const;
349 
VdexWillContainDexFiles()350   bool VdexWillContainDexFiles() const {
351     return dex_files_ != nullptr && extract_dex_files_into_vdex_;
352   }
353 
354   enum class WriteState {
355     kAddingDexFileSources,
356     kStartRoData,
357     kInitialize,
358     kPrepareLayout,
359     kWriteRoData,
360     kWriteText,
361     kWriteDataBimgRelRo,
362     kWriteHeader,
363     kDone
364   };
365 
366   WriteState write_state_;
367   TimingLogger* timings_;
368 
369   dchecked_vector<debug::MethodDebugInfo> method_info_;
370 
371   std::vector<uint8_t> code_info_data_;
372 
373   const CompilerDriver* compiler_driver_;
374   const CompilerOptions& compiler_options_;
375   const VerificationResults* const verification_results_;
376   ImageWriter* image_writer_;
377   // Whether the dex files being compiled are going to be extracted to the vdex.
378   bool extract_dex_files_into_vdex_;
379   // The start of the vdex file section mmapped for writing dex files.
380   uint8_t* vdex_begin_;
381 
382   // note OatFile does not take ownership of the DexFiles
383   const std::vector<const DexFile*>* dex_files_;
384 
385   // Whether this is the primary oat file.
386   bool primary_oat_file_;
387 
388   // Size required for Vdex data structures.
389   size_t vdex_size_;
390 
391   // Offset of section holding Dex files inside Vdex.
392   size_t vdex_dex_files_offset_;
393 
394   // Offset of section holding shared dex data section in the Vdex.
395   size_t vdex_dex_shared_data_offset_;
396 
397   // Offset of section holding VerifierDeps inside Vdex.
398   size_t vdex_verifier_deps_offset_;
399 
400   // Offset of section holding quickening info inside Vdex.
401   size_t vdex_quickening_info_offset_;
402 
403   // Offset of type lookup tables inside Vdex.
404   size_t vdex_lookup_tables_offset_;
405 
406   // OAT checksum.
407   uint32_t oat_checksum_;
408 
409   // Size of the .text segment.
410   size_t code_size_;
411 
412   // Size required for Oat data structures.
413   size_t oat_size_;
414 
415   // The start of the required .data.bimg.rel.ro section.
416   size_t data_bimg_rel_ro_start_;
417 
418   // The size of the required .data.bimg.rel.ro section holding the boot image relocations.
419   size_t data_bimg_rel_ro_size_;
420 
421   // The start of the required .bss section.
422   size_t bss_start_;
423 
424   // The size of the required .bss section holding the DexCache data and GC roots.
425   size_t bss_size_;
426 
427   // The offset of the methods in .bss section.
428   size_t bss_methods_offset_;
429 
430   // The offset of the GC roots in .bss section.
431   size_t bss_roots_offset_;
432 
433   // OatFile's information regarding the bss metadata for BCP DexFiles. Empty for multi-image.
434   std::vector<BssMappingInfo> bcp_bss_info_;
435 
436   // Map for allocating .data.bimg.rel.ro entries. Indexed by the boot image offset of the
437   // relocation. The value is the assigned offset within the .data.bimg.rel.ro section.
438   SafeMap<uint32_t, size_t> data_bimg_rel_ro_entries_;
439 
440   // Map for recording references to ArtMethod entries in .bss.
441   SafeMap<const DexFile*, BitVector> bss_method_entry_references_;
442 
443   // Map for recording references to GcRoot<mirror::Class> entries in .bss.
444   SafeMap<const DexFile*, BitVector> bss_type_entry_references_;
445 
446   // Map for recording references to public GcRoot<mirror::Class> entries in .bss.
447   SafeMap<const DexFile*, BitVector> bss_public_type_entry_references_;
448 
449   // Map for recording references to package GcRoot<mirror::Class> entries in .bss.
450   SafeMap<const DexFile*, BitVector> bss_package_type_entry_references_;
451 
452   // Map for recording references to GcRoot<mirror::String> entries in .bss.
453   SafeMap<const DexFile*, BitVector> bss_string_entry_references_;
454 
455   // Map for allocating ArtMethod entries in .bss. Indexed by MethodReference for the target
456   // method in the dex file with the "method reference value comparator" for deduplication.
457   // The value is the target offset for patching, starting at `bss_start_ + bss_methods_offset_`.
458   SafeMap<MethodReference, size_t, MethodReferenceValueComparator> bss_method_entries_;
459 
460   // Map for allocating Class entries in .bss. Indexed by TypeReference for the source
461   // type in the dex file with the "type value comparator" for deduplication. The value
462   // is the target offset for patching, starting at `bss_start_ + bss_roots_offset_`.
463   SafeMap<TypeReference, size_t, TypeReferenceValueComparator> bss_type_entries_;
464 
465   // Map for allocating public Class entries in .bss. Indexed by TypeReference for the source
466   // type in the dex file with the "type value comparator" for deduplication. The value
467   // is the target offset for patching, starting at `bss_start_ + bss_roots_offset_`.
468   SafeMap<TypeReference, size_t, TypeReferenceValueComparator> bss_public_type_entries_;
469 
470   // Map for allocating package Class entries in .bss. Indexed by TypeReference for the source
471   // type in the dex file with the "type value comparator" for deduplication. The value
472   // is the target offset for patching, starting at `bss_start_ + bss_roots_offset_`.
473   SafeMap<TypeReference, size_t, TypeReferenceValueComparator> bss_package_type_entries_;
474 
475   // Map for allocating String entries in .bss. Indexed by StringReference for the source
476   // string in the dex file with the "string value comparator" for deduplication. The value
477   // is the target offset for patching, starting at `bss_start_ + bss_roots_offset_`.
478   SafeMap<StringReference, size_t, StringReferenceValueComparator> bss_string_entries_;
479 
480   // Offset of the oat data from the start of the mmapped region of the elf file.
481   size_t oat_data_offset_;
482 
483   // Fake OatDexFiles to hold type lookup tables for the compiler.
484   std::vector<std::unique_ptr<art::OatDexFile>> type_lookup_table_oat_dex_files_;
485 
486   // data to write
487   std::unique_ptr<OatHeader> oat_header_;
488   dchecked_vector<OatDexFile> oat_dex_files_;
489   dchecked_vector<OatClassHeader> oat_class_headers_;
490   dchecked_vector<OatClass> oat_classes_;
491   std::unique_ptr<const std::vector<uint8_t>> jni_dlsym_lookup_trampoline_;
492   std::unique_ptr<const std::vector<uint8_t>> jni_dlsym_lookup_critical_trampoline_;
493   std::unique_ptr<const std::vector<uint8_t>> quick_generic_jni_trampoline_;
494   std::unique_ptr<const std::vector<uint8_t>> quick_imt_conflict_trampoline_;
495   std::unique_ptr<const std::vector<uint8_t>> quick_resolution_trampoline_;
496   std::unique_ptr<const std::vector<uint8_t>> quick_to_interpreter_bridge_;
497   std::unique_ptr<const std::vector<uint8_t>> nterp_trampoline_;
498 
499   // output stats
500   uint32_t size_vdex_header_;
501   uint32_t size_vdex_checksums_;
502   uint32_t size_dex_file_alignment_;
503   uint32_t size_quickening_table_offset_;
504   uint32_t size_executable_offset_alignment_;
505   uint32_t size_oat_header_;
506   uint32_t size_oat_header_key_value_store_;
507   uint32_t size_dex_file_;
508   uint32_t size_verifier_deps_;
509   uint32_t size_verifier_deps_alignment_;
510   uint32_t size_quickening_info_;
511   uint32_t size_quickening_info_alignment_;
512   uint32_t size_vdex_lookup_table_alignment_;
513   uint32_t size_vdex_lookup_table_;
514   uint32_t size_interpreter_to_interpreter_bridge_;
515   uint32_t size_interpreter_to_compiled_code_bridge_;
516   uint32_t size_jni_dlsym_lookup_trampoline_;
517   uint32_t size_jni_dlsym_lookup_critical_trampoline_;
518   uint32_t size_quick_generic_jni_trampoline_;
519   uint32_t size_quick_imt_conflict_trampoline_;
520   uint32_t size_quick_resolution_trampoline_;
521   uint32_t size_quick_to_interpreter_bridge_;
522   uint32_t size_nterp_trampoline_;
523   uint32_t size_trampoline_alignment_;
524   uint32_t size_method_header_;
525   uint32_t size_code_;
526   uint32_t size_code_alignment_;
527   uint32_t size_data_bimg_rel_ro_;
528   uint32_t size_data_bimg_rel_ro_alignment_;
529   uint32_t size_relative_call_thunks_;
530   uint32_t size_misc_thunks_;
531   uint32_t size_vmap_table_;
532   uint32_t size_method_info_;
533   uint32_t size_oat_dex_file_location_size_;
534   uint32_t size_oat_dex_file_location_data_;
535   uint32_t size_oat_dex_file_location_checksum_;
536   uint32_t size_oat_dex_file_offset_;
537   uint32_t size_oat_dex_file_class_offsets_offset_;
538   uint32_t size_oat_dex_file_lookup_table_offset_;
539   uint32_t size_oat_dex_file_dex_layout_sections_offset_;
540   uint32_t size_oat_dex_file_dex_layout_sections_;
541   uint32_t size_oat_dex_file_dex_layout_sections_alignment_;
542   uint32_t size_oat_dex_file_method_bss_mapping_offset_;
543   uint32_t size_oat_dex_file_type_bss_mapping_offset_;
544   uint32_t size_oat_dex_file_public_type_bss_mapping_offset_;
545   uint32_t size_oat_dex_file_package_type_bss_mapping_offset_;
546   uint32_t size_oat_dex_file_string_bss_mapping_offset_;
547   uint32_t size_bcp_bss_info_size_;
548   uint32_t size_bcp_bss_info_method_bss_mapping_offset_;
549   uint32_t size_bcp_bss_info_type_bss_mapping_offset_;
550   uint32_t size_bcp_bss_info_public_type_bss_mapping_offset_;
551   uint32_t size_bcp_bss_info_package_type_bss_mapping_offset_;
552   uint32_t size_bcp_bss_info_string_bss_mapping_offset_;
553   uint32_t size_oat_class_offsets_alignment_;
554   uint32_t size_oat_class_offsets_;
555   uint32_t size_oat_class_type_;
556   uint32_t size_oat_class_status_;
557   uint32_t size_oat_class_num_methods_;
558   uint32_t size_oat_class_method_bitmaps_;
559   uint32_t size_oat_class_method_offsets_;
560   uint32_t size_method_bss_mappings_;
561   uint32_t size_type_bss_mappings_;
562   uint32_t size_public_type_bss_mappings_;
563   uint32_t size_package_type_bss_mappings_;
564   uint32_t size_string_bss_mappings_;
565 
566   // The helper for processing relative patches is external so that we can patch across oat files.
567   MultiOatRelativePatcher* relative_patcher_;
568 
569   // Profile info used to generate new layout of files.
570   ProfileCompilationInfo* profile_compilation_info_;
571 
572   // Compact dex level that is generated.
573   CompactDexLevel compact_dex_level_;
574 
575   using OrderedMethodList = std::vector<OrderedMethodData>;
576 
577   // List of compiled methods, sorted by the order defined in OrderedMethodData.
578   // Methods can be inserted more than once in case of duplicated methods.
579   // This pointer is only non-null after InitOatCodeDexFiles succeeds.
580   std::unique_ptr<OrderedMethodList> ordered_methods_;
581 
582   // Container of shared dex data.
583   std::unique_ptr<DexContainer> dex_container_;
584 
585   DISALLOW_COPY_AND_ASSIGN(OatWriter);
586 };
587 
588 }  // namespace linker
589 }  // namespace art
590 
591 #endif  // ART_DEX2OAT_LINKER_OAT_WRITER_H_
592