delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/12/22:45:22

From: "Luke Bishop" <lbishop AT calvin DOT stemnet DOT nf DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Creating and using a protected stack area: how?
Date: 13 Apr 1998 01:24:31 GMT
Organization: The Zone
Lines: 18
Message-ID: <01bd65b2$d1f01c40$3348a5c6@technoid>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980412120542 DOT 3322Q-100000 AT is>
NNTP-Posting-Host: n072h051.thezone.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> > then when I have to switch the stack I simply copy SS to %ss and ESP to
> > %esp (with an assembly procedure).
> 
> I don't think this approach will work.  GCC assumes SS = DS, so code
> generated by GCC will not work correctly if you switch SS under its
> feet.
> 
> But you can have separate stacks in the same segment (i.e., change ESP
> but leave SS alone).

To protect the stack you should just probably set the memory protection on
the 5 K block after the stack end to no read or write and use that.  It
simplifies the stack problems.  Changing the segments is simple enough, but
you shouldn't expect the return address to be valid.  In fact, you should
push the value of a thread-end callback to the stack, as you really dont
want the function to try returning to some random function or just to the
function that spawned it.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019