Skip to content

Commit

Permalink
Maybe fix jumptable labels sometimes missing their rom suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Dec 2, 2024
1 parent ff5fb6d commit 918e9a1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix jumptable labels sometimes missing their rom suffix.

## [1.31.1] - 2024-12-01

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ If you use a `requirements.txt` file in your repository, then you can add
this library with the following line:

```txt
spimdisasm>=1.31.1,<2.0.0
spimdisasm>=1.31.2,<2.0.0
```

### Development version
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[project]
name = "spimdisasm"
# Version should be synced with spimdisasm/__init__.py
version = "1.31.1"
version = "1.31.2-dev0"
description = "MIPS disassembler"
readme = "README.md"
license = {file = "LICENSE"}
Expand Down
4 changes: 2 additions & 2 deletions spimdisasm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from __future__ import annotations

__version_info__: tuple[int, int, int] = (1, 31, 1)
__version__ = ".".join(map(str, __version_info__))# + "-dev0"
__version_info__: tuple[int, int, int] = (1, 31, 2)
__version__ = ".".join(map(str, __version_info__)) + "-dev0"
__author__ = "Decompollaborate"

from . import common as common
Expand Down
14 changes: 12 additions & 2 deletions spimdisasm/mips/FuncRodataEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ def iterRodataSyms(self) -> Generator[symbols.SymbolBase, None, None]:
yield sym

def writeToFile(self, f: TextIO, writeFunction: bool=True) -> None:
# Sadly, we have some logic that may affect disassembling other symbols
# on the "function"'s disassembly function, like setting the rom address
# of jumptable labels. Having this info may affect the name they get
# disassembled as.
# To avoid this issue, we disassemble the function first without writing
# it to the file.
disassembledFunction: str|None = None
if self.function is not None:
disassembledFunction = self.function.disassemble(migrate=self.hasRodataSyms(), isSplittedSymbol=True)

if len(self.rodataSyms) > 0:
# Write the rdata
f.write(f".section {self.sectionRodata}{common.GlobalConfig.LINE_ENDS}")
Expand All @@ -79,13 +89,13 @@ def writeToFile(self, f: TextIO, writeFunction: bool=True) -> None:
f.write(sym.disassemble(migrate=True, useGlobalLabel=True, isSplittedSymbol=True))
f.write(common.GlobalConfig.LINE_ENDS)

if self.function is not None:
if disassembledFunction is not None:
if len(self.rodataSyms) > 0 or len(self.lateRodataSyms) > 0:
f.write(f"{common.GlobalConfig.LINE_ENDS}.section {self.sectionText}{common.GlobalConfig.LINE_ENDS}")

if writeFunction:
# Write the function itself
f.write(self.function.disassemble(migrate=self.hasRodataSyms(), isSplittedSymbol=True))
f.write(disassembledFunction)

def getName(self) -> str:
assert self.function is not None or self.hasRodataSyms()
Expand Down

0 comments on commit 918e9a1

Please sign in to comment.