This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: question about allocating local variable


Purnendu/Gmail <purnendu@gmail.com> writes:

> On a solaris platform with gcc 3.0 the one i have
> out put for such a behaviour is pretty predictive.
> 
> It allocates a stack of 120 for char a[1] to char a[8]
> then 128 for char a[9] to char a[16]
> and so on.
> 
> for an integer array
> It allocates a stack of 120 for int a[1] and int a[2]
> then 128 for int a[3] to int a[4]
> and so on.
> 
> with a allignment of 4 bytes
> 
> ===============
> 
>  .file   "help.c"
>         .section        ".text"
>         .align 4
>         .global main
>         .type   main,#function
>         .proc   04
> main:
>         !#PROLOGUE# 0
>         save    %sp, -128, %sp

This isn't just for your array. Most of it is for saving the register
    stack. 

>         !#PROLOGUE# 1
>         ret
>         restore
> .LLfe1:
>         .size   main,.LLfe1-main
>         .ident  "GCC: (GNU) 3.0"
> ~
[snip]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]