This is the mail archive of the gcc@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: [10 PATCHES] inline functions to avoid stack overflow


On Tue, 1 Jul 2008, David Miller wrote:

From: Mikulas Patocka <mpatocka@redhat.com>
Date: Wed, 2 Jul 2008 00:39:35 -0400 (EDT)

The ABI is very vague about it. The V9 ABI just displays that 6-word space
in a figure bug doesn't say anything about it's usage. The V8 ABI just
says that "the function may write incoming arguments there". If it may
write anything other, it is unknown --- probably yes, but it is not said
in the document.

The document nicely specifies who owns which registers, but doesn't say
that about the stack space :-(

Actually, I know for a fact that you have to have those slots there.


A long time ago in the sparc64 kernel, in the trap entry code, I tried
only giving 128 bytes of stack frame as the trap entry called into C
code.  And it did not work, I had to put the 6 slots there.

The bad thing is that gcc can't use those slots optimally. If you have for example:


void f(int *x)
{
}

void g()
{
	int a;
	f(&a);
}

void h()
{
	g();
}

Then the variable "a" can't be placed into one of the 6 implicit slots for g->f call (beacuse "f" may overwrite that slot). But "a" could be placed into one of those 6 slots that "h" allocates for "g" (because these slots are owned by "g"). But it isn't --- additional place is allocated for "a" :-/

Mikulas


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