Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.h

Issue 340523003: Support for unpacked ARM packed relocations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fork_switch
Patch Set: Another review update Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 #endif
52
46 // This function is used to adjust relocated addresses in a copy of an 53 // 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| 54 // 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 55 // 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 56 // content into |dst_addr|...|dst_addr + size|, then adjust all relocated
50 // addresses inside the destination section as if it was loaded/mapped 57 // addresses inside the destination section as if it was loaded/mapped
51 // at |map_addr|...|map_addr + size|. Only relative relocations are processed, 58 // at |map_addr|...|map_addr + size|. Only relative relocations are processed,
52 // symbolic ones are ignored. 59 // symbolic ones are ignored.
53 void CopyAndRelocate(size_t src_addr, 60 void CopyAndRelocate(size_t src_addr,
54 size_t dst_addr, 61 size_t dst_addr,
55 size_t map_addr, 62 size_t map_addr,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 size_t map_delta); 94 size_t map_delta);
88 void RelocateRela(size_t src_addr, 95 void RelocateRela(size_t src_addr,
89 size_t dst_addr, 96 size_t dst_addr,
90 size_t map_addr, 97 size_t map_addr,
91 size_t size); 98 size_t size);
92 void RelocateRel(size_t src_addr, 99 void RelocateRel(size_t src_addr,
93 size_t dst_addr, 100 size_t dst_addr,
94 size_t map_addr, 101 size_t map_addr,
95 size_t size); 102 size_t size);
96 103
104 #ifdef __arm__
105 // Apply ARM packed relocations.
106 // On error, return false and set |error| message. No-op if no packed
107 // relocations were registered.
108 bool ApplyArmPackedRelocs(Error* error);
109 #endif
110
97 #if defined(__mips__) 111 #if defined(__mips__)
98 bool RelocateMipsGot(const ElfSymbols* symbols, 112 bool RelocateMipsGot(const ElfSymbols* symbols,
99 SymbolResolver* resolver, 113 SymbolResolver* resolver,
100 Error* error); 114 Error* error);
101 #endif 115 #endif
102 116
103 const ELF::Phdr* phdr_; 117 const ELF::Phdr* phdr_;
104 size_t phdr_count_; 118 size_t phdr_count_;
105 size_t load_bias_; 119 size_t load_bias_;
106 120
107 ELF::Addr relocations_type_; 121 ELF::Addr relocations_type_;
108 ELF::Addr plt_relocations_; 122 ELF::Addr plt_relocations_;
109 size_t plt_relocations_size_; 123 size_t plt_relocations_size_;
110 ELF::Addr* plt_got_; 124 ELF::Addr* plt_got_;
111 125
112 ELF::Addr relocations_; 126 ELF::Addr relocations_;
113 size_t relocations_size_; 127 size_t relocations_size_;
114 128
115 #if defined(__mips__) 129 #if defined(__mips__)
116 // MIPS-specific relocation fields. 130 // MIPS-specific relocation fields.
117 ELF::Word mips_symtab_count_; 131 ELF::Word mips_symtab_count_;
118 ELF::Word mips_local_got_count_; 132 ELF::Word mips_local_got_count_;
119 ELF::Word mips_gotsym_; 133 ELF::Word mips_gotsym_;
120 #endif 134 #endif
121 135
136 #if defined(__arm__)
137 uint8_t* arm_packed_relocs_;
138 #endif
139
122 bool has_text_relocations_; 140 bool has_text_relocations_;
123 bool has_symbolic_; 141 bool has_symbolic_;
124 }; 142 };
125 143
126 } // namespace crazy 144 } // namespace crazy
127 145
128 #endif // CRAZY_LINKER_ELF_RELOCATIONS_H 146 #endif // CRAZY_LINKER_ELF_RELOCATIONS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698