This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[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
- From: "mikpe at csd dot uu dot se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Nov 2005 22:04:09 -0000
- 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
- References: <bug-24675-11653@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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