Date: Fri, 14 Feb 1997 02:33:54 -0800 From: obrien@NUXI.com (David O'Brien) To: freebsd-chat@freebsd.org Subject: Re: Trying to understand stack overflow Message-ID: <19970214023354.GX64728@dragon.nuxi.com> In-Reply-To: <199702140448.OAA27909@ogre.devetir.qld.gov.au>; from Stephen McKay on Feb 14, 1997 14:48:06 %2B1000 References: <199702140448.OAA27909@ogre.devetir.qld.gov.au>
next in thread | previous in thread | raw e-mail | index | archive | help
Stephen McKay writes: > > The function arguments are pushed onto the stack in reverse order, This is by convention only, and is quite implimentation specific. This is not required by the i386 architecture. Microsoft Pascal pushes arguments on the stack in call order. There is a requirement for the C language that variable length parameter lists be dealt with. Pushing things in reverse order is simply one way of dealing with it. Another would be to pass the number of args in a register (the small C compiler did this). With the reverse order method, you know that the first arg is pointed to by BP/EBP + x (where X is size of return address + frame info), and you "walk" the stack for each argument you access. Of course you need to know when to stop. Think about what happens when you have one too many "%s'" in your printf format... :-) -- -- David (obrien@NUXI.com -or- obrien@FreeBSD.org)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970214023354.GX64728>