Re: Memory Allocation On Stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pankaj Kohli wrote:
> Yeah, that was me who asked it on kerneltrap :)
> If it is trying to align ESP on a 16-byte boundary, that seems fine
> for a single integer variable or anything less than 16 bytes, but why
> is it allocating 116 bytes for 100 byte buffer ? That doesn't fit on a
> 16-byte boundary.
>
> (gdb) list
> 1 #include
> 2
> 3 int main(int argc, char **argv) {
> 4 char buf[100];
> 5
> 6 return 0;
> 7 }
> 8
> (gdb) disassemble main
> Dump of assembler code for function main:
> 0x080483a4 : lea 0x4(%esp),%ecx
> 0x080483a8 : and $0xfffffff0,%esp
> 0x080483ab : pushl 0xfffffffc(%ecx)
> 0x080483ae : push %ebp
> 0x080483af : mov %esp,%ebp
> 0x080483b1 : push %ecx
> 0x080483b2 : sub $0x74,%esp

It does 3 pushl and the sub ... 0x74 + 3*4 == 128 which is a multiple of 16.

Tom

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux