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

Aperta
#370 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
C++
Stelle
3.3k
Fork
149
Merge medio
8h 46m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ran-j/PS2Recomp

Tutte le issue di ran-j/PS2Recomp

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.