diff --git a/CHANGELOG.md b/CHANGELOG.md index ff75c5ce..f5c150d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/spimdisasm/mips/symbols/MipsSymbolBase.py b/spimdisasm/mips/symbols/MipsSymbolBase.py index df95c05a..ff74b990 100644 --- a/spimdisasm/mips/symbols/MipsSymbolBase.py +++ b/spimdisasm/mips/symbols/MipsSymbolBase.py @@ -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):