[U-Boot] ARM relocation, question to Heiko

Albert ARIBAUD albert.aribaud at free.fr
Mon Oct 4 10:28:48 CEST 2010


Le 04/10/2010 09:27, Reinhard Meyer a écrit :
> Dear Albert ARIBAUD,
>>
>> Right now I can build (not run, mind you) u-boot for edminiv2 without
>> -fPIC/-fPIE, with -pie and a modified u-boot.lds and start.S. Almost all
>> of the .rel.dyn fixup entries are type 23, that is, relative to the base
>> address, which is good. However, here are about ten at the end which are
>> type 2 -- symbol-relative -- and I am studying them in order to see if
>> they are needed.
>>
>> If type 23 relocations are all that is needed, then a first ARM ELF
>> relocation implementation should 'simply' trade GOT vs .rel.dyn
>> relocation in start.S (I am almost there) and remove fixups in
>> board_init_r. Start.S would apply type 23 fixups only and ignore the
>> rest. Later on we could add a build stage to rewrite the .rel.dyn
>> section as suggested, by filtering out non-type-23 relocs and keeping
>> only the address part of type-23 ones, reducing the .rel.dyn table
>> roughly by half.
>>
>> The good news is, I can spare a couple more hours today on this. I'll
>> let you all know how this fares!
>
> Thats good news! How much did the image size increase with this table?

./MAKEALL edminiv2 results:

    text	   data	    bss	    dec	    hex	filename
  141376	   4388	  16640	 162404	  27a64	./u-boot (for GOT reloc)
  150160	   3819	  16640	 170619	  29a7b	./u-boot (for ELF reloc)

u-boot.bin size in bytes:

  145764 (for GOT reloc)
  153976 (for ELF reloc)

The .rel.dyn table is 18472 bytes, and should eventually shrink by half, 
losing about 9 KB. That would bring the u-boot.bin size down to
145 KB, roughly the same size as GOT reloc -- plus we'd save a few code 
bytes since reloc fixup functions in board_init_r would not be needed 
any more.

> And I am willing to test your efforts on AT91 here, maybe you can send me
> the changes to .lds and start.S beforehand so I can see what type of
> relocation info gets produced here.

I'll post an RFC patch within one or two hours.

> A rather wild, but quite arch independant additional "build stage" for
> relocation would be to link u-boot for two different TEXT_BASE values
> e.g. TEXT_BASE (as desired) and TEXT_BASE+0x00010010. A special "diff"
> tool should find the 32 bit places where relocation is required and
> add a table to the end of u-boot.bin... (Just a rough idea)

That would be the simplest option even though it's obviously not 
optimal. Feel free to start this if you want, and let's meet at the 
bridge. :)

> Best Regards,
> Reinhard

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list