I'm working on a program that uses inline assembly to perform a long jump. To my understanding, all I need to do is replace the FP and PC to a saved FP and PC. Using assembly, I'm able to change the frame pointer (%ebp) however I'm unable to do it to the PC.
int jump(int x)
{
int oldFP = getebp(); //the FP of the calling function
int oldPC = getebp()+4; //the PC of the calling function
ljump(); //uses assembly to change FP (works) but can't figure out PC
return x;
}
and my ljump()
is
ljump: # return stack frame pointer FP
movl savedFP, %ebp
ret
my previous attempt to change PC have been using a jump, however I usually get a segmentation error.
Any input would be appreciated.