This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: loading from the stack segment


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]