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



> >> 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.

The gcc documentation 
http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Local-Reg-Vars.html#Local-Reg-Vars
clearly states that local register variables are not guaranteed to contain the 
values you think they do, except in certain circumstances. In particular:
"Stores into local register variables may be deleted when they appear to be 
dead according to dataflow analysis."

You could try the patch below. It is against an old version of u-boot so YMMV.

Paul

diff -ur u-boot-1.1.1/include/asm-arm/global_data.h 
u-boot/include/asm-arm/global_data.h
--- u-boot-1.1.1/include/asm-arm/global_data.h	2003-10-10 11:05:43.000000000 
+0100
+++ u-boot/include/asm-arm/global_data.h	2004-11-28 22:00:29.000000000 +0000
@@ -61,6 +61,11 @@
 #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/
 #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/
 
-#define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r8")
+#if 0
+#define DECLARE_GLOBAL_DATA_PTR     register gd_t *gd asm ("r8")
+#else
+#define DECLARE_GLOBAL_DATA_PTR
+register gd_t *gd asm ("r8");
+#endif
 
 #endif /* __ASM_GBL_DATA_H */