I know that if I am inside some fuction foo() which is called somewhere from bar() function, then this return address is pushed on stack.
#include <stdio.h>
void foo()
{
unsigned int x;
printf("inside foo %x \n", &x );
}
int main()
{
foo();
printf("in main\n");
return 0;
}
In above code, I will get address of first pushed local variable on stack when foo function is active. How can I access the return address (main called foo) that is pushed somewhere before this variable on stack? Is that location fixed and can be accessed relative to first local variable? How can I modify it?
EDIT: My environment is Ubuntu 9.04 on x86 processor with gcc compiler.