Skip to content

Commit

Permalink
Add symbol visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed May 20, 2024
1 parent ad128fa commit f0b2c0e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `visibility` attribute to symbols.
- Allows to specify custom visibility, like `weak` or `local`, to each symbol.

## [1.25.1] - 2024-05-03

### Fixed
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.25.1"
version = "1.25.2.dev0"
description = "MIPS disassembler"
readme = "README.md"
license = {file = "LICENSE"}
Expand Down
4 changes: 2 additions & 2 deletions spimdisasm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from __future__ import annotations

__version_info__: tuple[int, int, int] = (1, 25, 1)
__version__ = ".".join(map(str, __version_info__))# + ".dev0"
__version_info__: tuple[int, int, int] = (1, 25, 2)
__version__ = ".".join(map(str, __version_info__)) + ".dev0"
__author__ = "Decompollaborate"

from . import common as common
Expand Down
6 changes: 4 additions & 2 deletions spimdisasm/common/ContextSymbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ class ContextSymbol:

isMips1Double: bool = False

visibility: str = "global"


@property
def vram(self) -> int:
Expand Down Expand Up @@ -677,7 +679,7 @@ def getCsvHeader() -> str:
output += "overlayCategory,unknownSegment,"
output += "isGot,isGotGlobal,isGotLocal,gotIndex,accessedAsGpRel,"
output += "firstLoAccess,isAutogeneratedPad,autoCreatedPadMainSymbol,isElfNotype,"
output += "isAutocreatedSymFromOtherSizedSym,isMips1Double"
output += "isAutocreatedSymFromOtherSizedSym,isMips1Double,visibility"
return output

def toCsv(self) -> str:
Expand Down Expand Up @@ -723,7 +725,7 @@ def toCsv(self) -> str:
if self.autoCreatedPadMainSymbol is not None:
autoCreatedPadMainSymbolName = self.autoCreatedPadMainSymbol.getName()
output += f"{self.firstLoAccess},{self.isAutogeneratedPad()},{autoCreatedPadMainSymbolName},{self.isElfNotype},"
output += f"{self.isAutocreatedSymFromOtherSizedSym},{self.isMips1Double}"
output += f"{self.isAutocreatedSymFromOtherSizedSym},{self.isMips1Double},{self.visibility}"
return output


Expand Down
2 changes: 2 additions & 0 deletions spimdisasm/common/ElementBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def getLabelFromSymbol(self, sym: ContextSymbol|None, symName: str|None) -> str:
if label is None:
return ""
label += f" {symName or sym.getName()}"
if sym.visibility != "global":
label += f", {sym.visibility}"
if GlobalConfig.GLABEL_ASM_COUNT:
if self.index is not None:
label += f" # {self.index}"
Expand Down
2 changes: 2 additions & 0 deletions spimdisasm/common/SymbolsSegment.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,5 @@ def readSplatSymbolAddrs(self, filepath: Path) -> None:
allowBeReferenced = Utils.getMaybeBooleyFromMaybeStr(pairs.get("allow_be_referenced"))
if allowBeReferenced is not None:
contextSym.allowedToBeReferenced = allowBeReferenced

contextSym.visibility = pairs.get("visibility", contextSym.visibility)

0 comments on commit f0b2c0e

Please sign in to comment.