loading from the stack segment

Alan Modra amodra@bigpond.net.au
Fri Aug 20 02:58:00 GMT 2004


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



More information about the Binutils mailing list