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

Stack structure detection without leveraging type information #5918

Open
xusheng6 opened this issue Sep 10, 2024 · 1 comment
Open

Stack structure detection without leveraging type information #5918

xusheng6 opened this issue Sep 10, 2024 · 1 comment
Labels
Component: Core Issue needs changes to the core Effort: High Issue should take > 1 month Impact: Medium Issue is impactful with a bad, or no, workaround Type: Enhancement Issue is a small enhancement to existing functionality

Comments

@xusheng6
Copy link
Member

xusheng6 commented Sep 10, 2024

Consider the following C code:

#include <stdio.h>

struct foobar
{
    int a;
    int b;
    int c;
};

int func(struct foobar* f)
{
    return f->a + f->b + f->c;
}

int main()
{
    struct foobar f;
    f.a = 123;
    f.b = 456;
    f.c = 789;
    int result = func(&f);
    printf("result: %d\n", result);
}

The default decompilation looks like this:

Screenshot 2024-09-10 at 2 17 14 PM

Since the analysis does not see the var_1c, var_18, and var_14 all belong to a structure, it marks the latter two as dead store. While the result is reasonable, it would be great if we can actually detect the case and create the stack structure.

Note this is different from #773, when we already know the type of the _func function -- that is just a type propagation. This issue suggests the capacity to detect the structure even if the function type is not set

@xusheng6
Copy link
Member Author

stack_struct.zip

@xusheng6 xusheng6 changed the title Stack structure detection Stack structure detection without leveraging type information Sep 10, 2024
@xusheng6 xusheng6 added Type: Enhancement Issue is a small enhancement to existing functionality Component: Core Issue needs changes to the core Effort: High Issue should take > 1 month Impact: Medium Issue is impactful with a bad, or no, workaround labels 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: High Issue should take > 1 month Impact: Medium Issue is impactful with a bad, or no, workaround Type: Enhancement Issue is a small enhancement to existing functionality
Projects
None yet
Development

No branches or pull requests

1 participant