help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

changing stacks


From: Ganesh
Subject: changing stacks
Date: Thu, 14 Feb 2008 20:40:08 -0800 (PST)
User-agent: G2/1.0

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]