Version and Platform (required):
- Binary Ninja Version: 5.0.7648
- Edition: Non-Commercial
- OS: Ubuntu Linux
- OS Version: 24.04
- CPU Architecture: x64
Bug Description:
The MSP430 lifter emits sub with its operands reversed. MSP430 defines sub src, dst as computing dst - src, but the lifter produces src - dst.
Cmp in the same file (arch/msp430/src/lift.rs) is correct, and the two are inconsistent:
// Instruction::Sub
il.sub(size, src, dest)
// Instruction::Cmp
il.sub(size, dest, src)
Steps To Reproduce:
Load 3b 80 02 24 as msp430 (sub #0x2402, r11).
Expected LLIL: r11 = r11 - 0x2402
Actual LLIL: r11 = 0x2402 - r11
Binary:
printf '\x3b\x80\x02\x24' > sub_repro.bin in a terminal.
Possible solution:
Switch src and dest in il.sub(size, src, dest), in the case Instruction::Sub(inst) of the file arch/msp430/src/lift.rs.
Notes:
Constant-generator forms (dec, decd) are unaffected -- they take a different code path, which lifts correctly.
Impact:
Produces plausible but incorrect decompilation for any length or offset computation using sub
Version and Platform (required):
Bug Description:
The MSP430 lifter emits sub with its operands reversed. MSP430 defines sub src, dst as computing dst - src, but the lifter produces src - dst.
Cmp in the same file (
arch/msp430/src/lift.rs) is correct, and the two are inconsistent:Steps To Reproduce:
Load
3b 80 02 24as msp430 (sub #0x2402, r11).Expected LLIL:
r11 = r11 - 0x2402Actual LLIL:
r11 = 0x2402 - r11Binary:
printf '\x3b\x80\x02\x24' > sub_repro.binin a terminal.Possible solution:
Switch
srcanddestinil.sub(size, src, dest), in the caseInstruction::Sub(inst)of the filearch/msp430/src/lift.rs.Notes:
Constant-generator forms (
dec,decd) are unaffected -- they take a different code path, which lifts correctly.Impact:
Produces plausible but incorrect decompilation for any length or offset computation using
sub