Monday, December 14, 2009

Generating readable assembly with gcc

Lifted from here.

>
gcc -g -c test.c
> objdump -d -M intel -S test.o

test
.o: file format elf32-i386


Disassembly of section .text:

00000000
:
#include

int main(void)
{
0: 55 push ebp
1: 89 e5 mov ebp,esp
3: 83 e4 f0 and esp,0xfffffff0
6: 83 ec 10 sub esp,0x10
puts
("test");
9: c7 04 24 00 00 00 00 mov DWORD PTR [esp],0x0
10: e8 fc ff ff ff call 11 <main+0x11>

return 0;
15: b8 00 00 00 00 mov eax,0x0
}
1a: c9 leave
1b: c3 ret

No comments:

Blog Archive