-
Notifications
You must be signed in to change notification settings - Fork 265
Description
Version and Platform (required):
- Binary Ninja Version: 5.2.8161-dev, 98bf34dd
- OS: macos
- OS Version: 15.6
- CPU Architecture: arm64
Bug Description:
The Python binding for DataVariable changes the symbol's type when changing the variable's name.
The name setter delegates to the symbol setter:
@name.setter
def name(self, value: str) -> None:
self.symbol = valueThe symbol setter looks like so:
@symbol.setter
def symbol(self, value: Optional[Union[str, '_types.CoreSymbol']]) -> None: # type: ignore
if value is None or value == "":
if self.symbol is not None:
self.view.undefine_user_symbol(self.symbol)
elif isinstance(value, (str, _types.QualifiedName)):
symbol = _types.Symbol(SymbolType.DataSymbol, self.address, str(value))
self.view.define_user_symbol(symbol)You can see when assigning a string it hard-codes the symbol type to SymbolType.DataSymbol, irrespective of what the existing symbol type is.
Steps To Reproduce:
- Open a binary. I used
/usr/libexec/syspolicyd, but it shouldn't matter so long as it has external symbols. - Run the following in the Python console:
var = [var for var in bv.data_vars.values() if var.symbol and var.symbol.type == SymbolType.ExternalSymbol][0] bv.navigate("Linear:%s" % bv.view_type, var.address) var.symbol.type var.name = var.name var.symbol.type
Expected Behavior:
Nothing should change, and the result of var.symbol.type should display as <SymbolType.ExternalSymbol: 5> before and after the name change.
Actual Behavior:
The symbol type changes to <SymbolType.DataSymbol: 3> and the rendering of the symbol updates in the linear view. In my case it changes from orange to blue.
Additional Information:
This was originally noticed due to it causing a poor interaction between the Swift Demangler plug-in, available via the plug-in manager, and the Pseudo Objective-C language representation. The Pseudo Objective-C language representation checks the symbol types in a few places and does not expect imported symbols, for instance, to be reported as being ordinary data symbols.