Hi,

I need to switch the stack before a function call in C++. Can I just
change the  stack pointer just before the function invocation. Is that
all that is required to change stacks? Like,

void func {
  change_stack_pointer
  foo (exp1, exp2...)
  restore_stack_pointer

}

The function call has expressions that access the local variable in
the original stack.   I am concerned that if a compiler (say g++)
emits a code that accesses the local variable of func using address
relative to SP, then the above approach will fail (because the SP is
changed).  How shall I gurantee in g++ (and if possible in other
compilers) that access to local variables is not relative to SP? Or is
it always the case that the access is not relative to SP?

I know that there are other ways to change stack (makecontext,
sigaltstack etc). But, I want an extremely light weight mechanism.

--Ganesh
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to