[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[openrisc] GCC problem



During debugging a RTOS kernel I discovered that following statement 
caused the Link Address Register R9[LR] to be set to 0.  Because of this 
kernel crashed. 
RTOSTcbHigRdy = RTOSTcbPrioTbl[(y << 3) + RTOSUnMapTbl
[RTOSRdyTbl[y]]];

To avoid this problem and to make the kernel work I split the previous 
statement to following 3 statements: 
    i = RTOSRdyTbl[y];
    t = (y << 3) + RTOSUnMapTbl[i];
    RTOSTCBHighRdy = RTOSTCBPrioTbl[t];

Local variables and global arrays used in both cases are as follow:
    ULONG         y, t, i;                       // Locals
    ULONG         RTOSRdyTbl[];            // Global array
    ULONG         RTOSUnMapTbl[];        // Global array
    ULONG        *RTOSTCBPrioTbl[];      // Global array

I used following compiler options to build the kernel:
    rtostest-O0.o: rtostest.c
         or32-uclinux-gcc -g -O0 $? -c -o $@
    rtostest-O2.o: rtostest.c
         or32-uclinux-gcc -g -O2 $? -c -o $@

I believe that cause of the problem is how the gcc compiler handles 
multiple array indexing.  
Would you look at this problem and suggest which compiler option to use 
to avoid this kind of problems in the future.

Thank you,
Venko Baksa
Nimbus Wireless Inc.
 
--
To unsubscribe from openrisc mailing list please visit http://www.opencores.org/mailinglists.shtml