Skip to content

Commit

Permalink
Merge pull request #125 from Decompollaborate/develop
Browse files Browse the repository at this point in the history
1.15.0
  • Loading branch information
AngheloAlf committed Jul 3, 2023
2 parents de63bc2 + 4f36653 commit ed12bf7
Show file tree
Hide file tree
Showing 26 changed files with 637 additions and 229 deletions.
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.14.3"
version = "1.15.0"
description = "MIPS disassembler"
# license = "MIT"
readme = "README.md"
Expand Down
18 changes: 9 additions & 9 deletions spimdisasm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

from __future__ import annotations

__version_info__ = (1, 14, 3)
__version_info__ = (1, 15, 0)
__version__ = ".".join(map(str, __version_info__))
__author__ = "Decompollaborate"

from . import common
from . import elf32
from . import mips
from . import common as common
from . import elf32 as elf32
from . import mips as mips

# Front-end scripts
from . import frontendCommon
from . import disasmdis
from . import rspDisasm
from . import elfObjDisasm
from . import singleFileDisasm
from . import frontendCommon as frontendCommon
from . import disasmdis as disasmdis
from . import rspDisasm as rspDisasm
from . import elfObjDisasm as elfObjDisasm
from . import singleFileDisasm as singleFileDisasm
56 changes: 50 additions & 6 deletions spimdisasm/common/ContextSymbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def getAllTypes(self) -> set[str]:


gKnownTypes: set[str] = {
"asciz", "char", "char*"
"asciz", "char", "char*", "String", "Char"
}

for kind in gAccessKinds.values():
Expand Down Expand Up @@ -122,6 +122,8 @@ class ContextSymbol:

isMaybeString: bool = False

isMaybePascalString: bool = False

referenceCounter: int = 0
"How much this symbol is referenced by something else"

Expand Down Expand Up @@ -205,6 +207,11 @@ def hasNoType(self) -> bool:
currentType = self.getTypeSpecial()
return (currentType is None or currentType == "") and self.accessType is None

def hasOnlyAutodetectedType(self) -> bool:
if self.userDeclaredType is not None and self.userDeclaredType != "":
return False
return (self.autodetectedType is not None and self.autodetectedType != "") or self.accessType is not None


def isTrustableFunction(self, rsp: bool=False) -> bool:
"""Checks if the function symbol should be trusted based on the current disassembler settings"""
Expand Down Expand Up @@ -263,16 +270,53 @@ def isShort(self) -> bool:
def isString(self) -> bool:
currentType = self.getTypeSpecial()

if self.sectionType == FileSectionType.Rodata:
stringGuesserLevel = GlobalConfig.RODATA_STRING_GUESSER_LEVEL
else:
stringGuesserLevel = GlobalConfig.DATA_STRING_GUESSER_LEVEL

if currentType in {"char", "char*", "asciz"}:
return True
if not self.isMaybeString:
return False
if not GlobalConfig.STRING_GUESSER:

if stringGuesserLevel < 1:
return False
if self.hasNoType(): # no type information, let's try to guess

if self.hasNoType():
# no type information, let's try to guess
return True

if self.hasOnlyAutodetectedType():
if stringGuesserLevel >= 4:
# There's autodetected type information, but we are going to ignore it and try to guess
return True
return False

def isPascalString(self) -> bool:
currentType = self.getTypeSpecial()

if self.sectionType == FileSectionType.Rodata:
stringGuesserLevel = GlobalConfig.PASCAL_RODATA_STRING_GUESSER_LEVEL
else:
stringGuesserLevel = GlobalConfig.PASCAL_DATA_STRING_GUESSER_LEVEL

if currentType in {"String", "Char"}:
return True
if GlobalConfig.AGGRESSIVE_STRING_GUESSER:
if not self.isMaybePascalString:
return False

if stringGuesserLevel < 1:
return False

if self.hasNoType():
# no type information, let's try to guess
return True

if self.hasOnlyAutodetectedType():
if stringGuesserLevel >= 4:
# There's autodetected type information, but we are going to ignore it and try to guess
return True
return False

def isFloat(self) -> bool:
Expand Down Expand Up @@ -519,7 +563,7 @@ def getCsvHeader() -> str:
output += "autodetectedSize,"
output += "getSize,getVrom,sectionType,"

output += "isDefined,isUserDeclared,isAutogenerated,isMaybeString,"
output += "isDefined,isUserDeclared,isAutogenerated,isMaybeString,isMaybePascalString,"
output += "referenceCounter,overlayCategory,unknownSegment,"
output += "isGot,isGotGlobal,isGotLocal,gotIndex,"
output += "firstLoAccess,isAutogeneratedPad,isElfNotype"
Expand All @@ -544,7 +588,7 @@ def toCsv(self) -> str:
else:
output += f"0x{self.autodetectedSize:X},"
output += f"0x{self.getSize():X},0x{self.getVrom():X},{self.sectionType.toStr()},"
output += f"{self.isDefined},{self.isUserDeclared},{self.isAutogenerated},{self.isMaybeString},"
output += f"{self.isDefined},{self.isUserDeclared},{self.isAutogenerated},{self.isMaybeString},{self.isMaybePascalString},"
output += f"{self.referenceCounter},{self.overlayCategory},{self.unknownSegment},"
output += f"{self.isGot},{self.isGotGlobal},{self.isGotLocal},{self.gotIndex},"
output += f"{self.firstLoAccess},{self.isAutogeneratedPad()},{self.isElfNotype}"
Expand Down
Loading

0 comments on commit ed12bf7

Please sign in to comment.