help!
tony_hcb
tony_hcb@sina.com
Fri Jun 28 00:39:00 GMT 2002
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/)
More information about the Gcc
mailing list