[U-Boot-Users] Why are some global vars part of the image, and some not?

Wolfgang Denk wd at denx.de
Sat Nov 4 01:31:40 CET 2006

In message <454BD9AB.1000303 at freescale.com> you wrote:
> To me, a variable defined outside of a function is a global variable, 

May I suggest we stick with ANSI C standard  terminology  instead  of
private interpretations?

Since you complained about a problem where I could not  see  any  (at
least  none  that  was not clearly documented) I was not sure if your
expectation of "global" was correct, i. e. if you were aware  of  the
differences  between  "global"  on  file level versus "global" in the
meaning of "external" to the linker.

> > THis is perfectly OK. Just check the variables after U-Boot has  been
> > relocated to RAM and BSS has been initialized.
> I can't.  This code is used to initialize the I2C bus, which is used to 
> initialize SPD on DDR, which is obviously done before U-Boot is relocated.
> These variables contain the I2C bus number.  On some boards, SPD is on bus 0, 
> on some they're on bus 1.  So the compile-time initializer needs to be the 
> right bus.

Then you must make sure that even  zero-initialized  data  don't  get
placed in bss, and your approach was correct.

[It would have been good if you had mentioned this in  the  opriginal

Best regards,

Wolfgang Denk

Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Pray: To ask that the laws of the universe be annulled in behalf of a
single petitioner confessedly unworthy.              - Ambrose Bierce

More information about the U-Boot mailing list