title: How can I determine the return address on stack?
body: <p>I know that if I am inside some function <code>foo()</code> which is called somewhere from <code>bar()</code> function, then this return address is pushed on stack.   </p>
  
  <pre><code>    #include &lt;stdio.h&gt;
  
      void foo()
      {
              unsigned int x;
              printf("inside foo %x\n", &amp;x);
      }
      int main()
      {
              foo();
              printf("in main\n");
              return 0;
      }
  </code></pre>
  
  <p>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? </p>
  
  <p>EDIT: My environment is Ubuntu 9.04 on x86 processor with gcc compiler. </p>