Subject: Re: alloca and libc
From: David Laight <firstname.lastname@example.org>
Date: 03/12/2002 17:37:34
On Tue, Mar 12, 2002 at 11:54:16AM +0100, Jaromir Dolecek wrote:
> David Laight wrote:
> > Given that alloca() is an architectural nightmare, maybe you should
> > abolish it completely and fix code not to assume it is present at all.
> > Get rid of setjmp/longjmp at the same time :-)
> Dream on :)
On an embedded system I think someone was trying to longjmp
out of an interrupt handler!
Thinking about it, you cannot write alloca without knowing
how the compiler has compiled the rest of the routine.
Indeed in some cases it cannot be written at all.
For instance, take a normal stack frame with frame ptr
pointing somewhere near the stacked return address.
Now instead of using 'push' for arguments, leave enough
space when the stack ptr is decremented (on entry) for
the arguments for the routine with most arguments and
move the arguments to the stack with fp relative
It is then impossible to write alloca.
The above scheme isn't stupid! I think it is a performance
gain on Pentium Pro (often sp relative addressing gets used,
but I suspect that bloats the code size so much that it
displaces other code from the cache and slows things down!)
David Laight: email@example.com