Skip to content

Commit

Permalink
Fix register garbage due to jumping outside of current function
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Sep 10, 2024
1 parent 74ab2b2 commit 5b60dd0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- This change should also reduce (and hopefully remove) the gaps generated
between symbols during rodata migration.

### Fixed

- Fix pointer tracking: fix garbage state of registers after function jumping
outside of the current function.

## [1.29.0] - 2024-09-09

### Added
Expand Down
10 changes: 10 additions & 0 deletions spimdisasm/mips/symbols/MipsSymbolFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ def _runInstructionAnalyzer(self) -> None:
# look-ahead symbol finder
self._lookAheadSymbolFinder(instr, prevInstr, instructionOffset, regsTracker)

if prevInstr.isJumpWithAddress() and not prevInstr.doesLink():
targetVram = prevInstr.getBranchVramGeneric()
if targetVram < self.vram or targetVram >= self.vramEnd:
# Function is jumping outside the current function, so
# the state of the registers is garbage to the rest of the
# function, so just reset everything.
# Jumping without linking outside of functions like this is
# usually caused by tail call optimizations.
regsTracker = rabbitizer.RegistersTracker()

self.instrAnalyzer.processPrevFuncCall(regsTracker, instr, prevInstr, currentVram)

instructionOffset += 4
Expand Down

0 comments on commit 5b60dd0

Please sign in to comment.