[uClinux-dev] elf2flt problem ARM

Thomas Ritter thritter_list at gmx.at
Wed Oct 26 19:57:44 EDT 2005


Hi,

I'm trying to use PIC code on an uClinuc ARM platform using gcc-3.4.4. With
this setup I'm running into problems when loading the FLAT file - the binary
loader complains on failed relocations.

Non PIC compiled/linked binaries work fine.

After digging into the problem I think I found the cause, but yet no real
solution:

As far as I understand it - the elf2flt tools do a 4x linking 
-> intermediate linking to out.elf2flt 
  -> linking out.elf2flt to out.elf (has relocations)
  -> linking out.elf2flt to out.gdb (is absolute)
finally calling elf2flt to build the result.

In this last step it is an implicit precondition, that the .data section of
the .elf and the .gdb file are equal (not considering the missing GOT in the
.elf file and the relocations of course).

Well - with my gcc-3.4.4 this is not true. The .data section of the .gdb
file is smaller than the one of the .elf file - the link for the .gdb seems
to opimize multiple const strings away. This results that the locations
(vma's) of the relocations in the .elf file donot match the ones in the .gdb
file.
   
Assuming that all "addresses" needing relocation are in the last part of the
data section, I changed elf2flt.c and do not add the GOT size to the
relocation-symbol-address but the size-offset of the 2 data-sections. This
seems to work at least for my simple hello world.

Q: Is this assumption resonable (all relocations are always at the .data
end) ?
Q: Anybody has already run into this problem and a better solution or a
better idea ?

Attached are the data section objdumps of .gdb and .elf (with the data-vma
increased by GOT size to do an easier compare). 

Thanks for any tips,

Tom









-- 
Telefonieren Sie schon oder sparen Sie noch?
NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: data-elf.txt
URL: <http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20051027/f33bc1f9/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: data-gdb.txt
URL: <http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20051027/f33bc1f9/attachment-0001.txt>


More information about the uClinux-dev mailing list