Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_ELF_WRITER_H_ |
| 18 | #define ART_COMPILER_ELF_WRITER_H_ |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 19 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 20 | #include <stdint.h> |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 21 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 22 | #include <cstddef> |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 23 | #include <string> |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 24 | #include <vector> |
| 25 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 26 | #include <llvm/Support/ELF.h> |
| 27 | |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 28 | #include "base/macros.h" |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 29 | #include "os.h" |
| 30 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 31 | namespace art { |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 32 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 33 | class CompilerDriver; |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 34 | class DexFile; |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 35 | class ElfFile; |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 36 | |
| 37 | class ElfWriter { |
| 38 | public: |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 39 | // Looks up information about location of oat file in elf file container. |
| 40 | // Used for ImageWriter to perform memory layout. |
| 41 | static void GetOatElfInformation(File* file, |
| 42 | size_t& oat_loaded_size, |
| 43 | size_t& oat_data_offset); |
| 44 | |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 45 | // Returns runtime oat_data runtime address for an opened ElfFile. |
| 46 | static llvm::ELF::Elf32_Addr GetOatDataAddress(ElfFile* elf_file); |
| 47 | |
| 48 | protected: |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 49 | ElfWriter(const CompilerDriver& driver, File* elf_file); |
Brian Carlstrom | fb6996f | 2013-07-18 18:21:14 -0700 | [diff] [blame^] | 50 | virtual ~ElfWriter(); |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 51 | |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 52 | virtual bool Write(std::vector<uint8_t>& oat_contents, |
| 53 | const std::vector<const DexFile*>& dex_files, |
| 54 | const std::string& android_root, |
| 55 | bool is_host) |
| 56 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 57 | |
| 58 | // Setup by constructor |
| 59 | const CompilerDriver* compiler_driver_; |
| 60 | File* elf_file_; |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | } // namespace art |
| 64 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 65 | #endif // ART_COMPILER_ELF_WRITER_H_ |