Recompiler: a delay slot past the function end is replaced by a NOP

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

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

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

評価

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

調査の方向性

Start with function_emitter.cpp:143-147 and trace how delay slots are decoded when a branch or jump ends a function range. Check how the ELF section provides the word at inst.address + 4, and compare that behavior with makeSyntheticDelaySlot. Done means the real delay instruction is preserved, or a warning identifies when a non-NOP word would be replaced.

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

説明

When a branch or jump is the last instruction of a function's range, function_emitter.cpp:143-147 emits a synthetic NOP for its delay slot (makeSyntheticDelaySlot) instead of decoding the real word at inst.address + 4 from the ELF. Nothing is logged.

So any function start that lands on a delay slot silently drops that delay instruction from the owner. The fallback heuristics are fixed in the linked PR, but the same thing can still happen with starts from JAL targets, the entry point, symbols, DWARF or Ghidra maps.

Seen in FIFA Street 2 (SLUS-21369): a heuristic start at 0x202020 cut sub_00201FD8 right after jal 0x431c88. The delay-slot lw $a0, 0($v0) that loads the call argument was replaced by the NOP, the lookup returned null, and the main thread died on a virtual call at 0x202048.

Suggested fix: decode the real word from the section when the delay slot sits outside the range, or at least warn when that word is not a NOP.

Related PR: fix/delay-slot-function-starts

主要言語
C++
スター
3.3k
フォーク
149
平均マージ
8時間 46分
マージ済み PR(30日)
1

環境構築

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

はじめの一歩

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

ran-j/PS2Recomp のほかの issue

ran-j/PS2Recomp の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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