Skip to content

Commit e69fe70

Browse files
authored
Merge pull request #186 from Decompollaborate/develop
1.33.0
2 parents 5680895 + 992a7d7 commit e69fe70

File tree

6 files changed

+50
-10
lines changed

6 files changed

+50
-10
lines changed

CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.33.0] - 2025-03-10
11+
12+
### Added
13+
14+
- `SectionText.setGpRelHack`: Allows updating the gpRelHack value after anlyzing
15+
the section.
16+
17+
### Changed
18+
19+
- Change where `.size` directive and end label is emitted on functions with no
20+
user-declared size.
21+
- The directives are now emitted before the function's trailing padding.
22+
- Allow using reloc `MIPS_NONE` on `jal` and `j` instructions.
23+
24+
### Fixed
25+
26+
- `gpRelHack` fix:
27+
- Avoid emitting multiple `gp_rel:` comments.
28+
1029
## [1.32.4] - 2025-03-03
1130

1231
### Fixed
@@ -1764,6 +1783,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
17641783
- Version 1.0.0
17651784

17661785
[unreleased]: https://github.com/Decompollaborate/spimdisasm/compare/master...develop
1786+
[1.33.0]: https://github.com/Decompollaborate/spimdisasm/compare/1.32.4...1.33.0
17671787
[1.32.4]: https://github.com/Decompollaborate/spimdisasm/compare/1.32.3...1.32.4
17681788
[1.32.3]: https://github.com/Decompollaborate/spimdisasm/compare/1.32.2...1.32.3
17691789
[1.32.2]: https://github.com/Decompollaborate/spimdisasm/compare/1.32.1...1.32.2

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ If you use a `requirements.txt` file in your repository, then you can add
6969
this library with the following line:
7070

7171
```txt
72-
spimdisasm>=1.32.4,<2.0.0
72+
spimdisasm>=1.33.0,<2.0.0
7373
```
7474

7575
### Development version

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[project]
55
name = "spimdisasm"
66
# Version should be synced with spimdisasm/__init__.py
7-
version = "1.32.4"
7+
version = "1.33.0"
88
description = "MIPS disassembler"
99
readme = "README.md"
1010
license = {file = "LICENSE"}

spimdisasm/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from __future__ import annotations
77

8-
__version_info__: tuple[int, int, int] = (1, 32, 4)
8+
__version_info__: tuple[int, int, int] = (1, 33, 0)
99
__version__ = ".".join(map(str, __version_info__))# + "-dev0"
1010
__author__ = "Decompollaborate"
1111

spimdisasm/mips/sections/MipsSectionText.py

+9
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,12 @@ def removeTrailingNops(self) -> bool:
419419
was_updated = True
420420

421421
return was_updated
422+
423+
def getGpRelHack(self) -> bool:
424+
return self.gpRelHack
425+
426+
def setGpRelHack(self, value: bool) -> None:
427+
self.gpRelHack = value
428+
for func in self.symbolList:
429+
assert isinstance(func, symbols.SymbolFunction)
430+
func.gpRelHack = value

spimdisasm/mips/symbols/MipsSymbolFunction.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,15 @@ def _getImmOverrideForInstruction(self, instr: rabbitizer.Instruction, instrOffs
709709
return None, None
710710

711711
relocInfo = self.getReloc(instrOffset, instr)
712-
if relocInfo is not None and not relocInfo.isRelocNone():
713-
ignoredRelocs = set()
714-
if self.gpRelHack:
715-
ignoredRelocs.add(common.RelocType.MIPS_GPREL16)
716-
return relocInfo.getNameWithReloc(isSplittedSymbol=isSplittedSymbol, ignoredRelocs=ignoredRelocs), relocInfo
712+
if relocInfo is not None:
713+
if relocInfo.isRelocNone():
714+
if instr.isJumpWithAddress():
715+
return f"0x{instr.getInstrIndexAsVram():08X}", relocInfo
716+
else:
717+
ignoredRelocs = set()
718+
if self.gpRelHack:
719+
ignoredRelocs.add(common.RelocType.MIPS_GPREL16)
720+
return relocInfo.getNameWithReloc(isSplittedSymbol=isSplittedSymbol, ignoredRelocs=ignoredRelocs), relocInfo
717721

718722
if instr.isBranch() or instr.isUnconditionalBranch():
719723
if common.GlobalConfig.IGNORE_BRANCHES:
@@ -811,8 +815,9 @@ def _emitInstruction(self, instr: rabbitizer.Instruction, instructionOffset: int
811815
line = line.replace("addiu ", "la ").replace(", $gp, ", ", ").replace(", $28, ", ", ")
812816

813817
endComment = self.endOfLineComment.get(instructionOffset//4, "")
814-
endComment += f" /* gp_rel: {immOverride} */"
815-
self.endOfLineComment[instructionOffset//4] = endComment
818+
if " /* gp_rel: " not in endComment:
819+
endComment += f" /* gp_rel: {immOverride} */"
820+
self.endOfLineComment[instructionOffset//4] = endComment
816821

817822
return f"{comment} {line}"
818823

@@ -867,7 +872,13 @@ def disassemble(self, migrate: bool=False, useGlobalLabel: bool=True, isSplitted
867872
self._generateRelocsFromInstructionAnalyzer()
868873

869874
symName = self.getName()
875+
870876
symSize = self.contextSym.getSize()
877+
if self.contextSym.userDeclaredSize is None:
878+
# Fixup symbol size to avoid counting padding as part of the symbol
879+
# on the emitted size and end directives.
880+
symSize -= 4 * self.countExtraPadding()
881+
871882
output += self.getSymbolAsmDeclaration(symName, useGlobalLabel)
872883

873884
wasLastInstABranch = False

0 commit comments

Comments
 (0)