From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerry Van Baren Date: Mon, 06 Nov 2006 13:03:02 -0500 Subject: [U-Boot-Users] Why are some global vars part of the image, and some not? In-Reply-To: <454F7440.5030709@freescale.com> References: <20061104020417.69640352658@atlas.denx.de> <454F7440.5030709@freescale.com> Message-ID: <454F78D6.6020805@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: > Wolfgang Denk wrote: >> In message <454BEF23.1020909@freescale.com> you wrote: >> >>> What about modifying the linker script so that all of bss is merged into >>> the image, i.e. treat it like 'data'? >> >> That would mean that you have to allocate flash memory for all this >> stuff, which is typically in the 100...150 kB range, i. e. you would >> double the memory footprint of U-Boot in flash memory., > > That seems rather ridiculously large... perhaps some of the larger > chunks of that could be dynamically allocated, rather than leaving a > giant welcome mat for bugs by executing C code before the BSS is cleared > (especially if, as it appears to be in this case, the compiler and/or > linker is putting things in the BSS even when explicitly initialized to > zero, rather than just left uninitialized)? > > BTW, I'm only seeing about 19kB of BSS on an 8349EMDS build from the > current git head. > >> No, this is NOT acceptable. Don't even think of it. > > I don't think refusing to think about alternatives is conducive to good > software engineering. > > -Scott You don't understand, u-boot _is_ what zeros bss so, until u-boot is running enough to zero bss, bss will be random garbage. The stuff you are doing is very early initialization - using I2C to read SPD, which is before you even _have_ a normal bss because you don't even have your SDRAM active at this point. Welcome to the Wacky World of Embedded where you must do everything yourself, and the world is populated with very sharp objects waiting to nail you if you do anything wrong. gvb