public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mikpe at csd dot uu dot se" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/24675] Stack corruption in ARM arch. if 64bit variable is passed to a function of which the low 32 use the register and the up 32 use the stack
Date: Wed, 09 Nov 2005 22:04:00 -0000	[thread overview]
Message-ID: <20051109220409.3920.qmail@sourceware.org> (raw)
In-Reply-To: <bug-24675-11653@http.gcc.gnu.org/bugzilla/>



------- Comment #6 from mikpe at csd dot uu dot se  2005-11-09 22:04 -------
Here's a standalone test case. This fails (returns 1 from main())
on armv5b-linux when compiled with gcc-3.4.4, 3.3.6, or 3.3.3,
at -O2 or -O1 -foptimize-sibling-calls. Disabling sibcall optimisation
hides the bug.

If the variable x in main() is removed (passing NULL not &x to
clobbers_callers_stack()), then the return address slot in main()'s
frame gets clobbered, causing main() to return to la-la land,
resulting in a seg fault.

#include <stdio.h>

void doit(void *p, unsigned long long ull, unsigned c, unsigned a, unsigned s)
{
    if (!(int)ull)
        printf("%p %016llx %x %x %x\n", p, ull, c, a, s);
}

void clobbers_callers_stack(void *p1, void *p2, unsigned c, unsigned long long
ull)
{
    doit(NULL, ull, 0x55, 0x20, 0x3a3a3a3a);
}

int main(void)
{
    int x = 0;
    clobbers_callers_stack(&x, NULL, 8, 0x700ULL);
    if (x != 0) {
        printf("main: x == %#x\n", x);
        return 1;
    }
    return 0;
}


-- 


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


  parent reply	other threads:[~2005-11-09 22:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-04 15:05 [Bug c/24675] New: " bill dot thompsons at gmail dot com
2005-11-04 15:08 ` [Bug target/24675] " pinskia at gcc dot gnu dot org
2005-11-09  2:11 ` armcc2000 at yahoo dot com
2005-11-09  4:21 ` armcc2000 at yahoo dot com
2005-11-09  4:31 ` pinskia at gcc dot gnu dot org
2005-11-09  6:21 ` armcc2000 at yahoo dot com
2005-11-09 22:04 ` mikpe at csd dot uu dot se [this message]
2005-11-09 23:33 ` armcc2000 at yahoo dot com
2005-11-09 23:41 ` pinskia at gcc dot gnu dot org
2005-11-10  1:25 ` armcc2000 at yahoo dot com
2005-11-11  0:56 ` bill dot thompsons at gmail 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=20051109220409.3920.qmail@sourceware.org \
    --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).