blob: 9e8611ca59baeca3b99a136cd327c346302cea0e [file] [log] [blame]
Logan Chienf7015fd2012-03-18 01:19:37 +08001/*
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 Chien0f0899a2012-03-23 10:48:18 +080020#include "elf_image.h"
Logan Chienf7015fd2012-03-18 01:19:37 +080021#include "globals.h"
Logan Chien0c717dd2012-03-28 18:31:07 +080022#include "oat_file.h"
Logan Chienf7015fd2012-03-18 01:19:37 +080023#include "object.h"
24
25#include <android/librsloader.h>
26#include <vector>
27
28namespace art {
Logan Chienf7015fd2012-03-18 01:19:37 +080029namespace compiler_llvm {
30
31class ElfLoader {
32 public:
TDYa1279d93ee62012-05-09 09:56:07 -070033 ElfLoader() : relocated(false) {}
Logan Chienf7015fd2012-03-18 01:19:37 +080034 ~ElfLoader();
35
Logan Chien0c717dd2012-03-28 18:31:07 +080036 bool LoadElfAt(size_t elf_idx, const ElfImage& elf_image,
37 OatFile::RelocationBehavior reloc);
38
39 void RelocateExecutable();
Logan Chienf7015fd2012-03-18 01:19:37 +080040
Logan Chien937105a2012-04-02 02:37:37 +080041 const void* GetMethodCodeAddr(uint16_t elf_idx,
42 uint16_t elf_func_idx) const;
Logan Chienf7015fd2012-03-18 01:19:37 +080043
Logan Chien937105a2012-04-02 02:37:37 +080044 const Method::InvokeStub* GetMethodInvokeStubAddr(uint16_t elf_idx,
45 uint16_t elf_func_idx) const;
Logan Chienf7015fd2012-03-18 01:19:37 +080046
Logan Chien14924fe2012-04-03 18:33:37 +080047 size_t GetCodeSize(uint16_t elf_idx, uint16_t elf_func_idx) const;
48
Logan Chienf7015fd2012-03-18 01:19:37 +080049 private:
50 const void* GetAddr(size_t elf_idx, const char* sym_name) const;
51
TDYa1279d93ee62012-05-09 09:56:07 -070052 bool relocated;
53 std::vector<ElfImage> elf_images_;
Logan Chienf7015fd2012-03-18 01:19:37 +080054 std::vector<RSExecRef> executables_;
55};
56
57
58} // namespace compiler_llvm
59} // namespace art
60
61#endif // ART_SRC_COMPILER_LLVM_ELF_LOADER_H_