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 #3 from armcc2000 at yahoo dot com  2005-11-09 04:21 -------
A few more results...

1) gcc 4.0.2 _is_ also buggy

2) Bug seems to be associated with -foptimize-sibling-calls 
ie previous code compiled with:

arm-linux-gcc-4.0.2 -O1 -foptimize-sibling-calls

gives:

        .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.
        sub     sp, sp, #4
        @ lr needed for prologue
        str     r3, [sp, #0]
        mov     r3, #0
        str     r3, [sp, #4]
        str     r3, [sp, #8]    <-- BANG... caller's stack overwritten !!
        mov     r0, r3
        mov     r1, r3
        mov     r2, r3
        add     sp, sp, #4
        b       foo
        .size   bad, .-bad
        .ident  "GCC: (GNU) 4.0.2"


For reference, arm-linux-gcc-4.0.2 -O1 
gives:

        .align  2
        .global bad
        .type   bad, %function
bad:
        @ args = 8, pretend = 4, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        sub     sp, sp, #4
        str     lr, [sp, #-4]!
        sub     sp, sp, #8
        str     r3, [sp, #12]
        mov     r3, #0
        str     r3, [sp, #0]
        str     r3, [sp, #4]
        mov     r0, r3
        mov     r1, r3
        mov     r2, r3
        bl      foo
        add     sp, sp, #8
        ldr     lr, [sp], #4
        add     sp, sp, #4
        bx      lr
        .size   bad, .-bad
        .ident  "GCC: (GNU) 4.0.2"

(ie not particularly optimal, but no stack corruption).


-- 

armcc2000 at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |armcc2000 at yahoo dot com


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]