Local variable memory allocation

Darragh O'Brien dobrien@computing.dcu.ie
Tue Sep 16 15:31:00 GMT 2003


> On Tue, 16 Sep 2003, Darragh O'Brien wrote:
> > Can I force gcc to allocate only as much room as is necessary for local
> > variables on the stack?
>
> Define "necessary", and tell us why you think it currently doesn't do
> that?

>From this:

void
func(void)
{
	char	buffer[256];
}

I get this:

0x0804835c <func+0>:    push   %ebp
0x0804835d <func+1>:    mov    %esp,%ebp
0x0804835f <func+3>:    sub    $0x108,%esp
0x08048365 <func+9>:    leave
0x08048366 <func+10>:   ret

Why 108?

Thanks.



More information about the Gcc mailing list