Skip to content

Commit cc4d460

Browse files
authored
Merge pull request #129 from Decompollaborate/develop
1.15.4
2 parents a59f75c + 4cde2d5 commit cc4d460

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
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.15.3"
7+
version = "1.15.4"
88
description = "MIPS disassembler"
99
# license = "MIT"
1010
readme = "README.md"

spimdisasm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from __future__ import annotations
77

8-
__version_info__ = (1, 15, 3)
8+
__version_info__ = (1, 15, 4)
99
__version__ = ".".join(map(str, __version_info__))
1010
__author__ = "Decompollaborate"
1111

spimdisasm/mips/sections/MipsSectionText.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _findFunctions(self, instrsList: list[rabbitizer.Instruction]):
8484

8585
while index < nInstr:
8686
instr = instrsList[index]
87-
if not instr.isImplemented():
87+
if not instr.isImplemented() or not instr.isValid():
8888
isInstrImplemented = False
8989

9090
if functionEnded:
@@ -121,7 +121,7 @@ def _findFunctions(self, instrsList: list[rabbitizer.Instruction]):
121121
if index >= len(instrsList):
122122
break
123123
instr = instrsList[index]
124-
isInstrImplemented = instr.isImplemented()
124+
isInstrImplemented = instr.isImplemented() and instr.isValid()
125125

126126
currentVram = self.getVramOffset(instructionOffset)
127127
currentVrom = self.getVromOffset(instructionOffset)
@@ -140,7 +140,7 @@ def _findFunctions(self, instrsList: list[rabbitizer.Instruction]):
140140
if not instr.isJump(): # Make an exception for `j`
141141
break
142142
# make sure to not branch outside of the current function
143-
if not isLikelyHandwritten:
143+
if not isLikelyHandwritten and isInstrImplemented:
144144
j = len(funcsStartsList) - 1
145145
while j >= 0:
146146
if branchOffset + instructionOffset < 0:

spimdisasm/mips/symbols/MipsSymbolFunction.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,12 @@ def _processElfRelocSymbols(self):
143143
symbolVram += addressOffset
144144
else:
145145
symbolVram += instr.getProcessedImmediate()
146-
relocInfo.symbol = self.addSymbol(symbolVram, isAutogenerated=True)
146+
contextSym = self.getSymbol(symbolVram, tryPlusOffset=True)
147+
if contextSym is None:
148+
contextSym = self.addSymbol(symbolVram, isAutogenerated=True)
149+
relocInfo.symbol = contextSym
147150
relocInfo.symbol._isStatic = True
151+
relocInfo.addend = symbolVram - contextSym.vram
148152
elif offsetAddend is not None:
149153
# Addends for global symbols
150154
relocInfo.addend = offsetAddend

0 commit comments

Comments
 (0)