Mail Archives: djgpp/1998/04/12/22:45:22
> > 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 -