public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/60109] New: __builtin_frame_address does not work as documented on ARM
@ 2014-02-07 16:41 doko at gcc dot gnu.org
  2014-02-07 17:25 ` [Bug target/60109] " rearnsha at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: doko at gcc dot gnu.org @ 2014-02-07 16:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60109

            Bug ID: 60109
           Summary: __builtin_frame_address does not work as documented on
                    ARM
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: doko at gcc dot gnu.org

__builtin_frame_address does not work as documented on ARM. For a value
greater or equal to 1 it returns a non null value but the returned
pointer does not seem to match a frame. See the attached testcase. With
tcc and clang it displays "__builtin_frame_address" while with gcc it
first displays "bfa1: %s" and then segfaults if the #if is removed.


amd64:
$ gcc builtin_frame_address.c && ./a.out
str: __builtin_frame_address
bfa1: __builtin_frame_address

armhf:
str: __builtin_frame_address
bfa1:  %s

$ cat builtin_frame_address.c 
#include <stdio.h>
#include <stddef.h>

void bfa3(ptrdiff_t str_offset)
{
    printf("bfa3: %s\n", (char *)__builtin_frame_address(3) + str_offset);
}
void bfa2(ptrdiff_t str_offset)
{
    printf("bfa2: %s\n", (char *)__builtin_frame_address(2) + str_offset);
    bfa3(str_offset);
}
void bfa1(ptrdiff_t str_offset)
{
    printf("bfa1: %s\n", (char *)__builtin_frame_address(1) + str_offset);
#if defined(__arm__) && !defined(__GNUC__)
    bfa2(str_offset);
#endif
}

void builtin_frame_address_test(void)
{
    char str[] = "__builtin_frame_address";
    char *fp0 = __builtin_frame_address(0);

    printf("str: %s\n", str);
    bfa1(str-fp0);
}

int main(void)
{
    builtin_frame_address_test();
    return 0;
}


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

end of thread, other threads:[~2014-05-06  1:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-07 16:41 [Bug target/60109] New: __builtin_frame_address does not work as documented on ARM doko at gcc dot gnu.org
2014-02-07 17:25 ` [Bug target/60109] " rearnsha at gcc dot gnu.org
2014-02-07 17:44 ` ramana at gcc dot gnu.org
2014-03-10  8:10 ` ramana at gcc dot gnu.org
2014-05-06  1:42 ` thomas.preudhomme at arm dot com

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).