
I will use google before asking dumb questions...
A software engineer from Chennai(India) specializing application development for embedded systems. Presently working on digital cinema projection systems and related products.
#include
int main ()
{
return 0;
}
g++ test.cpp -o testand objdump of assembly
objdump -d testlets analyze the code
08048364:
8048364: 55 push %ebp
8048365: 89 e5 mov %esp,%ebp
8048367: 83 ec 08 sub $0x8,%esp
804836a: 83 e4 f0 and $0xfffffff0,%esp
804836d: b8 00 00 00 00 mov $0x0,%eax
8048372: 29 c4 sub %eax,%esp
8048374: b8 00 00 00 00 mov $0x0,%eax
8048379: c9 leave
804837a: c3 ret
804837b: 90 nop
8048364: 55 push %ebpthis belongs to function prolog
8048365: 89 e5 mov %esp,%ebp
8048374: b8 00 00 00 00 mov $0x0,%eaxthis is function epilog
8048379: c9 leave
804837a: c3 ret
8048367: 83 ec 08 sub $0x8,%espafter a severe search i found that these are lines produced by compiler for memory alignment. also i found we can easily turn of this by including -Os (optimise for size) compiler options
804836a: 83 e4 f0 and $0xfffffff0,%esp
804836d: b8 00 00 00 00 mov $0x0,%eax
8048372: 29 c4 sub %eax,%esp
g++ -Os test.cpp -o testsurprised??????? yea even i felt the same.
objdump -d test
...
08048364:
8048364: 55 push %ebp
8048365: 89 e5 mov %esp,%ebp
8048367: 31 c0 xor %eax,%eax
8048369: c9 leave
804836a: c3 ret
804836b: 90 nop
...