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 // Register ARM packed relocations to apply. | |
49 // |arm_packed_relocs| is a pointer to packed relocations data. | |
50 void RegisterArmPackedRelocs(uint8_t* arm_packed_relocs); | |
51 | |
52 // Apply ARM packed relocations. | |
53 // On error, return false and set |error| message. No-op if no packed | |
54 // relocations were registered. | |
55 bool ApplyArmPackedRelocs(Error* error); | |
rmcilroy
2014/06/24 09:47:22
nit - make this private
simonb (inactive)
2014/06/24 11:43:55
Done.
| |
56 #endif | |
57 | |
46 // This function is used to adjust relocated addresses in a copy of an | 58 // 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| | 59 // 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 | 60 // 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 | 61 // content into |dst_addr|...|dst_addr + size|, then adjust all relocated |
50 // addresses inside the destination section as if it was loaded/mapped | 62 // addresses inside the destination section as if it was loaded/mapped |
51 // at |map_addr|...|map_addr + size|. Only relative relocations are processed, | 63 // at |map_addr|...|map_addr + size|. Only relative relocations are processed, |
52 // symbolic ones are ignored. | 64 // symbolic ones are ignored. |
53 void CopyAndRelocate(size_t src_addr, | 65 void CopyAndRelocate(size_t src_addr, |
54 size_t dst_addr, | 66 size_t dst_addr, |
55 size_t map_addr, | 67 size_t map_addr, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 ELF::Addr relocations_; | 124 ELF::Addr relocations_; |
113 size_t relocations_size_; | 125 size_t relocations_size_; |
114 | 126 |
115 #if defined(__mips__) | 127 #if defined(__mips__) |
116 // MIPS-specific relocation fields. | 128 // MIPS-specific relocation fields. |
117 ELF::Word mips_symtab_count_; | 129 ELF::Word mips_symtab_count_; |
118 ELF::Word mips_local_got_count_; | 130 ELF::Word mips_local_got_count_; |
119 ELF::Word mips_gotsym_; | 131 ELF::Word mips_gotsym_; |
120 #endif | 132 #endif |
121 | 133 |
134 #if defined(__arm__) | |
135 uint8_t* arm_packed_relocs_; | |
136 #endif | |
137 | |
122 bool has_text_relocations_; | 138 bool has_text_relocations_; |
123 bool has_symbolic_; | 139 bool has_symbolic_; |
124 }; | 140 }; |
125 | 141 |
126 } // namespace crazy | 142 } // namespace crazy |
127 | 143 |
128 #endif // CRAZY_LINKER_ELF_RELOCATIONS_H | 144 #endif // CRAZY_LINKER_ELF_RELOCATIONS_H |
OLD | NEW |