diff --git a/src/assembler/ArmV8Assembler.cpp b/src/assembler/ArmV8Assembler.cpp index 9be8097..c18ad31 100644 --- a/src/assembler/ArmV8Assembler.cpp +++ b/src/assembler/ArmV8Assembler.cpp @@ -87,9 +87,9 @@ void ArmV8Assembler::stp(ArmV8Register reg1, ArmV8Register reg2, ArmV8Register r this->write32(opc | reg2Shifted | regBaseShifted | immShifted | val(reg1)); } -void ArmV8Assembler::adrp(ArmV8Register dst, uint32_t imm) { +void ArmV8Assembler::adrp(ArmV8Register dst, int64_t imm) { const auto immlo = ((imm >> 12) & 3ull) << 29; - const auto immhi = (imm >> 14) << 5; + const auto immhi = ((imm >> 14) & 0x7ffffull) << 5; this->write32(0x90000000 | immlo | immhi | val(dst)); } diff --git a/src/assembler/ArmV8Assembler.hpp b/src/assembler/ArmV8Assembler.hpp index 42c5c6f..3d7a71f 100644 --- a/src/assembler/ArmV8Assembler.hpp +++ b/src/assembler/ArmV8Assembler.hpp @@ -96,7 +96,7 @@ namespace tulip::hook { void ldr(ArmV8Register dst, std::string const& label); void ldp(ArmV8Register reg1, ArmV8Register reg2, ArmV8Register regBase, int16_t imm, ArmV8IndexKind kind); void stp(ArmV8Register reg1, ArmV8Register reg2, ArmV8Register regBase, int16_t imm, ArmV8IndexKind kind); - void adrp(ArmV8Register dst, uint32_t imm); + void adrp(ArmV8Register dst, int64_t imm); void add(ArmV8Register dst, ArmV8Register src, uint16_t imm); void b(uint32_t imm); void br(ArmV8Register reg);