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