x86 lifting issues

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

メンテナーはふだん 2 日以内に返信

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp

調査の方向性

Start by reading core/flagsresolver.cpp around line 1855 and arch/x86/il.cpp around line 5263, then inspect the supplied kat-i386.o instructions at 0x10fa4 and 0x1236b. Verify that optimized LLIL branches on the original ECX value and that bsr exposes its scan result and zero flag semantics. Done means both cases produce the expected LLIL behavior.

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

説明

Binary files and instruction addresses (ZIP available for upload separately):

  • kat-i386.o: 0x10fa4, 0x1236b; SHA-256 e5c0a966aa75166edbb37d3130274e543b4dbf3a90718c197cc25f5d90965f8b

1: add ecx, -1; jae has an inverted condition

Binary instruction: kat-i386.o / signed_division at 0x10fa4; bytes 83c1ff 732b.

Disassembly: add ecx, 0xffffffff; jae 0x10fd4.

Current lifted LLIL (relevant lines):

ecx = add.d{*}(ecx, -1)
if (ge {u>=, x87comi.f>=, vcomi.f>=}) then 0x10fd4 else 0x10fa9

Current optimized LLIL (relevant lines):

temp0.d = ecx
ecx = ecx - 1
if (temp0.d u>= 1) then 0x10fd4 else 0x10fa9

Expected LLIL (semantic sketch):

old_ecx = ecx
ecx = add.d{*}(old_ecx, -1)
if (old_ecx == 0) then 0x10fd4 else 0x10fa9

Adding 0xffffffff sets the carry flag when the original ecx is nonzero. Since jae branches when carry is clear, it should branch only when the original ecx is zero; the optimized old_ecx u>= 1 condition branches in the opposite case. The lifted LLIL retains the flags correctly; the incorrect condition appears in optimized LLIL from the core flag resolver.

Code: core/flagsresolver.cpp:1855

2: x86 bsr / bsf

Binary instruction: kat-i386.o / bitcount_probe at 0x1236b; bytes 0fbdcf.

Disassembly: bsr ecx, edi.

Current lifted LLIL (relevant lines):

ecx, eflags = _bit_scan_reverse(edi)

Expected LLIL (semantic sketch):

ecx = 31 - clz.d(edi) for nonzero edi; ZF = (edi == 0)

The opaque form has no executable scan or ZF semantics in LLIL.

Code: arch/x86/il.cpp:5263

主要言語
C++
スター
1.3k
フォーク
304
平均マージ
2日 20時間
マージ済み PR(30日)
10

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

Vector35/binaryninja-api のほかの issue

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

似ている issue

C++ の issue をもっと見る

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

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