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

Bitfields don't seem to decompile very well #1059

Closed
jrmuizel opened this issue Sep 24, 2019 · 2 comments
Closed

Bitfields don't seem to decompile very well #1059

jrmuizel opened this issue Sep 24, 2019 · 2 comments
Labels
Feature: Bitfields Reason: Duplicate This issue or pull request already exists Type: Enhancement New feature or request

Comments

@jrmuizel
Copy link
Contributor

Given a program like:

struct A {
        int a: 4;
        int b: 4;
        int c;
};

int test(struct A* v) {
        if (v->a == 4) {
                return 1;
        } else {
                return 2;
        }
}

which compiles to

push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
and    $0xf,%eax
cmp    $0x4,%al
jne    1d <test+0x1d>
mov    $0x1,%eax
jmp    22 <test+0x22>
mov    $0x2,%eax
pop    %rbp
retq

When A is defined to contain a bit field the decompiler produces:

undefined8 test(A *param_1)

{
  undefined8 uVar1;
  
  if ((*(byte *)param_1 & 0xf) == 4) {
    uVar1 = 1;
  }
  else {
    uVar1 = 2;
  }
  return uVar1;
}

vs

undefined8 test(Value *param_1)

{
  undefined8 uVar1;
  
  if ((param_1->a_and_b & 0xfU) == 4) {
    uVar1 = 1;
  }
  else {
    uVar1 = 2;
  }
  return uVar1;
}

when the fields are not separated into the appropriate bitfields.

@ryanmkurtz
Copy link
Collaborator

Full support for bitfield references within the decompiler is planned for a future release.

@ryanmkurtz
Copy link
Collaborator

Duplicate of #647.

@ryanmkurtz ryanmkurtz added the Reason: Duplicate This issue or pull request already exists label Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Bitfields Reason: Duplicate This issue or pull request already exists Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants