[U-Boot-Users] Non-static global variables cause relocation to fail

Timur Tabi timur at freescale.com
Fri Jun 20 16:47:01 CEST 2008


Jerry Van Baren wrote:

> That isn't a variable, that is the first line of a struct declaration. 

I didn't include this part (although since the code compiles, it should be
obvious that it exists):

} e;

So I'm defining a global variable called 'e'.  Perhaps the short name is part of
the problem.

> You cut some pretty important information: what the struct is, the 
> actual variable in question, and whether it is initialized.

As Wolfgang pointed out, my assumption that this is a generic problem is flawed,
and it's most likely a problem with my specific implementation.

> I'm guessing from the name "eeprom" that you have a non-zero initializer 
> on it???  

No, no initializer.

> Does it make a difference if it is uninitialized, initialized 
> to {0}, or initialized to non-zero values?

I don't know, I haven't considered it.

I did notice this code in fsl_i2c.c:

#ifdef CFG_SPD_BUS_NUM
static unsigned int i2c_bus_num __attribute__ ((section ("data"))) =
CFG_SPD_BUS_NUM;
#else
static unsigned int i2c_bus_num __attribute__ ((section ("data"))) = 0;
#endif

I wrote this code, but I don't remember why I added the "__attribute__ ((section
("data")))".  I guess I should have commented it, but I wonder if it applies to
my current problem.

> Does it make a difference if it is packed or not (my guess: much less 
> likely than initialization to cause works/broken).

It needs to be packed, otherwise the code won't work.  Sadly, someone defined a
4-byte integer at address 0x72 in the EEPROM.

When I post the full patch, I'll revisit this problem.  Sorry for all the noise.

-- 
Timur Tabi
Linux kernel developer at Freescale




More information about the U-Boot mailing list