Logan Chien | f7015fd | 2012-03-18 01:19:37 +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 | |
| 17 | #ifndef ART_SRC_COMPILER_LLVM_ELF_LOADER_H_ |
| 18 | #define ART_SRC_COMPILER_LLVM_ELF_LOADER_H_ |
| 19 | |
Logan Chien | 0f0899a | 2012-03-23 10:48:18 +0800 | [diff] [blame] | 20 | #include "elf_image.h" |
Logan Chien | f7015fd | 2012-03-18 01:19:37 +0800 | [diff] [blame] | 21 | #include "globals.h" |
Logan Chien | 0c717dd | 2012-03-28 18:31:07 +0800 | [diff] [blame] | 22 | #include "oat_file.h" |
Logan Chien | f7015fd | 2012-03-18 01:19:37 +0800 | [diff] [blame] | 23 | #include "object.h" |
| 24 | |
| 25 | #include <android/librsloader.h> |
| 26 | #include <vector> |
| 27 | |
| 28 | namespace art { |
Logan Chien | f7015fd | 2012-03-18 01:19:37 +0800 | [diff] [blame] | 29 | namespace compiler_llvm { |
| 30 | |
| 31 | class ElfLoader { |
| 32 | public: |
| 33 | ~ElfLoader(); |
| 34 | |
Logan Chien | 0c717dd | 2012-03-28 18:31:07 +0800 | [diff] [blame] | 35 | bool LoadElfAt(size_t elf_idx, const ElfImage& elf_image, |
| 36 | OatFile::RelocationBehavior reloc); |
| 37 | |
| 38 | void RelocateExecutable(); |
Logan Chien | f7015fd | 2012-03-18 01:19:37 +0800 | [diff] [blame] | 39 | |
Logan Chien | 937105a | 2012-04-02 02:37:37 +0800 | [diff] [blame] | 40 | const void* GetMethodCodeAddr(uint16_t elf_idx, |
| 41 | uint16_t elf_func_idx) const; |
Logan Chien | f7015fd | 2012-03-18 01:19:37 +0800 | [diff] [blame] | 42 | |
Logan Chien | 937105a | 2012-04-02 02:37:37 +0800 | [diff] [blame] | 43 | const Method::InvokeStub* GetMethodInvokeStubAddr(uint16_t elf_idx, |
| 44 | uint16_t elf_func_idx) const; |
Logan Chien | f7015fd | 2012-03-18 01:19:37 +0800 | [diff] [blame] | 45 | |
Logan Chien | 14924fe | 2012-04-03 18:33:37 +0800 | [diff] [blame] | 46 | size_t GetCodeSize(uint16_t elf_idx, uint16_t elf_func_idx) const; |
| 47 | |
Logan Chien | f7015fd | 2012-03-18 01:19:37 +0800 | [diff] [blame] | 48 | private: |
| 49 | const void* GetAddr(size_t elf_idx, const char* sym_name) const; |
| 50 | |
| 51 | std::vector<RSExecRef> executables_; |
| 52 | }; |
| 53 | |
| 54 | |
| 55 | } // namespace compiler_llvm |
| 56 | } // namespace art |
| 57 | |
| 58 | #endif // ART_SRC_COMPILER_LLVM_ELF_LOADER_H_ |