From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerry Van Baren Date: Mon, 06 Nov 2006 14:06:06 -0500 Subject: [U-Boot-Users] Why are some global vars part of the image, and some not? In-Reply-To: <454F854B.9000402@freescale.com> References: <20061104020417.69640352658@atlas.denx.de> <454F7440.5030709@freescale.com> <454F78D6.6020805@smiths-aerospace.com> <454F7A30.9030100@freescale.com> <454F8373.1000300@smiths-aerospace.com> <454F854B.9000402@freescale.com> Message-ID: <454F879E.9020803@smiths-aerospace.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Scott Wood wrote: > Jerry Van Baren wrote: >> In theory, yes. In practice, I have my doubts that it is workable, let >> alone a better way. Writing "then the compiler would be the one that >> zeros BSS" is easy, actually making it work may be tricky. > > It's a pretty simple linker script change, actually. Just move all of > the lines within .bss {} into .data {}. Where do you see the difficulty > coming from? > > -Scott Does the linker create proper zero initialization? If you initialize a variable to zero, the compiler puts it in bss and does not initialize it, secure in the knowledge that the runtime zeroes bss. If you subsequently put it in the data section via the linker script, does it get zeroed? Does the bss/data end up in the right place? 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? Simple enough things to experiment with, but it all takes time and the benefit is questionable. Feel free to prove us curmudgeons wrong. ;-) gvb