[U-Boot-Users] Why are some global vars part of the image, and some not?

Timur Tabi
2006-11-04T00:09:36Z

Wolfgang Denk wrote:
> In message <454BC07C.4090704@freescale.com> you wrote:
>>> #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
>> Ok, I fixed my problem by changing the above line to:
>
> I don't see any problem that needed fixing.

The problem is that without specifying the section attribute, when I ran my
code, i2c_bus_num was equal to 0xFFFFFFFF.

>> static volatile unsigned int i2c_bus_num __attribute__ ((section ("data"))) = 0;
>>
>> Is "data" the right section to use? Here's my lds file:
>
> If you have to ask this question, then the answer is no, and better
> don't mess with things you don't understand.
>
> What exactly is the "problem" you are experiencing? Did you read the
> documentation, especially section "Initial Stack, Global Data" in the
> README? Please let me know if there is anything in this text which is
> not clear enough.

That section doesn't address issues with global (static or otherwise)
variables that need to be read prior to relocation.

--
Timur Tabi
Linux Kernel Developer @ Freescale