xor reg1, reg1 is not always simplified to reg1 = 0

オープン
#6,010 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp

調査の方向性

Start by opening the supplied xor_simple.bndb.zip and keygenme4.exe.bndb.zip databases, then inspect the LLIL, MLIL, and HLIL around address 0x416ed5. Compare the inconsistent xor self-assignment simplification with the simple case. Done means equivalent opaque-predicate branches are simplified consistently without changing program semantics.

索引モデルが issue の本文から書いたものです。

説明

Component: Core Core: LLIL Effort: Low Impact: Low

When we have some code like

xor edx, edx
jne 0x18
Screenshot 2024-10-19 at 12 56 30 PM

The LLIL simplifies the xor instruction to edx = 0, and the jne instruction is treated as opaque predicate and removed in higher level of ILs.

LLIL:

Screenshot 2024-10-19 at 12 57 55 PM

MLIL:

Screenshot 2024-10-19 at 12 58 06 PM

HLIL:

Screenshot 2024-10-19 at 12 58 33 PM

This works perfectly for the above example, however, I noticed that it does not work all of the time. See below for an example:

Screenshot 2024-10-19 at 12 59 41 PM

This is an opaque predicate as well and the left branch is fake. The code always executes the right branch.

LLIL:

Screenshot 2024-10-19 at 1 00 37 PM

MLIL:

Screenshot 2024-10-19 at 1 01 03 PM

HLIL:

Screenshot 2024-10-19 at 1 01 35 PM

While the semantics of the code is still correct and we can see it is still an opaque predicate, we should be able to simplify it automatically.

Database:

Offending binary:

keygenme4.exe.bndb.zip

Address: 0x416ed5

Simple case:
xor_simple.bndb.zip

主要言語
C++
スター
1.3k
フォーク
298
平均マージ
5日 5時間
マージ済み PR(30日)
19

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Vector35/binaryninja-api のほかの issue

Vector35/binaryninja-api の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。