blob: 1abf06b1c5c51296358ed759116500cc7c56dd78 [file] [log] [blame]
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -07001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_ELF_FIXUP_H_
18#define ART_COMPILER_ELF_FIXUP_H_
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070019
20#include <stdint.h>
21
22#include "base/macros.h"
23#include "os.h"
24
25namespace art {
26
27class ElfFile;
28
29class ElfFixup {
30 public:
31 // Fixup an ELF file so that that oat header will be loaded at oat_begin.
32 // Returns true on success, false on failure.
33 static bool Fixup(File* file, uintptr_t oat_data_begin);
34
35 private:
36 // Fixup .dynamic d_ptr values for the expected base_address.
37 static bool FixupDynamic(ElfFile& elf_file, uintptr_t base_address);
38
39 // Fixup Elf32_Shdr p_vaddr to load at the desired address.
40 static bool FixupSectionHeaders(ElfFile& elf_file, uintptr_t base_address);
41
42 // Fixup Elf32_Phdr p_vaddr to load at the desired address.
43 static bool FixupProgramHeaders(ElfFile& elf_file, uintptr_t base_address);
44
45 // Fixup symbol table
46 static bool FixupSymbols(ElfFile& elf_file, uintptr_t base_address, bool dynamic);
47
48 // Fixup dynamic relocations
49 static bool FixupRelocations(ElfFile& elf_file, uintptr_t base_address);
50
51 DISALLOW_IMPLICIT_CONSTRUCTORS(ElfFixup);
52};
53
54} // namespace art
55
Brian Carlstromfc0e3212013-07-17 14:40:12 -070056#endif // ART_COMPILER_ELF_FIXUP_H_