Commit 2f56fd50 authored by swift_gan's avatar swift_gan Committed by swift_gan

[NativeHook]fix b

parent c7fbe9ee
......@@ -98,7 +98,7 @@ void AssemblerA32::Ldrsh(RegisterA32 &rt, const MemOperand &operand) {
}
void AssemblerA32::B(Label *label) {
Emit(reinterpret_cast<Unit<Base>*>(new INST_T32(B32)(INST_T32(B32)::B, INST_T32(B32)::arm, *label)));
Emit(reinterpret_cast<Unit<Base>*>(new INST_T16(B)(*label)));
}
void AssemblerA32::Bl(Label *label) {
......
......@@ -43,7 +43,7 @@ T16_B::T16_B(Label &label) {
}
Off T16_B::getImmPCOffset() {
return signExtend32(11 + 1, COMBINE(get()->imm11, 0, 1));
return DECODE_OFFSET(11, 1);
}
void T16_B::decode(T16_STRUCT_B *inst) {
......@@ -52,12 +52,12 @@ void T16_B::decode(T16_STRUCT_B *inst) {
void T16_B::assembler() {
SET_OPCODE(B);
get()->imm11 = TruncateToUint11(offset >> 1);
DECODE_OFFSET(11, 1);
}
void T16_B::onOffsetApply(Off offset) {
this->offset = offset;
get()->imm11 = TruncateToUint11(offset >> 1);
DECODE_OFFSET(11, 1);
}
......
......@@ -170,8 +170,10 @@ IMPL_RELOCATE(T16, CBZ_CBNZ) {
IMPL_RELOCATE(T16, LDR_LIT) {
if (inRelocateRange(CODE_OFFSET(inst), sizeof(InstT16))) {
__ Ldr(*inst->rt, getLaterBindLabel(CODE_OFFSET(inst) + curOffset));
if (inRelocateRange(CODE_OFFSET(inst), inst->rt->getWide())) {
inst->ref();
inst->bindLabel(*getLaterBindLabel(CODE_OFFSET(inst) + curOffset));
__ Emit(reinterpret_cast<Instruction<Base>*>(inst));
return;
}
......@@ -183,8 +185,10 @@ IMPL_RELOCATE(T16, LDR_LIT) {
IMPL_RELOCATE(T16, ADR) {
if (inRelocateRange(CODE_OFFSET(inst), sizeof(InstT16))) {
__ Adr(*inst->rd, getLaterBindLabel(CODE_OFFSET(inst) + curOffset));
if (inRelocateRange(CODE_OFFSET(inst), inst->rd->getWide())) {
inst->ref();
inst->bindLabel(*getLaterBindLabel(CODE_OFFSET(inst) + curOffset));
__ Emit(reinterpret_cast<Instruction<Base>*>(inst));
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment