RE: [arm-gnu] Problem with u-boot compiled with 2006q1-3
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [arm-gnu] Problem with u-boot compiled with 2006q1-3



Hi,

>> I was unable to run u-boot compiled with the newest codesourcery 
>> toolchain and after debugging I got the problem isolated to 
>an example 
>> below. U-boot breaks with -Os but works with -O0, but the example 
>> below does not work with either one. Earlier toolchains work.
>> 
>> It looks like gcc does not obey the instruction to use r8 for gd 
>> variable in main function, and so the program crashes when 
>func() uses 
>> gd which it thinks is in r8. Is this a bug in u-boot code or in gcc?
>
>This is a bug in uboot.
>
>int main()
>{
>  register volatile gd_t *gd asm("r8");
>
>Does not declare a global register.  It declares a local 
>variable in r8.

That is true. But the local variable should be in r8, and it's not. The
called function also declares a local var in r8, so in a sense it is
global between those functions. I agree that it's a very questionable
way to do the thing =). But I guess it is correct behaviour from the
compiler to optimize the usage of the registers, and not to use r8 if
from the compiler's point of view no one uses the register.

 Tomi