On the ARMv7 in the Thumb mode, unconditional BranchThumbOffset uses relative offset to the current instruction, however the conditional branches do +1 for some reason:
|
inst.opcode = Opcode::B; |
|
let imm = instr2[0..8].load::<u8>() as i8 as i32; |
|
inst.condition = ConditionCode::build(opcode); |
|
inst.operands = [ |
|
Operand::BranchThumbOffset(imm + 1), |
Is there a reason for this? The workaround is simple
let fixup = if code.instruction.condition == ConditionCode::AL {
4
} else {
2
};
let pc = code.offset + fixup;
but I don't think it matches the ARM spec (where the PC + 4 is a general rule for the PC-relative stuff).
On the ARMv7 in the Thumb mode, unconditional
BranchThumbOffsetuses relative offset to the current instruction, however the conditional branches do+1for some reason:yaxpeax-arm/src/armv7/thumb.rs
Lines 4182 to 4186 in 5803a74
Is there a reason for this? The workaround is simple
but I don't think it matches the ARM spec (where the PC + 4 is a general rule for the PC-relative stuff).