From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timur Tabi Date: Fri, 03 Nov 2006 18:07:07 -0600 Subject: [U-Boot-Users] Why are some global vars part of the image, and some not? In-Reply-To: <20061103234436.14D2F353C4E@atlas.denx.de> References: <20061103234436.14D2F353C4E@atlas.denx.de> Message-ID: <454BD9AB.1000303@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Wolfgang Denk wrote: > I'm not exactly sure what you mean by the "global vars" in the > Subject line. The declaration you show here says "static". This may > or may not be what you mean. To me, a variable defined outside of a function is a global variable, regardless as to whether it's "static" or not. Technically, these variables are static globals, but I don't think removing the "static" would change what I'm seeing. Would it? >> As you can see, I defined two static volatile global vars: i2c_bus_num and >> i2c_dev. > > Yes, and one of these is initialized with non-zero values (so it will > go to the data segment), while the other is not (so it will go to > bss). I realized that about two minutes after I posted my email, which is why I posted a follow-up. > 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. (An alternative would be to change i2c_read() and i2c_write() to take a bus number as a parameter, but that would change hundreds of files). -- Timur Tabi Linux Kernel Developer @ Freescale