/* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "linker/arm64/relative_patcher_arm64.h" #include "base/casts.h" #include "linker/relative_patcher_test.h" #include "lock_word.h" #include "mirror/array-inl.h" #include "mirror/object.h" #include "oat_quick_method_header.h" namespace art { namespace linker { class Arm64RelativePatcherTest : public RelativePatcherTest { public: explicit Arm64RelativePatcherTest(const std::string& variant) : RelativePatcherTest(InstructionSet::kArm64, variant) { } protected: static const uint8_t kCallRawCode[]; static const ArrayRef kCallCode; static const uint8_t kNopRawCode[]; static const ArrayRef kNopCode; // NOP instruction. static constexpr uint32_t kNopInsn = 0xd503201f; // All branches can be created from kBlPlus0 or kBPlus0 by adding the low 26 bits. static constexpr uint32_t kBlPlus0 = 0x94000000u; static constexpr uint32_t kBPlus0 = 0x14000000u; // Special BL values. static constexpr uint32_t kBlPlusMax = 0x95ffffffu; static constexpr uint32_t kBlMinusMax = 0x96000000u; // LDR immediate, 32-bit, unsigned offset. static constexpr uint32_t kLdrWInsn = 0xb9400000u; // LDR register, 32-bit, LSL #2. static constexpr uint32_t kLdrWLsl2Insn = 0xb8607800u; // LDUR, 32-bit. static constexpr uint32_t kLdurWInsn = 0xb8400000u; // ADD/ADDS/SUB/SUBS immediate, 64-bit. static constexpr uint32_t kAddXInsn = 0x91000000u; static constexpr uint32_t kAddsXInsn = 0xb1000000u; static constexpr uint32_t kSubXInsn = 0xd1000000u; static constexpr uint32_t kSubsXInsn = 0xf1000000u; // LDUR x2, [sp, #4], i.e. unaligned load crossing 64-bit boundary (assuming aligned sp). static constexpr uint32_t kLdurInsn = 0xf840405fu; // LDR w12,