[U-Boot-Users] Relocation of symbols?

Andreas Block andreas.block at esd-electronics.com
Tue Jun 28 17:47:52 CEST 2005

28.06.2005 17:21:35, Wolfgang Denk <wd at denx.de> wrote:

>In message <85W32HGVT4WOKE0XT1Y1XVTND0OM74.42c15f80 at pc-block> you wrote:
>> Well, then I don't get it. Perhaps you could have a look at my mail referenced
>> above. 
>> There's an example of U-Boot relocating an absolute symbol.
>I didn't see it. You claimed that there was an absolute symbol in  an
>object  file, but I have not seen the result of the linker run (i. e.
>the U-Boot ELF file, the System.map file or the u-boot.map file); nor
>do I know what you are doing in your linker script.
>Is your symbol "fpgadata" really listed in the GOT?
>You mentioned that it contains a bad value, but did you  verify  that
>this  was indeed casued by relocation (i. e. was the value really off
>by the relocation distance) ?

Well, I did show you the output of the generated object itself (before it got linked 
against U-Boot) and all I did in my test-command in U-Boot was to print the address of 
the symbol. All I can think of is relocation. But I'll think again, do some more tests 
and send you the result tomorrow.

>> Well, I think there has to be a difference for the compiler in the next two cases:
>> char *walter = 0x4711;
>> char *herbert = "Thommy, the cat";
>No. There may be a difference for you, or for the resultof  the  code
>execution,  but  for  the  compiler  it's all the same. AFAIK the ESP
>module of GCC has not been implemented yet :-)

Of course it's not the compiler, but the linker. When talking about compiler, I was 
speaking of the entire tool-chain, sorry, for this imprecision. But I can show you, 
that it is indeed two different thinks for the compiler (which reaches some information 
about this difference to the linker). I'll do this tomorrow, too.

>> The first one shouldn't be relocated by the compiler, but the last one has to be 
>> relocated, in order to make the program work. At least as far as I understand it, 
>> please correct me, if I'm wrong.
>The _compiler_ does not do any relocation at  all.  He  doesn't  even
>know that such a thing exists. For the _compiler_ a pointer is just a
>pointer, in no way more special than an int.

But the compiler tags relocation marks for the linker, right?

>> >I don't think  that  GCC/gas  will  normally  generate  any  absolute
>> >symbols  at all. If you manually define such symbols you are expected
>> >to understand what you are doing.
>The emphasis is on "understand".

Thanks a lot, I got that one.

>> Again, I'd like to reference my above mentioned first request from 14.06.2005. I 
>> I know what I'm doing and what I want to do, but the generated absolute symbol is 
>> relocated by U-Boot.
>You know what you  did,  but  you  posted  here  because  you  didn't
>understand  the  results,  right?  I don't understand it either, so I
>tend to avoid doing such things ;-)

If I avoided all things I don't understand, I wouldn't have much to do, would I?

>> Thanks for your suggestions, but my main problem is I'm not wanting to change any 
>> common code and want to solve my problem in the problem specific code.
>I really don't understand why you need to statically  intialize  this
>pointer  at  all,  or why you bother about it being relocated or not.
>You mentioned that this is an address to where the code is downloaded
>by TFTP first. So you will have to set up a  TFTP  transfer  and  all
>these  things  - so the address in RAM should be known. Why don't you
>simply use a plain assignment in your code, then?

I will explain this once more in detail tomorrow. The main problem lies in the fact, 
that I don't want to touch any common code, but want to achive a solution within my 
project's code, only.

Andreas Block

More information about the U-Boot mailing list