From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timur Tabi Date: Fri, 03 Nov 2006 15:58:29 -0600 Subject: [U-Boot-Users] Why are some global vars part of the image, and some not? Message-ID: <454BBB85.5040507@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 I have the following code in one of my files: #ifdef CFG_SPD_BUS_NUM static volatile unsigned int i2c_bus_num = CFG_SPD_BUS_NUM; #else static volatile unsigned int i2c_bus_num = 0; #endif static volatile struct fsl_i2c *i2c_dev[2] = { (struct fsl_i2c *) (CFG_IMMR + CFG_I2C_OFFSET), #ifdef CFG_I2C2_OFFSET (struct fsl_i2c *) (CFG_IMMR + CFG_I2C2_OFFSET) #endif }; As you can see, I defined two static volatile global vars: i2c_bus_num and i2c_dev. My U-Boot image is 0x294E0 bytes in size, and it's located at address 0xFE000000. When I run U-Boot, the address of i2c_bus_num is 0xfe02a114, and the address of i2c_dev[] is 0xfe028124. In other words, i2c_dev[] is part of the actual U-Boot image, but i2c_bus_num, which is defined right next to it, isn't. This means that i2c_dev[] is properly initialized, but i2c_bus_num is set to 0xFFFFFFFF (the value that erased flash has). How is this possible? How can two adjacent global variables be located is completely different memory segments? -- Timur Tabi Linux Kernel Developer @ Freescale