Skip to content

Commit

Permalink
Merge pull request #165 from Decompollaborate/develop
Browse files Browse the repository at this point in the history
1.26.0
  • Loading branch information
AngheloAlf authored May 21, 2024
2 parents ad128fa + e3e3481 commit f772ac2
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.26.0] - 2024-05-21

### Added

- Add `visibility` attribute to symbols.
- Allows to specify custom visibility, like `weak` or `local`, to each symbol.
- Read symbol binding from elf files as `visibility` automatically.

## [1.25.1] - 2024-05-03

### Fixed
Expand Down Expand Up @@ -1515,6 +1523,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.26.0]: https://github.com/Decompollaborate/spimdisasm/compare/1.25.1...1.26.0
[1.25.1]: https://github.com/Decompollaborate/spimdisasm/compare/1.25.0...1.25.1
[1.25.0]: https://github.com/Decompollaborate/spimdisasm/compare/1.24.3...1.25.0
[1.24.3]: https://github.com/Decompollaborate/spimdisasm/compare/1.24.2...1.24.3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ If you use a `requirements.txt` file in your repository, then you can add
this library with the following line:

```txt
spimdisasm>=1.25.1,<2.0.0
spimdisasm>=1.26.0,<2.0.0
```

### Development version
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.26.0"
description = "MIPS disassembler"
readme = "README.md"
license = {file = "LICENSE"}
Expand Down
2 changes: 1 addition & 1 deletion spimdisasm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from __future__ import annotations

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

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|None = None


@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 is not None:
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")
4 changes: 4 additions & 0 deletions spimdisasm/elfObjDisasm/ElfObjDisasmInternals.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ def insertSymtabIntoContext(context: common.Context, symbolTable: elf32.Elf32Sym
if contextSym is not None:
contextSym.sectionType = sectType

bind = elf32.Elf32SymbolTableBinding.fromValue(symEntry.stBind)
if bind is not None:
contextSym.visibility = bind.name

def insertDynsymIntoContext(context: common.Context, symbolTable: elf32.Elf32Syms, stringTable: elf32.Elf32StringTable) -> None:
for symEntry in symbolTable:
if symEntry.value == 0 or symEntry.shndx == 0:
Expand Down

0 comments on commit f772ac2

Please sign in to comment.