Skip to content

Commit

Permalink
Fix some function pointers not being properly identified
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Jun 26, 2024
1 parent c1a7798 commit ca776af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `elfObjDisasm`
- Fix wrong capitalization on elf symbol visibility.
- Fix symbol visibility not being used on some linked elfs.
- Fix some function pointers not being properly symbolized.
- Those function pointers may get wrongly identified as jumptables because the
jumptable pattern and the function pointer tail call pattern is similar.

## [1.26.0] - 2024-05-21

Expand Down
13 changes: 9 additions & 4 deletions spimdisasm/mips/symbols/MipsSymbolBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,18 @@ def getNthWordAsWords(self, i: int, canReferenceSymbolsWithAddends: bool=False,
if self.contextSym.isGot and common.GlobalConfig.GP_VALUE is not None:
labelAddr = common.GlobalConfig.GP_VALUE + rabbitizer.Utils.from2Complement(w, 32)
labelSym = self.getSymbol(labelAddr, tryPlusOffset=False)
if labelSym is not None and labelSym.getTypeSpecial() == common.SymbolSpecialType.jumptablelabel:
dotType = ".gpword"
if labelSym is not None:
labelType = labelSym.getTypeSpecial()
if labelType == common.SymbolSpecialType.jumptablelabel or labelType == common.SymbolSpecialType.function:
dotType = ".gpword"
else:
labelSym = self.getSymbol(w, tryPlusOffset=False)

if labelSym is not None and labelSym.getTypeSpecial() == common.SymbolSpecialType.jumptablelabel:
value = labelSym.getName()
if labelSym is not None:
labelType = labelSym.getTypeSpecial()
if labelType == common.SymbolSpecialType.jumptablelabel or labelType == common.SymbolSpecialType.function:
# We check for function references too because this symbol may have gotten wrongly identified as a jumptable because of tail call optimizations.
value = labelSym.getName()
else:
# This word could be a reference to a symbol
if not self.context.isAddressBanned(w):
Expand Down

0 comments on commit ca776af

Please sign in to comment.