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

Andreas Block andreas.block at esd-electronics.com
Thu Jun 30 15:38:05 CEST 2005


30.06.2005 14:40:10, Wolfgang Denk <wd at denx.de> wrote:

>In message <S6Z4ZJE2ZD9OKTKIA9EBQPNIHC652U.42c3dac1 at pc-block> you wrote:
>> 
>> Hmm? This example was sent to Rune Torgersen in order to show him, that "char *bla" 
>> isn't the same as "char bli[]", so I'm not sure, why it doesn't explain anything.
>
>I think most of us are aware of the differences between a pointer and
>an array, but this is not your point. Your problem was how you  could
>keep  existing  code (which uses an array, as I understand), and both
>Rune and me said that the existing difference might be worked  around
>one way or another.

I'd appreciate, if any of you could get any more specific, because I don't get your 
hints about workarounds. And on the other side, neither of you comments my way of 
working around with an attempt to tell me, what I did wrong or overlooked.
I understand, you want to push me into the direction of a workaround, but I've no idea 
what you're thinking of.


>> 1) Is U-Boot supposed to relocate absolute symbols located in any objects, that are 
>> linked against it?
>
>U-Boot doesn't know anything about any symbols. It just walsk the GOT
>and adjusts the addresses it finds there.

Sorry, another imprecision on my side. I meant the linker script.


>> 1a) If not, would you be interested in a patch for U-Boot? (For me, I will be able 
>> to live with my workaround and putting any effort into it, pays only, if these 
>> changes make their way into the U-Boot tree.)
>
>In my understanding you want to find a way  that  "absolute  symbols"
>(and  eventually staticlaly initialized function pointers, too ?) get
>relocated correctly. Of course I will accept patches that improve the
>current code.

See below.


>> 2) Is it correct, that the linker script creates relocation tags inside of .text-
>> segments, only? Which would lead to the observed behaviour, that statically 
>> initialized pointers, which normnally result in relocation tags in .data segments, 
>> aren't relocated.
>
>No, this is not correct. You can access variables  in  data  and  bss
>segments  after relocation, so it's obvious that these got relocated,
>too.

Hm, are you sure? As far as I see it, the only relocation points in .data segment are 
the ones initializating pointers. All other relocation points are lying in .text-
segments, aren't they?

E.g.:

Global variables:
int walter; ==> results in relocation point(s) in .text-segment (every access to this 
variable results in machine code (in _.text_) with the need to be patched, when 
relocated)
These are handled perfectly by linker script.

Statically initialized pointers:
char *walter = "Big brown beaver"; ==> Here are two different relocations needed. For 
pointer "walter" see above "Global variables". Everything's fine. But number two 
concerns the address of the string. This results in a relocation entry in the .data-
segment and these seem not to be handled by the linker script. As far as I know, this 
is the only case leading to relocation points in the .data segment.

It seems to me, as if this should be fixable with a change in the linker script, but at 
the moment I've to admit, that the interior of this script is quite magic to me. 
Anyway, if one could fix it in the linker script, the handful codepieces relocating 
pointers are unnecessary. The icing on this cake would be to keep absolute symbols out 
of the GOT.

Best regards,
Andreas Block






More information about the U-Boot mailing list