Saying that I have an executable binary file, which comes from the compilation of some C code and its name is a.out
.
As we know, we can disassemble it with the command objdump -d a.out
. Here is an example:
00000000004006b6 <main>:
4006b6: 55 push %rbp
4006b7: 48 89 e5 mov %rsp,%rbp
4006ba: 89 7d ec mov %edi,-0x14(%rbp)
4006bd: 48 89 75 e0 mov %rsi,-0x20(%rbp)
4006c1: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%rbp)
4006c8: c7 45 f8 02 00 00 00 movl $0x2,-0x8(%rbp)
4006cf: 8b 55 f4 mov -0xc(%rbp),%edx
4006d2: 8b 45 f8 mov -0x8(%rbp),%eax
4006d5: 01 d0 add %edx,%eax
4006d7: 89 45 fc mov %eax,-0x4(%rbp)
...
...
Now I want to know if we can list the C code corresponding to the disassembly, meaning that something as below:
4006c1: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%rbp) // int i = 1;
4006c8: c7 45 f8 02 00 00 00 movl $0x2,-0x8(%rbp) // int j = 2;
In a word, I know that movl $0x2,-0x8(%rbp)
is to assign the integer 2
to a variable, but as you see this is not very clear, I'm thinking if there are some way to translate movl $0x2,-0x8(%rbp)
into int j = 2
automatically and immediately, it would be very helpful.