Pointers are created as 64bit
Pointers are created as 64 bit, instead of the expected 16bit, whether created via the UI with "y" or programmatically like this:
type = self.parse_type_string("void *vector");
self.define_data_var(0x8000, type[0])
Note that creating pointers via the O hotkey (Type>Make Pointer in context menu) will create appropriately sized 16-bit pointers, and that the architecture correctly specifies the address size as 2 bytes:
>>> bv.arch
<arch: 6502>
>>> bv.arch.address_size
2 / 0x2
Unfortunately, the width of pointer types parsed from strings will be 8 bytes due to a couple of factors in the interface to our clang type parser which depends on fixing this issue: https://github.com/Vector35/binaryninja-api/issues/4868
However, it is worth pointing out that this works "correctly" for the arch:
>>> Type.pointer(bv.arch, bv.parse_type_string('void')[0])
<type: immutable:PointerTypeClass 'void*'>
>>> _.width
2 / 0x2
As another workaround, defining or setting a variable in the UI using type void in the dialog, and then letting Binary Ninja turn it into a pointer, results in a proper-width pointer:
https://github.com/Vector35/6502/assets/12259536/b7c9863f-d7ab-49ff-9380-0697eabd9b31
Thanks for the workarounds! Have checked in a change to the module using this.
Couple updates on this from a few weeks ago:
- You can now specify custom type parser arguments with the new Platform::AdjustTypeParserInput callback, which you can use to give clang a
--target=etcif your target is supported (or if a different, supported target has similar type sizes) - Even if the platform pointers are not the size you expected, you can annotate a differently-sized pointer with the new
void* __ptr16syntax (or custom size withvoid* __ptr_width(2))