public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* __builtin_extract_return_address undefined
@ 2012-10-15 16:15 Alfonso Acosta
  2012-10-16 22:44 ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Alfonso Acosta @ 2012-10-15 16:15 UTC (permalink / raw)
  To: gcc-help

Hi,

Under gcc 4.6.1 (and at least in the x86 64bit architecture),
__builtin_extract_return_address seems to be undefined. Sorry for not
using the trunk or the latest stable version but I need to stick to
this version for my production software.

As a workaround, I am planning to simply avoid using
__builtin_extract_return_address since it seems to be the identity
function for most architectures.

Can somebody point out on which architectures
__builtin_extract_return_address is actually supposed to do something?
My code should support at the very least x86 (32 and 64) and ARM for
which I presume it's just the identity function.

Here is the testcase:

$ gcc --version
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -a
Linux maurice 3.0.0-17-generic #30-Ubuntu SMP Thu Mar 8 20:45:39 UTC
2012 x86_64 x86_64 x86_64 GNU/Linux

$ gcc -Wall -c test_builtin_extract_return_address.c
test_builtin_extract_return_address.c: In function 'print_my_own_ret_addr':
test_builtin_extract_return_address.c:9:3: warning: implicit
declaration of function '__builtin_extract_return_address'
[-Wimplicit-function-declaration]
test_builtin_extract_return_address.c:9:22: warning: assignment makes
pointer from integer without a cast [enabled by default]


test_builtin_extract_return_address.c:
=========
#include <stdio.h>


void print_my_own_ret_addr()
{
  void *unextracted_ret_addr;
  void *extracted_ret_addr;
  unextracted_ret_addr = __builtin_return_address(0);
  extracted_ret_addr = __builtin_extract_return_address(unextracted_ret_addr);
  printf("returning to %p\n",
         extracted_ret_addr);
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: __builtin_extract_return_address undefined
  2012-10-15 16:15 __builtin_extract_return_address undefined Alfonso Acosta
@ 2012-10-16 22:44 ` Ian Lance Taylor
  2012-10-17  5:18   ` Alfonso Acosta
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2012-10-16 22:44 UTC (permalink / raw)
  To: Alfonso Acosta; +Cc: gcc-help

On Mon, Oct 15, 2012 at 4:56 AM, Alfonso Acosta
<alfonso.acosta@gmail.com> wrote:
>
> Under gcc 4.6.1 (and at least in the x86 64bit architecture),
> __builtin_extract_return_address seems to be undefined. Sorry for not
> using the trunk or the latest stable version but I need to stick to
> this version for my production software.

It should be defined in GCC 4.6.1.  Note that it's called
__builtin_extract_return_addr.

> Can somebody point out on which architectures
> __builtin_extract_return_address is actually supposed to do something?
> My code should support at the very least x86 (32 and 64) and ARM for
> which I presume it's just the identity function.

It is not the identity function on ARM when running in 26-bit mode.
Other architectures where it is not always the identity function:
Alpha, MIPS, MMIX, PA, S390, S+CORE, SPARC.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: __builtin_extract_return_address undefined
  2012-10-16 22:44 ` Ian Lance Taylor
@ 2012-10-17  5:18   ` Alfonso Acosta
  2012-10-17 12:52     ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Alfonso Acosta @ 2012-10-17  5:18 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

> It should be defined in GCC 4.6.1.  Note that it's called
> __builtin_extract_return_addr.

Thanks! There's a typo in the documentation (it is documented as
__builtin_extract_return_address):

http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html#Return-Address

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: __builtin_extract_return_address undefined
  2012-10-17  5:18   ` Alfonso Acosta
@ 2012-10-17 12:52     ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2012-10-17 12:52 UTC (permalink / raw)
  To: Alfonso Acosta; +Cc: gcc-help

On Tue, Oct 16, 2012 at 12:23 PM, Alfonso Acosta
<alfonso.acosta@gmail.com> wrote:
>> It should be defined in GCC 4.6.1.  Note that it's called
>> __builtin_extract_return_addr.
>
> Thanks! There's a typo in the documentation (it is documented as
> __builtin_extract_return_address):
>
> http://gcc.gnu.org/onlinedocs/gcc/Return-Address.html#Return-Address

Thanks for pointing that out.  I fixed it in mainline.

http://gcc.gnu.org/ml/gcc-patches/2012-10/msg01617.html

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-17  5:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-15 16:15 __builtin_extract_return_address undefined Alfonso Acosta
2012-10-16 22:44 ` Ian Lance Taylor
2012-10-17  5:18   ` Alfonso Acosta
2012-10-17 12:52     ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).