This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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



------- Comment #2 from armcc2000 at yahoo dot com  2005-11-09 02:11 -------
Here's a slightly smaller test case:

------------------------------------------------------------
extern void foo (int f1, int f2, int f3, int f4, int f5, int f6);

void good (int g1, int g2, int g3, int g4, int g5)
{
        foo (0, 0, 0, 0, 0, 0);
}

void bad (int b1, int b2, int b3, long long b45)
{
        foo (0, 0, 0, 0, 0, 0);
}
------------------------------------------------------------

Compiled with gcc 4.0.1 (-Os), this gives:

        .file   "tst.c"
        .text
        .align  2
        .global good
        .type   good, %function
good:
        @ args = 4, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        str     lr, [sp, #-4]!
        mov     ip, #0
        sub     sp, sp, #8
        mov     r0, ip
        mov     r1, ip
        mov     r2, ip
        mov     r3, ip
        str     ip, [sp, #0]
        str     ip, [sp, #4]
        bl      foo
        add     sp, sp, #8
        ldmfd   sp!, {pc}
        .size   good, .-good
        .align  2
        .global bad
        .type   bad, %function
bad:
        @ args = 8, pretend = 4, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        mov     ip, #0
        sub     sp, sp, #4
        str     r3, [sp, #0]
        mov     r0, ip
        mov     r1, ip
        mov     r2, ip
        mov     r3, ip
        @ lr needed for prologue
        str     ip, [sp, #4]
        str     ip, [sp, #8]    <-- BANG... caller's stack is overwritten !!
        add     sp, sp, #4
        b       foo
        .size   bad, .-bad
        .ident  "GCC: (GNU) 4.0.1"

------------------------------------------------------------

The bug is also present in 3.4.4


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]