Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
927 stars 209 forks source link

ARM64 assembler ignores address of assembled instruction. #4563

Closed lwerdna closed 1 year ago

lwerdna commented 1 year ago

Version and Platform (required): 3.5

Bug Description: The assembler is ignore the address at which the assembling should occur.

Steps To Reproduce:

  1. Run BinaryNinja
  2. File -> New Binary Data
  3. Enter bytes: 1f 20 03 d5 1f 20 03 d5 1f 20 03 d5 1f 20 03 d5 (four nop instructions)
  4. Create aarch64 function at address 0 (hotkey "P")
  5. With cursor at address 0, Edit -> Assemble, then "bl 0x1000" it emits encoding 0x00040094
  6. With cursor at address 4, Edit -> Assemble, then "bl 0x1000" it emits encoding 0x00040094

image

Expected Behavior: The assembled instruction is PC-relative, so it should not have the same encoding. The second instruction at address 4 should be encoded 0xff030094.

lwerdna commented 1 year ago

Thank you for the bug report. Unfortunately this is a limitation of LLVM which we are using for many of our assemblers.

The recommended workaround is to install and use the keypatch plugin from the plugin manager:

Screen Shot 2023-08-20 at 4 58 17 PM

assemble-plugin

In the future we will release a more official plugin.

BrentDaMage commented 1 year ago

Dude are you okay?

psifertex commented 1 year ago

We use public issues to relate the state of internal discussions on features and fixes quite frequently. It's not uncommon to see one Vector35 person post an issue and end up resolving it differently after we've talked about it in more detail internally.

In this case I think Andrew was posting the issue on behalf of someone else originally who he is thanking which does sound a bit strange without that context. :-)

lwerdna commented 1 year ago

Dude are you okay?

Hah while I do sometimes talk to myself, what's happening is someone will briefly report a problem on slack, and I'll promote it to an official github issue and give them the link so they can track its status. I assume they're reading it, or will read it when it's closed. So yes, as psifertex explained, this is an issue posted on behalf of someone else.