OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CRAZY_LINKER_ELF_RELOCATIONS_H | 5 #ifndef CRAZY_LINKER_ELF_RELOCATIONS_H |
6 #define CRAZY_LINKER_ELF_RELOCATIONS_H | 6 #define CRAZY_LINKER_ELF_RELOCATIONS_H |
7 | 7 |
8 #include <string.h> | 8 #include <string.h> |
| 9 #include <unistd.h> |
9 | 10 |
10 #include "elf_traits.h" | 11 #include "elf_traits.h" |
11 | 12 |
12 namespace crazy { | 13 namespace crazy { |
13 | 14 |
14 class ElfSymbols; | 15 class ElfSymbols; |
15 class ElfView; | 16 class ElfView; |
16 class Error; | 17 class Error; |
17 | 18 |
18 // An ElfRelocations instance holds information about relocations in a mapped | 19 // An ElfRelocations instance holds information about relocations in a mapped |
(...skipping 17 matching lines...) Expand all Loading... |
36 | 37 |
37 // Apply all relocations to the target mapped ELF binary. Must be called | 38 // Apply all relocations to the target mapped ELF binary. Must be called |
38 // after Init(). | 39 // after Init(). |
39 // |symbols| maps to the symbol entries for the target library only. | 40 // |symbols| maps to the symbol entries for the target library only. |
40 // |resolver| can resolve symbols out of the current library. | 41 // |resolver| can resolve symbols out of the current library. |
41 // On error, return false and set |error| message. | 42 // On error, return false and set |error| message. |
42 bool ApplyAll(const ElfSymbols* symbols, | 43 bool ApplyAll(const ElfSymbols* symbols, |
43 SymbolResolver* resolver, | 44 SymbolResolver* resolver, |
44 Error* error); | 45 Error* error); |
45 | 46 |
| 47 #ifdef __arm__ |
| 48 // Apply ARM packed relocations. These are in addition to any applied |
| 49 // by ApplyAll(). |
| 50 // |arm_packed_relocs| is a pointer to packed relocations data. |
| 51 // On error, return false and set |error| message. |
| 52 bool ApplyArmPackedRelocs(const uint8_t* arm_packed_relocs, |
| 53 Error* error); |
| 54 #endif |
| 55 |
46 // This function is used to adjust relocated addresses in a copy of an | 56 // This function is used to adjust relocated addresses in a copy of an |
47 // existing section of an ELF binary. I.e. |src_addr|...|src_addr + size| | 57 // existing section of an ELF binary. I.e. |src_addr|...|src_addr + size| |
48 // must be inside the mapped ELF binary, this function will first copy its | 58 // must be inside the mapped ELF binary, this function will first copy its |
49 // content into |dst_addr|...|dst_addr + size|, then adjust all relocated | 59 // content into |dst_addr|...|dst_addr + size|, then adjust all relocated |
50 // addresses inside the destination section as if it was loaded/mapped | 60 // addresses inside the destination section as if it was loaded/mapped |
51 // at |map_addr|...|map_addr + size|. Only relative relocations are processed, | 61 // at |map_addr|...|map_addr + size|. Only relative relocations are processed, |
52 // symbolic ones are ignored. | 62 // symbolic ones are ignored. |
53 void CopyAndRelocate(size_t src_addr, | 63 void CopyAndRelocate(size_t src_addr, |
54 size_t dst_addr, | 64 size_t dst_addr, |
55 size_t map_addr, | 65 size_t map_addr, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 ELF::Word mips_gotsym_; | 129 ELF::Word mips_gotsym_; |
120 #endif | 130 #endif |
121 | 131 |
122 bool has_text_relocations_; | 132 bool has_text_relocations_; |
123 bool has_symbolic_; | 133 bool has_symbolic_; |
124 }; | 134 }; |
125 | 135 |
126 } // namespace crazy | 136 } // namespace crazy |
127 | 137 |
128 #endif // CRAZY_LINKER_ELF_RELOCATIONS_H | 138 #endif // CRAZY_LINKER_ELF_RELOCATIONS_H |
OLD | NEW |