So here's a code I'm disassembling using GDB:
#include
int main()
{
int i;
for (i=0; i <10;i++)
{
printf("%s", "Hello World!\n");
}
return 0;
}
A simple code that simply prints out hello world, so what I did was disassemble the main function and set a break at main to get this:
0x0000000000400536 <+0>: push rbp
0x0000000000400537 <+1>: mov rbp,rsp
0x000000000040053a <+4>: sub rsp,0x10
=> 0x000000000040053e <+8>: mov DWORD PTR [rbp-0x4],0x0
0x0000000000400545 <+15>: jmp 0x400555
0x0000000000400547 <+17>: mov edi,0x400600
0x000000000040054c <+22>: call 0x400410
0x0000000000400551 <+27>: add DWORD PTR [rbp-0x4],0x1
0x0000000000400555 <+31>: cmp DWORD PTR [rbp-0x4],0x9
0x0000000000400559 <+35>: jle 0x400547
0x000000000040055b <+37>: mov eax,0x0
0x0000000000400560 <+42>: leave
0x0000000000400561 <+43>: ret
so when I examine the stack pointer register by running:
(gdb) x/16x $rsp
I get this as an output:
0x7fffffffdb90: 0xffffdc80 0x00007fff 0x00000000 0x00000000
0x7fffffffdba0: 0x00400570 0x00000000 0x26c20700 0x00000031
0x7fffffffdbb0: 0xffffdc88 0x00007fff 0xffffdc88 0x00007fff
0x7fffffffdbc0: 0x00000000 0x00000001 0x00400536 0x00000000
I need help can someone explain to me what all of this is?