das-labor / panopticon

A libre cross-platform disassembler.
https://panopticon.re
GNU General Public License v3.0
1.43k stars 78 forks source link

Error in control flow graph. #349

Open duesee opened 6 years ago

duesee commented 6 years ago

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