blob: 263a9fab973822ba2c395790633af8bbe337eefd [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:
33 ~ElfLoader();
34
Logan Chien0c717dd2012-03-28 18:31:07 +080035 bool LoadElfAt(size_t elf_idx, const ElfImage& elf_image,
36 OatFile::RelocationBehavior reloc);
37
38 void RelocateExecutable();
Logan Chienf7015fd2012-03-18 01:19:37 +080039
Logan Chien937105a2012-04-02 02:37:37 +080040 const void* GetMethodCodeAddr(uint16_t elf_idx,
41 uint16_t elf_func_idx) const;
Logan Chienf7015fd2012-03-18 01:19:37 +080042
Logan Chien937105a2012-04-02 02:37:37 +080043 const Method::InvokeStub* GetMethodInvokeStubAddr(uint16_t elf_idx,
44 uint16_t elf_func_idx) const;
Logan Chienf7015fd2012-03-18 01:19:37 +080045
Logan Chien14924fe2012-04-03 18:33:37 +080046 size_t GetCodeSize(uint16_t elf_idx, uint16_t elf_func_idx) const;
47
Logan Chienf7015fd2012-03-18 01:19:37 +080048 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_