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

Error in control flow graph. #349

Open
duesee opened this issue Aug 9, 2018 · 0 comments
Open

Error in control flow graph. #349

duesee opened this issue Aug 9, 2018 · 0 comments

Comments

@duesee
Copy link

duesee commented Aug 9, 2018

I played around with panopticon and noticed that for this C code...

int sum_while(int max) {
    int sum = 0;
    int i = 1;

    while (i <= max) {
        sum += i;
        i += 1;
    }

    return sum;
}

... i.e. ...

0000118d <sum_for>:
    118d:   55                      push   ebp
    118e:   89 e5                   mov    ebp,esp
    1190:   83 ec 10                sub    esp,0x10
    1193:   e8 b1 00 00 00          call   1249 <__x86.get_pc_thunk.ax>
    1198:   05 68 2e 00 00          add    eax,0x2e68
    119d:   c7 45 f8 00 00 00 00    mov    DWORD PTR [ebp-0x8],0x0
    11a4:   c7 45 fc 01 00 00 00    mov    DWORD PTR [ebp-0x4],0x1
    11ab:   eb 0a                   jmp    11b7 <sum_for+0x2a>
    11ad:   8b 45 fc                mov    eax,DWORD PTR [ebp-0x4]
    11b0:   01 45 f8                add    DWORD PTR [ebp-0x8],eax
    11b3:   83 45 fc 01             add    DWORD PTR [ebp-0x4],0x1
    11b7:   8b 45 fc                mov    eax,DWORD PTR [ebp-0x4]
    11ba:   3b 45 08                cmp    eax,DWORD PTR [ebp+0x8]
    11bd:   7e ee                   jle    11ad <sum_for+0x20>
    11bf:   8b 45 f8                mov    eax,DWORD PTR [ebp-0x8]
    11c2:   c9                      leave
    11c3:   c3                      ret

... the control flow graph is wrong. It looks like this...
bildschirmfoto von 2018-08-09 20-04-38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant