1 /* 2 * Copyright (C) 2012 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_COMPILER_ELF_WRITER_H_ 18 #define ART_COMPILER_ELF_WRITER_H_ 19 20 #include <stdint.h> 21 #include <cstddef> 22 #include <string> 23 #include <vector> 24 25 #include "base/macros.h" 26 #include "base/mutex.h" 27 #include "os.h" 28 29 namespace art { 30 31 class CompilerDriver; 32 class DexFile; 33 class ElfFile; 34 class OatWriter; 35 36 class ElfWriter { 37 public: 38 // Looks up information about location of oat file in elf file container. 39 // Used for ImageWriter to perform memory layout. 40 static void GetOatElfInformation(File* file, 41 size_t& oat_loaded_size, 42 size_t& oat_data_offset); 43 44 // Returns runtime oat_data runtime address for an opened ElfFile. 45 static uint32_t GetOatDataAddress(ElfFile* elf_file); 46 47 protected: ElfWriter(const CompilerDriver & driver,File * elf_file)48 ElfWriter(const CompilerDriver& driver, File* elf_file) 49 : compiler_driver_(&driver), elf_file_(elf_file) { 50 } 51 ~ElfWriter()52 virtual ~ElfWriter() {} 53 54 virtual bool Write(OatWriter* oat_writer, 55 const std::vector<const DexFile*>& dex_files, 56 const std::string& android_root, 57 bool is_host) 58 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; 59 60 const CompilerDriver* const compiler_driver_; 61 File* const elf_file_; 62 }; 63 64 } // namespace art 65 66 #endif // ART_COMPILER_ELF_WRITER_H_ 67