diff --git a/CHANGELOG.md b/CHANGELOG.md index c6d8a4ed..1b356db8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/README.md b/README.md index 90db48d0..51681e47 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/pyproject.toml b/pyproject.toml index e1129645..a77f9d46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"} diff --git a/spimdisasm/__init__.py b/spimdisasm/__init__.py index 824635a5..492f862e 100644 --- a/spimdisasm/__init__.py +++ b/spimdisasm/__init__.py @@ -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" diff --git a/spimdisasm/mips/symbols/MipsSymbolBase.py b/spimdisasm/mips/symbols/MipsSymbolBase.py index a36595bf..3a18dbea 100644 --- a/spimdisasm/mips/symbols/MipsSymbolBase.py +++ b/spimdisasm/mips/symbols/MipsSymbolBase.py @@ -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): diff --git a/spimdisasm/mips/symbols/MipsSymbolRodata.py b/spimdisasm/mips/symbols/MipsSymbolRodata.py index 1da08074..1cbfc26e 100644 --- a/spimdisasm/mips/symbols/MipsSymbolRodata.py +++ b/spimdisasm/mips/symbols/MipsSymbolRodata.py @@ -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