[Bug] Declare recovered internal functions before call sites

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

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

評価

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

調査の方向性

Start with the function emission loop in src/decompiler/project.cpp (lines 316-337) and the call emission in src/decompiler/decompiler.cpp (lines 558-590), then check how analysis.functions is used to name callees. Save the issue's reproducer as C, decompile it, and compile the output with gcc -std=c11 -Wall -Wextra -Werror to see the implicit-declaration error. Done means the reproducer compiles cleanly, and forward and mutually recursive calls also compile with matching prototypes and static linkage.

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

説明

bug

Summary

Generated C-like output calls recovered internal functions before declaring them. When a caller is located before its callee in the binary, the generated source fails under C11 with -Werror.

Evidence

src/decompiler/project.cpp:316-337 emits recovered function definitions in analysis/address order, while src/decompiler/decompiler.cpp:558-590 emits calls using the recovered callee name. No forward declarations are emitted for functions in analysis.functions.

Reproducer:

int callee(int);
__attribute__((noinline)) int caller(int x) { return callee(x); }
__attribute__((noinline)) int callee(int x) { return x; }
int main(void) { return caller(0); }

After compiling at -O0 -g, decompiling, and compiling the recovered source with gcc -std=c11 -Wall -Wextra -Werror, GCC reports:

error: implicit declaration of function ‘callee’
error: static declaration of ‘callee’ follows non-static declaration

Impact

Whether recovered output compiles depends on the link/order layout of functions. Forward calls, mutually recursive functions, and some stripped binaries fail even when the underlying recovered call is otherwise representable.

Expected behavior

The renderer should emit a consistent prototype for every recovered internal function before any function body, or otherwise order declarations safely while preserving recursion and the static linkage used by generated definitions.

Acceptance criteria

  • The reproducer compiles with -std=c11 -Wall -Wextra -Werror.
  • Forward calls and recursive/mutually recursive calls do not produce implicit-declaration or linkage-conflict diagnostics.
  • Prototypes use the same generated identifiers and compatible parameter/return types as their definitions.
主要言語
C++
スター
0
フォーク
0
PR マージ指標
30日以内にマージされた PR はありません

環境構築

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

はじめの一歩

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

TiElixir/caraxes のほかの issue

TiElixir/caraxes の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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