binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

[RV32] Very bad decompilation of simple getchar function

Open ozoromo opened this issue 2 months ago • 0 comments

Version and Platform (required):

  • Binary Ninja Version: 5.2.8614
  • Edition: Non-Commercial
  • OS: NixOs
  • OS Version: 25.11
  • CPU Architecture: x64

Bug Description: I have the simple function getchar(char* c) with the following reasonably simple assembly code:

Image

That:

  • saves the incoming buffer from a0 into a5
  • sets a0 to the getchar syscall
  • returns immediately if the syscall gave a non 0 exit status
  • saves the char into the buffer and exits otherwise

However the HLIL and pseudo C de-compilations are very confusing:

HLIL: Image

Pseudo C:

Image

Expected Behavior: Binany ninja should understand that a0 is the only incoming register in this function and that it therefore only takes one Argument.

Screenshots/Video Recording: The screenshots are placed in their appropriate place in the issue description.

Binary: glow circle serves neatly base offset is 0x20000000

ozoromo avatar Dec 09 '25 10:12 ozoromo