This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: loading from the stack segment
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: David Livshin <dlivshin at inter dot net dot il>
- Cc: binutils at sources dot redhat dot com
- Date: Fri, 20 Aug 2004 12:28:24 +0930
- Subject: Re: loading from the stack segment
- References: <412510C1.4080603@inter.net.il>
On Thu, Aug 19, 2004 at 11:42:41PM +0300, David Livshin wrote:
> Hi,
>
> Changing the sequence of instructions from
>
> subl $9980,%esp
> movl -9976(%ebp),%eax
>
> to
>
> movl -9976(%ebp),%eax
> subl $9980,%esp
>
> causes segmentation fault while executing memory load
>
> movl -9976(%ebp),%eax
>
> I don't see any dependency between those two instructions.
>
> My guess is that
>
> subl $9980,%esp
>
> somehow establishes stack segment that
You guess is correct. Your operating system is extending the stack
segment automatically for you in the first case, but not the second.
If you're running linux, see linux/arch/i386/mm/fault.c:do_page_fault
and note the expand_stack call.
--
Alan Modra
IBM OzLabs - Linux Technology Centre