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 #ifndef ART_DEX2OAT_LINKER_ARM_RELATIVE_PATCHER_THUMB2_H_ 18 #define ART_DEX2OAT_LINKER_ARM_RELATIVE_PATCHER_THUMB2_H_ 19 20 #include "arch/arm/registers_arm.h" 21 #include "base/array_ref.h" 22 #include "linker/arm/relative_patcher_arm_base.h" 23 24 namespace art { 25 26 namespace arm { 27 class ArmVIXLAssembler; 28 } // namespace arm 29 30 namespace linker { 31 32 class Thumb2RelativePatcher final : public ArmBaseRelativePatcher { 33 public: 34 explicit Thumb2RelativePatcher(RelativePatcherThunkProvider* thunk_provider, 35 RelativePatcherTargetProvider* target_provider); 36 37 void PatchCall(std::vector<uint8_t>* code, 38 uint32_t literal_offset, 39 uint32_t patch_offset, 40 uint32_t target_offset) override; 41 void PatchPcRelativeReference(std::vector<uint8_t>* code, 42 const LinkerPatch& patch, 43 uint32_t patch_offset, 44 uint32_t target_offset) override; 45 void PatchBakerReadBarrierBranch(std::vector<uint8_t>* code, 46 const LinkerPatch& patch, 47 uint32_t patch_offset) override; 48 49 protected: 50 uint32_t MaxPositiveDisplacement(const ThunkKey& key) override; 51 uint32_t MaxNegativeDisplacement(const ThunkKey& key) override; 52 53 private: 54 void SetInsn32(std::vector<uint8_t>* code, uint32_t offset, uint32_t value); 55 static uint32_t GetInsn32(ArrayRef<const uint8_t> code, uint32_t offset); 56 57 template <typename Vector> 58 static uint32_t GetInsn32(Vector* code, uint32_t offset); 59 60 static uint32_t GetInsn16(ArrayRef<const uint8_t> code, uint32_t offset); 61 62 template <typename Vector> 63 static uint32_t GetInsn16(Vector* code, uint32_t offset); 64 65 friend class Thumb2RelativePatcherTest; 66 67 DISALLOW_COPY_AND_ASSIGN(Thumb2RelativePatcher); 68 }; 69 70 } // namespace linker 71 } // namespace art 72 73 #endif // ART_DEX2OAT_LINKER_ARM_RELATIVE_PATCHER_THUMB2_H_ 74