Re: Memory Allocation On Stack

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

 



Pankaj Kohli writes:
 > 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.

Where's the mystery?

 > Dump of assembler code for function main:
 > 0x080483a4 : lea 0x4(%esp),%ecx
 > 0x080483a8 : and $0xfffffff0,%esp

sp = sp & -16 // sp is 16-aligned

 > 0x080483ab : pushl 0xfffffffc(%ecx)

sp -= 4  // sp is 4-aligned

 > 0x080483ae : push %ebp

sp -= 4  // sp is 8-aligned

 > 0x080483af : mov %esp,%ebp
 > 0x080483b1 : push %ecx

sp -= 4  // sp is 4-aligned

 > 0x080483b2 : sub $0x74,%esp

sp -= 116 // sp is 16-aligned

Andrew.

[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