I am kind of confused by the latest version of gcc. A simple piece of code is compiled:
int main()
{
char buffer[1];
scanf("%s",buffer);
printf("You Entered %s\n", buffer );
return 0;
}
When I dissemble the func, this is what i find :
(gdb) disas main
Dump of assembler code for function main:
0x0804846d <+0>: push %ebp
0x0804846e <+1>: mov %esp,%ebp
0x08048470 <+3>: and $0xfffffff0,%esp
0x08048473 <+6>: sub $0x20,%esp
0x08048476 <+9>: lea 0x1f(%esp),%eax
0x0804847a <+13>: mov %eax,0x4(%esp)
...........................
My question is why do we subtract 0x20 i.e 32 bytes, when I allocate just 1 byte ! I dont understand this strange behaviour
P.S. I was studying buffer overflows but this problem doesnt seem to be related to it,still fyi I had turned ASLR off and other gcc stack protection stuff.