Skip to content

Commit

Permalink
Prevent generating labels for ignored symbols that are referenced by …
Browse files Browse the repository at this point in the history
…function calls
  • Loading branch information
AngheloAlf committed Sep 19, 2024
1 parent ea94ae3 commit 7f86bcd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Use `GlobalConfig.ASM_INDENTATION` and `GlobalConfig.ASM_INDENTATION_LABELS`
to disable this behavior.

### Fixed

- Prevent generating labels for ignored symbols that are referenced by function
calls (ie in a `jal`).

## [1.30.0] - 2024-09-10

### Changed
Expand Down
6 changes: 6 additions & 0 deletions spimdisasm/common/ContextSymbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ def getCsvHeader() -> str:
output += "isDefined,isUserDeclared,isAutogenerated,"
output += "isMaybeString,failedStringDecoding,isMaybePascalString,failedPascalStringDecoding,"
output += "referenceCounter,"
if False:
output += "referenceFunctions,"
output += "referenceSymbols,"
output += "parentFunction,"
output += "parentFileName,"
output += "inFileOffset,"
Expand Down Expand Up @@ -760,6 +763,9 @@ def toCsv(self) -> str:
output += f"{self.isDefined},{self.isUserDeclared},{self.isAutogenerated},"
output += f"{self.isMaybeString},{self.failedStringDecoding},{self.isMaybePascalString},{self.failedPascalStringDecoding},"
output += f"{self.referenceCounter},"
if False:
output += f"\"{','.join(x.getName() for x in self.referenceFunctions)}\","
output += f"\"{','.join(x.getName() for x in self.referenceSymbols)}\","

if self.parentFunction is not None:
output += f"{self.parentFunction.getName()},"
Expand Down
9 changes: 9 additions & 0 deletions spimdisasm/mips/symbols/MipsSymbolFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ def analyze(self) -> None:

# Branches
for instrOffset, targetBranchVram in self.instrAnalyzer.branchInstrOffsets.items():
if self.context.isAddressBanned(targetBranchVram):
continue

if common.GlobalConfig.INPUT_FILE_TYPE == common.InputFileType.ELF:
if self.getVromOffset(instrOffset) in self.context.globalRelocationOverrides:
# Avoid creating wrong symbols on elf files
Expand All @@ -442,6 +445,9 @@ def analyze(self) -> None:

# Function calls
for instrOffset, targetVram in self.instrAnalyzer.funcCallInstrOffsets.items():
if self.context.isAddressBanned(targetVram):
continue

if common.GlobalConfig.INPUT_FILE_TYPE == common.InputFileType.ELF:
if self.getVromOffset(instrOffset) in self.context.globalRelocationOverrides:
# Avoid creating wrong symbols on elf files
Expand Down Expand Up @@ -521,6 +527,9 @@ def analyze(self) -> None:

# Jump tables
for targetVram in self.instrAnalyzer.referencedJumpTableOffsets.values():
if self.context.isAddressBanned(targetVram):
continue

jumpTable = self.addJumpTable(targetVram, isAutogenerated=True)
jumpTable.parentFunction = self.contextSym
self.contextSym.jumpTables.add(jumpTable.vram, jumpTable)
Expand Down

0 comments on commit 7f86bcd

Please sign in to comment.