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

Scott Wood scottwood at freescale.com
Mon Nov 6 20:46:43 CET 2006


Jerry Van Baren wrote:
> Does the linker create proper zero initialization?

Yes.

> Does the bss/data end up in the right place?

It ends up where nonzero-initialized data currently is (i.e. in flash 
before relocation, in RAM after).

> On start up your stack is 
> in cache or dual-port RAM until SDRAM is initialized.  When does the 
> initialized portion of the data section get initialized and where? 
> Before it is in SDRAM or after SDRAM is initialized?

I don't follow what, specifically, you mean by "initialized portion". 
The data section contains data which is statically initiallized at 
compile/link time; the only difference is that it would now include data 
whose initial value is zero.  Some pieces of data will be further 
"initialized" at runtime by U-Boot code; this, of course, must happen 
after SDRAM is initialized (and U-Boot has relocated to it), but that 
has nothing to do with moving the BSS into the data segment.

The BSS is purely an optimization; besides increasing flash footprint 
somewhat, removing it should not change anything except for code that 
was already broken.

> Simple enough things to experiment with, but it all takes time and the 
> benefit is questionable.  Feel free to prove us curmudgeons wrong. ;-)

The main things that would take effort are changing all the board linker 
scripts, and finding large BSS allocations and changing them to be 
dynamically allocated so they don't take up space in flash.

The benefit is that bss-related bugs in the pre-RAM code go away and 
stay away, and that ugliness such as having to specify __attribute__ 
((section ("data"))) whenever the value is zero also goes away.

-Scott




More information about the U-Boot mailing list