Hi,I have been evaluating the ARM 2006q3-26 for arm-linux release and I found what seems like a bug related to gcc.
While compiling Linux kernel 2.6.16, gcc corrupts registers after calling do_div64 function. This is a asm function that uses a very weird parameter passing and results returning (it returns a 64 bit value on r2, r3).
The problem is that when enabling optimizations gcc is ignoring the returned value is on r2, r3, and therefore corrupting them during the next function call:
ldr r0, [pc, #64] ; 58 <.text+0x58> ldr r4, [pc, #64] ; 5c <.text+0x5c> ldr r1, [pc, #64] ; 60 <.text+0x60> bl 0 <__do_div64> mov r0, r1 mov r1, #1000 ; 0x3e8 <-- r2, and r3 should be saved bl 0 <__aeabi_uidiv>Compiling the same code with a EABI toolchain from montavista (based on gcc 3.4.3), this one generates proper code:
ldmia r0, {r0, r1} ldr r4, [pc, #72] ; 68 <.text+0x68> bl 0 <__do_div64> mov r0, r1 mov r1, #1000 ; 0x3e8 mov r5, r3 mov r4, r2 bl 0 <__aeabi_uidivmod>I take the code out of Linux kernel and create a test case for user space. I'm attaching it.
It's this a known bug? I'm missing something? I was wondering if someone successfully run kernel 2.6.16 or higher with this toolchain, since this bug can potentially brake many code paths.
Regards Diego Dompe, RidgeRun Engineering
Attachment:
gccbug-test.tgz
Description: Binary data