Re: determining return address of a function



On Wed, 28 Dec 2005 05:17:09 +0100, Madhav <madhav.kelkar@xxxxxxxxx> wrote:

> [mkelkar@adrastea cthreads]$ ./a.out
> 0th function (this function test2) 0x804836a

This is the return address somewhere in test1

> Test2=0x804836c

This is the start of test2

> 1st function ( function test1) 0x804835d

This is the return address somewhere in main

Do you mean to say that when I say __builtin_return_address(1) in test2( ), it will be the address of the 10th line pasted below?

8 int main(void)
9 {
10    test1();
11}

Please tell me if my understanding is right or wrong.

Wrong, but close.

The address of line 11 would be even closer.

The assembly code of the call of test1() may possibly contain some register
shuffling and stack operations after the call.  The return address is the
address of the first assembly instruction after the call.

-Enrique
.



Relevant Pages