[U-Boot-Users] Does u-boot relocate absolute symbols?

Andreas Block andreas.block at esd-electronics.com
Fri Jul 1 17:06:26 CEST 2005


Hi Jerry,

thanks for your time.

On Fri, 01 Jul 2005 16:35:49 +0200, Jerry Van Baren  
<gerald.vanbaren at smiths-aerospace.com> wrote:

> I ran the code you (Andreas) sent, with the one correction for the
> printf().  The code you sent did not set the test array pointer to
> 0x40000.

I did look at the code, I had sent originally (with the typo you proposed)  
and in line 3 of array.c *test is initialized to 0x40000. I was writing  
big time nonsens that morning, but I wasn't that bad.


>  When I use the code you _ment_ rather than what you _sent_
> (see below - sorry for top-quoting), I get the same effect you get:
>
> vanbaren at sherwood:~/x> ./arrtest
> *test: 0x08048558
> test[]: 0x08048558
>
> vanbaren at sherwood:~/x> ./arrtest-ptr
> *test: 0x00040000
> test[]: 0x08048558
>
> I think I now understand the root of your problem.  You want to place an
> initialized array at a specific location.  C has a way of initializing
> arrays:
>    const unsigned char test[] = { value... };
> and a way of making a pointer to an array:
>    const unsigned char *test = (unsigned char*)0x40000;
> but it doesn't have a way to do _both_ at the same time.  You are trying
> to avoid the need for two initializations in one declaration limitation
> by doing it _differently_ in _two_ different places.  This is confusing
> the compiler and/or the linker.

As I already said, this is no bug in the compiler nor the linker. It is  
C-language and this example isn't supposed to work. It's just to show a  
peculiarity of C-language (or better a peculiarity of how most people  
(incl. me) understand C-language). It took me some time to realize, but I  
realized _before_ posting here. Your suggestion again ends up with changes  
in common.h, which is the only thing I'd like to avoid. Don't get me  
wrong, thanks for the time you've invested in order to help me. But I had  
a workaround (with changes in common code) running, before I posted the  
first time.


> I would guess this is a compiler/linker interaction that could be
> labeled unfortunate lack of communications or a bug, depending on your
> frustration level for the day.
> [...]
> You still may have to resolve relocation issues, depending on where you
> locate the resulting array data and whether it gets copied and whether
> it is available in the ROM location, but that is a red herring at this
> point.

The entire discussion is more about, should/could be something changed in  
U-Boot/linker script in order to make relocation somewhat more  
consistent/generic/orthogonal.

Best regards,
Andreas Block




More information about the U-Boot mailing list