1 /*
2 * Copyright (C) 2015 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 #include "linker/arm64/relative_patcher_arm64.h"
18
19 #include "arch/arm64/asm_support_arm64.h"
20 #include "arch/arm64/instruction_set_features_arm64.h"
21 #include "art_method.h"
22 #include "base/bit_utils.h"
23 #include "base/malloc_arena_pool.h"
24 #include "compiled_method-inl.h"
25 #include "driver/compiler_driver.h"
26 #include "entrypoints/quick/quick_entrypoints_enum.h"
27 #include "heap_poisoning.h"
28 #include "linker/linker_patch.h"
29 #include "lock_word.h"
30 #include "mirror/array-inl.h"
31 #include "mirror/object.h"
32 #include "oat.h"
33 #include "oat_quick_method_header.h"
34 #include "read_barrier.h"
35 #include "stream/output_stream.h"
36 #include "utils/arm64/assembler_arm64.h"
37
38 namespace art {
39 namespace linker {
40
41 namespace {
42
43 // Maximum positive and negative displacement for method call measured from the patch location.
44 // (Signed 28 bit displacement with the last two bits 0 has range [-2^27, 2^27-4] measured from
45 // the ARM64 PC pointing to the BL.)
46 constexpr uint32_t kMaxMethodCallPositiveDisplacement = (1u << 27) - 4u;
47 constexpr uint32_t kMaxMethodCallNegativeDisplacement = (1u << 27);
48
49 // Maximum positive and negative displacement for a conditional branch measured from the patch
50 // location. (Signed 21 bit displacement with the last two bits 0 has range [-2^20, 2^20-4]
51 // measured from the ARM64 PC pointing to the B.cond.)
52 constexpr uint32_t kMaxBcondPositiveDisplacement = (1u << 20) - 4u;
53 constexpr uint32_t kMaxBcondNegativeDisplacement = (1u << 20);
54
55 // The ADRP thunk for erratum 843419 is 2 instructions, i.e. 8 bytes.
56 constexpr uint32_t kAdrpThunkSize = 8u;
57
IsAdrpPatch(const LinkerPatch & patch)58 inline bool IsAdrpPatch(const LinkerPatch& patch) {
59 switch (patch.GetType()) {
60 case LinkerPatch::Type::kCallRelative:
61 case LinkerPatch::Type::kCallEntrypoint:
62 case LinkerPatch::Type::kBakerReadBarrierBranch:
63 return false;
64 case LinkerPatch::Type::kIntrinsicReference:
65 case LinkerPatch::Type::kDataBimgRelRo:
66 case LinkerPatch::Type::kMethodRelative:
67 case LinkerPatch::Type::kMethodBssEntry:
68 case LinkerPatch::Type::kTypeRelative:
69 case LinkerPatch::Type::kTypeBssEntry:
70 case LinkerPatch::Type::kStringRelative:
71 case LinkerPatch::Type::kStringBssEntry:
72 return patch.LiteralOffset() == patch.PcInsnOffset();
73 }
74 }
75
MaxExtraSpace(size_t num_adrp,size_t code_size)76 inline uint32_t MaxExtraSpace(size_t num_adrp, size_t code_size) {
77 if (num_adrp == 0u) {
78 return 0u;
79 }
80 uint32_t alignment_bytes =
81 CompiledMethod::AlignCode(code_size, InstructionSet::kArm64) - code_size;
82 return kAdrpThunkSize * num_adrp + alignment_bytes;
83 }
84
85 } // anonymous namespace
86
Arm64RelativePatcher(RelativePatcherThunkProvider * thunk_provider,RelativePatcherTargetProvider * target_provider,const Arm64InstructionSetFeatures * features)87 Arm64RelativePatcher::Arm64RelativePatcher(RelativePatcherThunkProvider* thunk_provider,
88 RelativePatcherTargetProvider* target_provider,
89 const Arm64InstructionSetFeatures* features)
90 : ArmBaseRelativePatcher(thunk_provider, target_provider, InstructionSet::kArm64),
91 fix_cortex_a53_843419_(features->NeedFixCortexA53_843419()),
92 reserved_adrp_thunks_(0u),
93 processed_adrp_thunks_(0u) {
94 if (fix_cortex_a53_843419_) {
95 adrp_thunk_locations_.reserve(16u);
96 current_method_thunks_.reserve(16u * kAdrpThunkSize);
97 }
98 }
99
ReserveSpace(uint32_t offset,const CompiledMethod * compiled_method,MethodReference method_ref)100 uint32_t Arm64RelativePatcher::ReserveSpace(uint32_t offset,
101 const CompiledMethod* compiled_method,
102 MethodReference method_ref) {
103 if (!fix_cortex_a53_843419_) {
104 DCHECK(adrp_thunk_locations_.empty());
105 return ReserveSpaceInternal(offset, compiled_method, method_ref, 0u);
106 }
107
108 // Add thunks for previous method if any.
109 if (reserved_adrp_thunks_ != adrp_thunk_locations_.size()) {
110 size_t num_adrp_thunks = adrp_thunk_locations_.size() - reserved_adrp_thunks_;
111 offset = CompiledMethod::AlignCode(offset, InstructionSet::kArm64) +
112 kAdrpThunkSize * num_adrp_thunks;
113 reserved_adrp_thunks_ = adrp_thunk_locations_.size();
114 }
115
116 // Count the number of ADRP insns as the upper bound on the number of thunks needed
117 // and use it to reserve space for other linker patches.
118 size_t num_adrp = 0u;
119 DCHECK(compiled_method != nullptr);
120 for (const LinkerPatch& patch : compiled_method->GetPatches()) {
121 if (IsAdrpPatch(patch)) {
122 ++num_adrp;
123 }
124 }
125 ArrayRef<const uint8_t> code = compiled_method->GetQuickCode();
126 uint32_t max_extra_space = MaxExtraSpace(num_adrp, code.size());
127 offset = ReserveSpaceInternal(offset, compiled_method, method_ref, max_extra_space);
128 if (num_adrp == 0u) {
129 return offset;
130 }
131
132 // Now that we have the actual offset where the code will be placed, locate the ADRP insns
133 // that actually require the thunk.
134 uint32_t quick_code_offset = compiled_method->AlignCode(offset + sizeof(OatQuickMethodHeader));
135 uint32_t thunk_offset = compiled_method->AlignCode(quick_code_offset + code.size());
136 DCHECK(compiled_method != nullptr);
137 for (const LinkerPatch& patch : compiled_method->GetPatches()) {
138 if (IsAdrpPatch(patch)) {
139 uint32_t patch_offset = quick_code_offset + patch.LiteralOffset();
140 if (NeedsErratum843419Thunk(code, patch.LiteralOffset(), patch_offset)) {
141 adrp_thunk_locations_.emplace_back(patch_offset, thunk_offset);
142 thunk_offset += kAdrpThunkSize;
143 }
144 }
145 }
146 return offset;
147 }
148
ReserveSpaceEnd(uint32_t offset)149 uint32_t Arm64RelativePatcher::ReserveSpaceEnd(uint32_t offset) {
150 if (!fix_cortex_a53_843419_) {
151 DCHECK(adrp_thunk_locations_.empty());
152 } else {
153 // Add thunks for the last method if any.
154 if (reserved_adrp_thunks_ != adrp_thunk_locations_.size()) {
155 size_t num_adrp_thunks = adrp_thunk_locations_.size() - reserved_adrp_thunks_;
156 offset = CompiledMethod::AlignCode(offset, InstructionSet::kArm64) +
157 kAdrpThunkSize * num_adrp_thunks;
158 reserved_adrp_thunks_ = adrp_thunk_locations_.size();
159 }
160 }
161 return ArmBaseRelativePatcher::ReserveSpaceEnd(offset);
162 }
163
WriteThunks(OutputStream * out,uint32_t offset)164 uint32_t Arm64RelativePatcher::WriteThunks(OutputStream* out, uint32_t offset) {
165 if (fix_cortex_a53_843419_) {
166 if (!current_method_thunks_.empty()) {
167 uint32_t aligned_offset = CompiledMethod::AlignCode(offset, InstructionSet::kArm64);
168 if (kIsDebugBuild) {
169 CHECK_ALIGNED(current_method_thunks_.size(), kAdrpThunkSize);
170 size_t num_thunks = current_method_thunks_.size() / kAdrpThunkSize;
171 CHECK_LE(num_thunks, processed_adrp_thunks_);
172 for (size_t i = 0u; i != num_thunks; ++i) {
173 const auto& entry = adrp_thunk_locations_[processed_adrp_thunks_ - num_thunks + i];
174 CHECK_EQ(entry.second, aligned_offset + i * kAdrpThunkSize);
175 }
176 }
177 uint32_t aligned_code_delta = aligned_offset - offset;
178 if (aligned_code_delta != 0u && !WriteCodeAlignment(out, aligned_code_delta)) {
179 return 0u;
180 }
181 if (!WriteMiscThunk(out, ArrayRef<const uint8_t>(current_method_thunks_))) {
182 return 0u;
183 }
184 offset = aligned_offset + current_method_thunks_.size();
185 current_method_thunks_.clear();
186 }
187 }
188 return ArmBaseRelativePatcher::WriteThunks(out, offset);
189 }
190
PatchCall(std::vector<uint8_t> * code,uint32_t literal_offset,uint32_t patch_offset,uint32_t target_offset)191 void Arm64RelativePatcher::PatchCall(std::vector<uint8_t>* code,
192 uint32_t literal_offset,
193 uint32_t patch_offset,
194 uint32_t target_offset) {
195 DCHECK_ALIGNED(literal_offset, 4u);
196 DCHECK_ALIGNED(patch_offset, 4u);
197 DCHECK_ALIGNED(target_offset, 4u);
198 uint32_t displacement = CalculateMethodCallDisplacement(patch_offset, target_offset & ~1u);
199 PatchBl(code, literal_offset, displacement);
200 }
201
PatchPcRelativeReference(std::vector<uint8_t> * code,const LinkerPatch & patch,uint32_t patch_offset,uint32_t target_offset)202 void Arm64RelativePatcher::PatchPcRelativeReference(std::vector<uint8_t>* code,
203 const LinkerPatch& patch,
204 uint32_t patch_offset,
205 uint32_t target_offset) {
206 DCHECK_ALIGNED(patch_offset, 4u);
207 DCHECK_ALIGNED(target_offset, 4u);
208 uint32_t literal_offset = patch.LiteralOffset();
209 uint32_t insn = GetInsn(code, literal_offset);
210 uint32_t pc_insn_offset = patch.PcInsnOffset();
211 uint32_t disp = target_offset - ((patch_offset - literal_offset + pc_insn_offset) & ~0xfffu);
212 bool wide = (insn & 0x40000000) != 0;
213 uint32_t shift = wide ? 3u : 2u;
214 if (literal_offset == pc_insn_offset) {
215 // Check it's an ADRP with imm == 0 (unset).
216 DCHECK_EQ((insn & 0xffffffe0u), 0x90000000u)
217 << literal_offset << ", " << pc_insn_offset << ", 0x" << std::hex << insn;
218 if (fix_cortex_a53_843419_ && processed_adrp_thunks_ != adrp_thunk_locations_.size() &&
219 adrp_thunk_locations_[processed_adrp_thunks_].first == patch_offset) {
220 DCHECK(NeedsErratum843419Thunk(ArrayRef<const uint8_t>(*code),
221 literal_offset, patch_offset));
222 uint32_t thunk_offset = adrp_thunk_locations_[processed_adrp_thunks_].second;
223 uint32_t adrp_disp = target_offset - (thunk_offset & ~0xfffu);
224 uint32_t adrp = PatchAdrp(insn, adrp_disp);
225
226 uint32_t out_disp = thunk_offset - patch_offset;
227 DCHECK_EQ(out_disp & 3u, 0u);
228 DCHECK((out_disp >> 27) == 0u || (out_disp >> 27) == 31u); // 28-bit signed.
229 insn = (out_disp & 0x0fffffffu) >> shift;
230 insn |= 0x14000000; // B <thunk>
231
232 uint32_t back_disp = -out_disp;
233 DCHECK_EQ(back_disp & 3u, 0u);
234 DCHECK((back_disp >> 27) == 0u || (back_disp >> 27) == 31u); // 28-bit signed.
235 uint32_t b_back = (back_disp & 0x0fffffffu) >> 2;
236 b_back |= 0x14000000; // B <back>
237 size_t thunks_code_offset = current_method_thunks_.size();
238 current_method_thunks_.resize(thunks_code_offset + kAdrpThunkSize);
239 SetInsn(¤t_method_thunks_, thunks_code_offset, adrp);
240 SetInsn(¤t_method_thunks_, thunks_code_offset + 4u, b_back);
241 static_assert(kAdrpThunkSize == 2 * 4u, "thunk has 2 instructions");
242
243 processed_adrp_thunks_ += 1u;
244 } else {
245 insn = PatchAdrp(insn, disp);
246 }
247 // Write the new ADRP (or B to the erratum 843419 thunk).
248 SetInsn(code, literal_offset, insn);
249 } else {
250 if ((insn & 0xfffffc00) == 0x91000000) {
251 // ADD immediate, 64-bit with imm12 == 0 (unset).
252 if (!kEmitCompilerReadBarrier) {
253 DCHECK(patch.GetType() == LinkerPatch::Type::kIntrinsicReference ||
254 patch.GetType() == LinkerPatch::Type::kMethodRelative ||
255 patch.GetType() == LinkerPatch::Type::kTypeRelative ||
256 patch.GetType() == LinkerPatch::Type::kStringRelative) << patch.GetType();
257 } else {
258 // With the read barrier (non-Baker) enabled, it could be kStringBssEntry or kTypeBssEntry.
259 DCHECK(patch.GetType() == LinkerPatch::Type::kIntrinsicReference ||
260 patch.GetType() == LinkerPatch::Type::kMethodRelative ||
261 patch.GetType() == LinkerPatch::Type::kTypeRelative ||
262 patch.GetType() == LinkerPatch::Type::kStringRelative ||
263 patch.GetType() == LinkerPatch::Type::kTypeBssEntry ||
264 patch.GetType() == LinkerPatch::Type::kStringBssEntry) << patch.GetType();
265 }
266 shift = 0u; // No shift for ADD.
267 } else {
268 // LDR/STR 32-bit or 64-bit with imm12 == 0 (unset).
269 DCHECK(patch.GetType() == LinkerPatch::Type::kDataBimgRelRo ||
270 patch.GetType() == LinkerPatch::Type::kMethodBssEntry ||
271 patch.GetType() == LinkerPatch::Type::kTypeBssEntry ||
272 patch.GetType() == LinkerPatch::Type::kStringBssEntry) << patch.GetType();
273 DCHECK_EQ(insn & 0xbfbffc00, 0xb9000000) << std::hex << insn;
274 }
275 if (kIsDebugBuild) {
276 uint32_t adrp = GetInsn(code, pc_insn_offset);
277 if ((adrp & 0x9f000000u) != 0x90000000u) {
278 CHECK(fix_cortex_a53_843419_);
279 CHECK_EQ(adrp & 0xfc000000u, 0x14000000u); // B <thunk>
280 CHECK_ALIGNED(current_method_thunks_.size(), kAdrpThunkSize);
281 size_t num_thunks = current_method_thunks_.size() / kAdrpThunkSize;
282 CHECK_LE(num_thunks, processed_adrp_thunks_);
283 uint32_t b_offset = patch_offset - literal_offset + pc_insn_offset;
284 for (size_t i = processed_adrp_thunks_ - num_thunks; ; ++i) {
285 CHECK_NE(i, processed_adrp_thunks_);
286 if (adrp_thunk_locations_[i].first == b_offset) {
287 size_t idx = num_thunks - (processed_adrp_thunks_ - i);
288 adrp = GetInsn(¤t_method_thunks_, idx * kAdrpThunkSize);
289 break;
290 }
291 }
292 }
293 CHECK_EQ(adrp & 0x9f00001fu, // Check that pc_insn_offset points
294 0x90000000 | ((insn >> 5) & 0x1fu)); // to ADRP with matching register.
295 }
296 uint32_t imm12 = (disp & 0xfffu) >> shift;
297 insn = (insn & ~(0xfffu << 10)) | (imm12 << 10);
298 SetInsn(code, literal_offset, insn);
299 }
300 }
301
PatchEntrypointCall(std::vector<uint8_t> * code,const LinkerPatch & patch,uint32_t patch_offset)302 void Arm64RelativePatcher::PatchEntrypointCall(std::vector<uint8_t>* code,
303 const LinkerPatch& patch,
304 uint32_t patch_offset) {
305 DCHECK_ALIGNED(patch_offset, 4u);
306 ThunkKey key = GetEntrypointCallKey(patch);
307 uint32_t target_offset = GetThunkTargetOffset(key, patch_offset);
308 uint32_t displacement = target_offset - patch_offset;
309 PatchBl(code, patch.LiteralOffset(), displacement);
310 }
311
PatchBakerReadBarrierBranch(std::vector<uint8_t> * code,const LinkerPatch & patch,uint32_t patch_offset)312 void Arm64RelativePatcher::PatchBakerReadBarrierBranch(std::vector<uint8_t>* code,
313 const LinkerPatch& patch,
314 uint32_t patch_offset) {
315 DCHECK_ALIGNED(patch_offset, 4u);
316 uint32_t literal_offset = patch.LiteralOffset();
317 uint32_t insn = GetInsn(code, literal_offset);
318 DCHECK_EQ(insn & 0xffffffe0u, 0xb5000000); // CBNZ Xt, +0 (unpatched)
319 ThunkKey key = GetBakerThunkKey(patch);
320 uint32_t target_offset = GetThunkTargetOffset(key, patch_offset);
321 DCHECK_ALIGNED(target_offset, 4u);
322 uint32_t disp = target_offset - patch_offset;
323 DCHECK((disp >> 20) == 0u || (disp >> 20) == 4095u); // 21-bit signed.
324 insn |= (disp << (5 - 2)) & 0x00ffffe0u; // Shift bits 2-20 to 5-23.
325 SetInsn(code, literal_offset, insn);
326 }
327
MaxPositiveDisplacement(const ThunkKey & key)328 uint32_t Arm64RelativePatcher::MaxPositiveDisplacement(const ThunkKey& key) {
329 switch (key.GetType()) {
330 case ThunkType::kMethodCall:
331 case ThunkType::kEntrypointCall:
332 return kMaxMethodCallPositiveDisplacement;
333 case ThunkType::kBakerReadBarrier:
334 return kMaxBcondPositiveDisplacement;
335 }
336 }
337
MaxNegativeDisplacement(const ThunkKey & key)338 uint32_t Arm64RelativePatcher::MaxNegativeDisplacement(const ThunkKey& key) {
339 switch (key.GetType()) {
340 case ThunkType::kMethodCall:
341 case ThunkType::kEntrypointCall:
342 return kMaxMethodCallNegativeDisplacement;
343 case ThunkType::kBakerReadBarrier:
344 return kMaxBcondNegativeDisplacement;
345 }
346 }
347
PatchAdrp(uint32_t adrp,uint32_t disp)348 uint32_t Arm64RelativePatcher::PatchAdrp(uint32_t adrp, uint32_t disp) {
349 return (adrp & 0x9f00001fu) | // Clear offset bits, keep ADRP with destination reg.
350 // Bottom 12 bits are ignored, the next 2 lowest bits are encoded in bits 29-30.
351 ((disp & 0x00003000u) << (29 - 12)) |
352 // The next 16 bits are encoded in bits 5-22.
353 ((disp & 0xffffc000u) >> (12 + 2 - 5)) |
354 // Since the target_offset is based on the beginning of the oat file and the
355 // image space precedes the oat file, the target_offset into image space will
356 // be negative yet passed as uint32_t. Therefore we limit the displacement
357 // to +-2GiB (rather than the maximim +-4GiB) and determine the sign bit from
358 // the highest bit of the displacement. This is encoded in bit 23.
359 ((disp & 0x80000000u) >> (31 - 23));
360 }
361
PatchBl(std::vector<uint8_t> * code,uint32_t literal_offset,uint32_t displacement)362 void Arm64RelativePatcher::PatchBl(std::vector<uint8_t>* code,
363 uint32_t literal_offset,
364 uint32_t displacement) {
365 DCHECK_ALIGNED(displacement, 4u);
366 DCHECK((displacement >> 27) == 0u || (displacement >> 27) == 31u); // 28-bit signed.
367 uint32_t insn = (displacement & 0x0fffffffu) >> 2;
368 insn |= 0x94000000; // BL
369
370 // Check that we're just overwriting an existing BL.
371 DCHECK_EQ(GetInsn(code, literal_offset) & 0xfc000000u, 0x94000000u);
372 // Write the new BL.
373 SetInsn(code, literal_offset, insn);
374 }
375
NeedsErratum843419Thunk(ArrayRef<const uint8_t> code,uint32_t literal_offset,uint32_t patch_offset)376 bool Arm64RelativePatcher::NeedsErratum843419Thunk(ArrayRef<const uint8_t> code,
377 uint32_t literal_offset,
378 uint32_t patch_offset) {
379 DCHECK_EQ(patch_offset & 0x3u, 0u);
380 if ((patch_offset & 0xff8) == 0xff8) { // ...ff8 or ...ffc
381 uint32_t adrp = GetInsn(code, literal_offset);
382 DCHECK_EQ(adrp & 0x9f000000, 0x90000000);
383 uint32_t next_offset = patch_offset + 4u;
384 uint32_t next_insn = GetInsn(code, literal_offset + 4u);
385
386 // Below we avoid patching sequences where the adrp is followed by a load which can easily
387 // be proved to be aligned.
388
389 // First check if the next insn is the LDR using the result of the ADRP.
390 // LDR <Wt>, [<Xn>, #pimm], where <Xn> == ADRP destination reg.
391 if ((next_insn & 0xffc00000) == 0xb9400000 &&
392 (((next_insn >> 5) ^ adrp) & 0x1f) == 0) {
393 return false;
394 }
395
396 // And since LinkerPatch::Type::k{Method,Type,String}Relative is using the result
397 // of the ADRP for an ADD immediate, check for that as well. We generalize a bit
398 // to include ADD/ADDS/SUB/SUBS immediate that either uses the ADRP destination
399 // or stores the result to a different register.
400 if ((next_insn & 0x1f000000) == 0x11000000 &&
401 ((((next_insn >> 5) ^ adrp) & 0x1f) == 0 || ((next_insn ^ adrp) & 0x1f) != 0)) {
402 return false;
403 }
404
405 // LDR <Wt>, <label> is always aligned and thus it doesn't cause boundary crossing.
406 if ((next_insn & 0xff000000) == 0x18000000) {
407 return false;
408 }
409
410 // LDR <Xt>, <label> is aligned iff the pc + displacement is a multiple of 8.
411 if ((next_insn & 0xff000000) == 0x58000000) {
412 bool is_aligned_load = (((next_offset >> 2) ^ (next_insn >> 5)) & 1) == 0;
413 return !is_aligned_load;
414 }
415
416 // LDR <Wt>, [SP, #<pimm>] and LDR <Xt>, [SP, #<pimm>] are always aligned loads, as SP is
417 // guaranteed to be 128-bits aligned and <pimm> is multiple of the load size.
418 if ((next_insn & 0xbfc003e0) == 0xb94003e0) {
419 return false;
420 }
421 return true;
422 }
423 return false;
424 }
425
SetInsn(std::vector<uint8_t> * code,uint32_t offset,uint32_t value)426 void Arm64RelativePatcher::SetInsn(std::vector<uint8_t>* code, uint32_t offset, uint32_t value) {
427 DCHECK_LE(offset + 4u, code->size());
428 DCHECK_ALIGNED(offset, 4u);
429 uint8_t* addr = &(*code)[offset];
430 addr[0] = (value >> 0) & 0xff;
431 addr[1] = (value >> 8) & 0xff;
432 addr[2] = (value >> 16) & 0xff;
433 addr[3] = (value >> 24) & 0xff;
434 }
435
GetInsn(ArrayRef<const uint8_t> code,uint32_t offset)436 uint32_t Arm64RelativePatcher::GetInsn(ArrayRef<const uint8_t> code, uint32_t offset) {
437 DCHECK_LE(offset + 4u, code.size());
438 DCHECK_ALIGNED(offset, 4u);
439 const uint8_t* addr = &code[offset];
440 return
441 (static_cast<uint32_t>(addr[0]) << 0) +
442 (static_cast<uint32_t>(addr[1]) << 8) +
443 (static_cast<uint32_t>(addr[2]) << 16)+
444 (static_cast<uint32_t>(addr[3]) << 24);
445 }
446
447 template <typename Alloc>
GetInsn(std::vector<uint8_t,Alloc> * code,uint32_t offset)448 uint32_t Arm64RelativePatcher::GetInsn(std::vector<uint8_t, Alloc>* code, uint32_t offset) {
449 return GetInsn(ArrayRef<const uint8_t>(*code), offset);
450 }
451
452 } // namespace linker
453 } // namespace art
454