public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "doko at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/60109] New: __builtin_frame_address does not work as documented on ARM
Date: Fri, 07 Feb 2014 16:41:00 -0000	[thread overview]
Message-ID: <bug-60109-4@http.gcc.gnu.org/bugzilla/> (raw)

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;
}


             reply	other threads:[~2014-02-07 16:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-07 16:41 doko at gcc dot gnu.org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60109-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).