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