[U-Boot-Users] Changing u-boot relocation scheme

kenneth johansson kenneth at southpole.se
Fri Jul 25 22:51:09 CEST 2008


On Fri, 2008-07-25 at 20:35 +0200, Haavard Skinnemoen wrote:
> On Fri, 25 Jul 2008 19:28:48 +0200
> kenneth johansson <kenneth at southpole.se> wrote:
> 
> > I was afraid that what was needed was more or less a complete linker but
> > it looks like if one generate the dynamic reloc table a much simpler
> > linker(relocation function) is needed. Still probably a lot more complex
> > than the GOT and fixup code that is just a loop over a table. We may
> > need a case also ;-) 
> 
> Hmm...looks like linking with -pie (or --pic-executable) does
> something vaguely resembling the trick. But I don't know what vintage
> of ld you need for this to be available and actually work...

Can't see any reason for using this flag over -fPIC for a program like
u-boot.

> hskinnemoen at siona:~/work/u-boot/master$ avr32-linux-readelf -d u-boot
> 
> Dynamic section at offset 0x1b8f0 contains 12 entries:
>   Tag        Type                         Name/Value
>  0x00000004 (HASH)                       0x182ac
>  0x00000005 (STRTAB)                     0x18260
>  0x00000006 (SYMTAB)                     0x18150
>  0x0000000a (STRSZ)                      74 (bytes)
>  0x0000000b (SYMENT)                     16 (bytes)
>  0x00000003 (PLTGOT)                     0x1ae70
>  0x70000001 (Processor Specific: 70000001) 0xe6c
>  0x00000015 (DEBUG)                      0x0
>  0x00000007 (RELA)                       0x1833c
>  0x00000008 (RELASZ)                     6996 (bytes)
>  0x00000009 (RELAENT)                    12 (bytes)
>  0x00000000 (NULL)                       0x0
> 
> The dynamic relocation section became surprisingly large. I wonder if
> we actually manage to manually relocate all those buggers...I checked a
> couple of them and in both cases it looked like something that needed
> to be relocated, but I couldn't find any code that actually did it.

yes it's scary that it's working as well as it does. This is however
solved by reactivating Grant Likely's patch.

> One example from common/cmd_itest.c:
> 
> op_tbl_t op_table [] = {
>         { "-lt", LT },
>         { "<"  , LT },
>         { "-gt", GT },
>         { ">"  , GT },
>         { "-eq", EQ },
>         { "==" , EQ },
>         { "-ne", NE },
>         { "!=" , NE },
>         { "<>" , NE },
>         { "-ge", GE },
>         { ">=" , GE },
>         { "-le", LE },
>         { "<=" , LE },
> };
> 
> Does this really work without any relocation? Or is it being relocated
> and I'm just too blind to see it?

No you are right there is probably many places like this. the code just
use the old location and that works most of the time.

> The symbol tables can probably be made smaller with some careful
> ldscript tweaking.
> 
> Haavard
> 








More information about the U-Boot mailing list