Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve lifting of ARM64 CCMP instruction to compound if statement #5915

Open
raminri opened this issue Sep 10, 2024 · 0 comments
Open

Improve lifting of ARM64 CCMP instruction to compound if statement #5915

raminri opened this issue Sep 10, 2024 · 0 comments
Labels
Component: Core Issue needs changes to the core Effort: Low Issue should take < 1 week Impact: Low Issue is a papercut or has a good, supported workaround Type: Enhancement Issue is a small enhancement to existing functionality

Comments

@raminri
Copy link

raminri commented Sep 10, 2024

Version and Platform (required):

  • Binary Ninja Version: 4.2.6042-dev (e875db7b)
  • OS: Windows
  • OS Version: 10
  • CPU Architecture: x64

Bug Description:
This C pattern:

if (c == '\n' || c == '\r')
{
  // ...
}
// ...

Can compile into this ARM assembly:

00000000  3f280071   cmp     w1, #0xa
00000004  24184d7a   ccmp    w1, #0xd, #0x4, ne
00000008  00050054   b.eq    0xa8 

This ends up decompiling into this HLIL:

00000004      bool z
00000004      
00000004      if (c != 0xa)
00000004          z = c == 0xd
00000004      else
00000004          z = true
00000004      
00000008      if (z)
00000008          jump(0xa8)
00000008      
00000008      jump(0xc)

Steps To Reproduce:
Please provide all steps required to reproduce the behavior:

  1. Create a new blank view with Ctrl+N
  2. Paste in the following bytes: 3f28007124184d7a00050054
  3. Create aarch64 function and view HLIL

Expected Behavior:
Should decompile into a more compact form, e.g. if (c == 0xa || c == 0xd).

@xusheng6 xusheng6 added Type: Enhancement Issue is a small enhancement to existing functionality Component: Core Issue needs changes to the core Impact: Low Issue is a papercut or has a good, supported workaround Effort: Low Issue should take < 1 week labels Sep 23, 2024
@xusheng6 xusheng6 changed the title Improve lifting of ARM64 CCMP instruction Improve lifting of ARM64 CCMP instruction to compound if statement Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Issue needs changes to the core Effort: Low Issue should take < 1 week Impact: Low Issue is a papercut or has a good, supported workaround Type: Enhancement Issue is a small enhancement to existing functionality
Projects
None yet
Development

No branches or pull requests

2 participants