This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: how to access PC
- From: Richard Henderson <rth at redhat dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: Mohammed Tajuddin <taj dot subhani at oracle dot com>, linuxppc64-dev at lists dot linuxppc dot org, gcc at gcc dot gnu dot org
- Date: Mon, 8 Sep 2003 23:28:22 -0700
- Subject: Re: how to access PC
- References: <3F5D18CD.E04E0B6C@oracle.com> <A6740B58-E264-11D7-A58D-0003939F15BE@physics.uc.edu>
On Mon, Sep 08, 2003 at 06:26:34PM -0700, Andrew Pinski wrote:
> Try this function:
> void * __attribute__((noinline)) getpc()
> {
> void *t;
> asm("mflr %0":"=r"(t));
> return t;
> }
If you're not going to inline, __builtin_return_address(0) will work.
r~