MSP430: Sub lifts operands in reverse order (inconsistent with Cmp)

未关闭 适合新手
#8,503 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
92/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust

调研方向

打开 arch/msp430/src/lift.rs,并结合 Instruction::Cmp 检查 Instruction::Sub case。使用 printf '\x3b\x80\x02\x24' > sub_repro.bin 复现,并将其作为 MSP430 加载。完成标准是 sub #0x2402, r11 生成 LLIL r11 = r11 - 0x2402,同时 constant-generator 形式保持不受影响。

由索引模型根据 Issue 内容生成。

描述

Arch: MSP430

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

主要语言
C++
星标
1.3k
派生
298
平均合并
5 天 5 小时
30 天内合并 PR
19

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Vector35/binaryninja-api 的其他 Issue

查看 Vector35/binaryninja-api 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。