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 rtl-optimization/11222] arm/thumb __Unwind_SjLj_Register prologue optimization causes crash on interrupts



------- Comment #9 from guested dot portrayed dot stephen at blacksapphire dot com  2007-08-08 05:15 -------
Created an attachment (id=14042)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14042&action=view)
This fixes a very similar bug in 4.1.1

gcc version 4.1.1 contains a very similar (but not quite the same) bug where
function epilogues like this are generated for ARM thumb targets.

empty:
        push    {r7, lr}
        add     r7, sp, #8
        mov     sp, r7
        sub     sp, sp, #8
        @ sp needed for prologue
        pop     {r7}
        pop     {r0}
        bx      r0

The problem is that between "mov sp, r7" and "sub sp, #8", the stack pointer
points above the valid stack bottom, and if an interrupt occurs between these
points, stack contents get overwritten.

To generate the above code, use this test.c file:

--- test.c
void empty(void);
void empty()
{
}
--- end test.c

Use this command:

/opt/arm-none-eabi/bin/arm-none-eabi-gcc -S -o test.s test.c -mthumb
-fno-omit-frame-pointer -O2

The attached patch fixes this bug.


-- 


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


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