Subject: Re: Adding a size parameter to stackgap_init()
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 03/18/2002 11:09:01
On Sun, Mar 17, 2002 at 11:16:24PM +0100, Wolfgang Solfrank wrote:
> Hi,
>
> > >How could we implement stackgap differently? The only idea that comes to
> > >me is to use the bottom of the stack (I mean where sp point to). But
> > >there must be a reason why it is not done that way. What is the
> > >drawback?
> >
> > That is what I meant. I don't know what the drawback is.
>
> The problem with this approach is that you don't know what is
> below the sp
>
> sp might point to just some place where you stored the parameters
> for the system call.
An implemetation might have passed the system call parameters
in some foul, horrid, way. But I would have though there
was an extensible stack there somewhere - even if it only actally
contains the env and argv structures.
> There are even some architectures (which we support) that don't have
> a real sp, but (for programs written in a language that depends on
> a stack) simulate one by using an ordinary register.
Erm ARM? pdp-11? :-)
I would have though that netbsd relied on a stack based system.
I can't see you getting any unix apps running without one.
After all the kernel needs one itself.....
> IMHO it would be a serious drawback to limit the layout of memory to the
> way it is defined in ELF-land.
My guess is that the memory layout is independant of the object file
type! It is much more of an OS dependant (constrained by system hw)
issue.
> It would have seriously hindered the devlopment of things like (p)threads,
> alloca
A horrid hack which was originally something like:
pop ret_addr
pop size
mov sp, accumulater /* function return value */
sub size, sp
jmp ret_addr
These days it is a foul horrid beast that the compiler has to
implement internally (as if part of the C language) in order to
get the expected efficiency.....
> unexec, threaded code etc. (probably even shared libraries, would you
> have restricted the layout before their advent)
> in the past and may do so for some future ideas.
FWIW another alternative would be to request a page of user memory
from the system - must be something in the pmap code for that.
David
--
David Laight: david@l8s.co.uk