This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Stack frame question on x86 code generation
- From: James E Wilson <wilson at specifixinc dot com>
- To: Gang-Ryung Uh <uh18104 at yahoo dot com>
- Cc: gcc at gcc dot gnu dot org, gcc-help at gcc dot gnu dot org
- Date: Mon, 25 Apr 2005 17:26:11 -0700
- Subject: Re: Stack frame question on x86 code generation
- References: <20050423180944.68016.qmail@web50304.mail.yahoo.com>
Gang-Ryung Uh wrote:
Could anyone help me understand what is the gcc
strategy to prepare the stack frame?
You didn't mention the gcc version, or the gcc target. Different gcc
versions and targets will give different answers. Even different x86
targets work differently.
printf("0x%x=return address, *ret);
You are missing a quote here.
question1: Why the stack frame size is 56?
A bug. It is 40 in current gcc development sources, or rather, I should
say that it is 40 that gets subtracted from the stack pointer. The
actual frame size also includes stuff that is being pushed.
This is probably the same issue as discussed in the thead here
http://gcc.gnu.org/ml/gcc/2005-04/msg01191.html
Then, why they adding 16 bytes padding?
Probably the same bug. I get "leal -9(%ebp), %eax" which makes sense
for a 5 byte array, with 4 bytes of data allocated ahead of it.
question2: Why gcc makes the stack frame bigger before
the function call printf?
This is probably to maintain 16-byte stack alignment when we reach
printf. We maintain 16-byte stack alignment so that MMX/SSE
instructions will work.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com