Skip to content

Commit

Permalink
Merge pull request #155 from Decompollaborate/develop
Browse files Browse the repository at this point in the history
1.23.1
  • Loading branch information
AngheloAlf authored Mar 22, 2024
2 parents df1b4a7 + 0b1217a commit dd6759d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 44 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.23.1] - 2024-03-22

### Fixed

- Fix rodata symbols referencing symbols that it should not reference.
- Symbols like functions with addends, branch labels (not to be confused with
jumptable labels), etc.

## [1.23.0] - 2024-03-19

### Added
Expand Down Expand Up @@ -1447,6 +1455,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Version 1.0.0

[unreleased]: https://github.com/Decompollaborate/spimdisasm/compare/master...develop
[1.23.1]: https://github.com/Decompollaborate/spimdisasm/compare/1.23.1...1.23.1
[1.23.0]: https://github.com/Decompollaborate/spimdisasm/compare/1.22.0...1.23.0
[1.22.0]: https://github.com/Decompollaborate/spimdisasm/compare/1.21.1...1.22.0
[1.21.0]: https://github.com/Decompollaborate/spimdisasm/compare/1.20.1...1.21.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ If you use a `requirements.txt` file in your repository, then you can add
this library with the following line:

```txt
spimdisasm>=1.23.0,<2.0.0
spimdisasm>=1.23.1,<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.23.0"
version = "1.23.1"
description = "MIPS disassembler"
readme = "README.md"
license = {file = "LICENSE"}
Expand Down
2 changes: 1 addition & 1 deletion spimdisasm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from __future__ import annotations

__version_info__: tuple[int, int, int] = (1, 23, 0)
__version_info__: tuple[int, int, int] = (1, 23, 1)
__version__ = ".".join(map(str, __version_info__))
__author__ = "Decompollaborate"

Expand Down
17 changes: 17 additions & 0 deletions spimdisasm/mips/symbols/MipsSymbolBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,25 @@ def getNthWordAsWords(self, i: int, canReferenceSymbolsWithAddends: bool=False,
contextSym = self.getSymbol(relocVram, checkUpperLimit=False)
if contextSym is not None:
value = contextSym.getSymbolPlusOffset(relocVram)
wordRel = relocInfo.relocType.getWordRel()
if wordRel is not None:
dotType = wordRel
else:
value = relocInfo.getName(isSplittedSymbol=isSplittedSymbol)
wordRel = relocInfo.relocType.getWordRel()
if wordRel is not None:
dotType = wordRel
elif self.contextSym.isJumpTable():
if self.contextSym.isGot and common.GlobalConfig.GP_VALUE is not None:
labelAddr = common.GlobalConfig.GP_VALUE + rabbitizer.Utils.from2Complement(w, 32)
labelSym = self.getSymbol(labelAddr, tryPlusOffset=False)
if labelSym is not None and labelSym.getTypeSpecial() == common.SymbolSpecialType.jumptablelabel:
dotType = ".gpword"
else:
labelSym = self.getSymbol(w, tryPlusOffset=False)

if labelSym is not None and labelSym.getTypeSpecial() == common.SymbolSpecialType.jumptablelabel:
value = labelSym.getName()
else:
# This word could be a reference to a symbol
if not self.context.isAddressBanned(w):
Expand Down
41 changes: 0 additions & 41 deletions spimdisasm/mips/symbols/MipsSymbolRodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,44 +114,3 @@ def countExtraPadding(self) -> int:
break
count += 1
return count

def getNthWord(self, i: int, canReferenceSymbolsWithAddends: bool=False, canReferenceConstants: bool=False, isSplittedSymbol: bool=False) -> tuple[str, int]:
localOffset = 4*i
w = self.words[i]
vrom = self.getVromOffset(localOffset)

label = ""
rodataWord: int|None = w
value: str = f"0x{w:08X}"

dotType = ".word"
skip = 0

relocInfo = self.context.globalRelocationOverrides.get(vrom)
if relocInfo is not None:
if relocInfo.staticReference is not None:
relocVram = relocInfo.staticReference.sectionVram + w
labelSym = self.getSymbol(relocVram, tryPlusOffset=False)
if labelSym is not None:
relocInfo.symbol = labelSym.getName()
comment = self.generateAsmLineComment(localOffset, rodataWord)
return f"{label}{comment} {relocInfo.getNameWithReloc(isSplittedSymbol=isSplittedSymbol)}{common.GlobalConfig.LINE_ENDS}", skip

if self.contextSym.isJumpTable():
if self.contextSym.isGot and common.GlobalConfig.GP_VALUE is not None:
labelAddr = common.GlobalConfig.GP_VALUE + rabbitizer.Utils.from2Complement(w, 32)
labelSym = self.getSymbol(labelAddr, tryPlusOffset=False)
if labelSym is not None and labelSym.getTypeSpecial() == common.SymbolSpecialType.jumptablelabel:
dotType = ".gpword"
else:
labelSym = self.getSymbol(w, tryPlusOffset=False)

if labelSym is not None and labelSym.getTypeSpecial() == common.SymbolSpecialType.jumptablelabel:
value = labelSym.getName()
else:
labelSym = self.getSymbol(w, tryPlusOffset=canReferenceSymbolsWithAddends)
if labelSym is not None and not self.context.isAddressBanned(labelSym.vram):
value = labelSym.getSymbolPlusOffset(w)

comment = self.generateAsmLineComment(localOffset, rodataWord)
return f"{label}{comment} {dotType} {value}{common.GlobalConfig.LINE_ENDS}", skip

0 comments on commit dd6759d

Please sign in to comment.