Re: Stack frame question on x86 code generation

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

 



Thanks for your response. Please find the subsequent
question. 

Best regards,

--- James E Wilson <wilson@xxxxxxxxxxxxxxx> wrote:

> 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.
> 
% gcc -v
Reading specs from
/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs
Configured with: ../configure --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-shared --enable-threads=posix
--disable-checking --with-system-zlib
--enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)


> >   printf("0x%x=return address, *ret);
> 
> You are missing a quote here.
> 

You are absolutely right.

> > 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.
> 

Well, that answers. 

> 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.
> 

That answers, too!

> > 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.

I am not quite following this. It sounds like the
stack frame
of the current development gcc version is not aligned
with 16 bytes with -40. How you can make it 16 bytes
aligned with -8? 

> -- 
> Jim Wilson, GNU Tools Support,
> http://www.SpecifixInc.com
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[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