This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
help!
- From: tony_hcb <tony_hcb at sina dot com>
- To: gcc at gnu dot org
- Cc: gcc-owner at gcc dot gnu dot org
- Date: Fri, 28 Jun 2002 12:28:54 +0800
- Subject: help!
would you please explain the allocation of the local variables in the stack space? We will describe the question below:
Step 1、 source code(1.c)is below:
main()
{
int *a[1];
}
after "gcc -S 1.c",the content of (1.s) is below:
.file "3.c"
.version "01.01"
gcc2_compiled.:
.text
.align 4
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
subl $4, %esp (this will be discussed belowing)
leave
ret
.Lfe1:
.size main,.Lfe1-main
.ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.0)"
Step 2、
main()
{
char *a[2];
}
after "gcc -S 2.c","subl $4, %esp" changes into "subl $8, %esp" (this is understandable)
Step 3、
main()
{
char *a[3];
}
after "gcc -S 3.c","subl $8, %esp" changes into "subl $24, %esp"
WHY?
According to our knowledge, the number should be 12 rather than 24.
CAN YOU EXPLAIN THE REASON AND THE RULES OF STACK SPACE ALLOCATION?
We disassemble with GCC of different version and get different results.Have this results relation to the versions of GCC?
Expecting your response!
______________________________________
===================================================================
新浪免费电子邮箱 (http://mail.sina.com.cn)
新浪分类信息:二手市场走一走,该出手时就出手! (http://classad.sina.com.cn/2shou/)