[U-Boot] U-Boot Relocation (all sections, not just .text)
Graeme Russ
graeme.russ at gmail.com
Fri Oct 10 00:07:51 CEST 2008
Hi All,
I am trying to fully relocate U-Boot out of the Boot Flash into RAM
on my i386 (AMD sc520) board in order to allow the Boot Flash to be
flashed from within U-Boot itself (upgrade in place)
I have added code to patch the command table so all the code can
be relocated. Further investigation revealed that the code has
absolute references into the Boot Flash - printf() format strings
are a prime example, but I'm sure there are others
After a bit of searching around the 'net I discovered gcc's -fpie and
ld's -pie flags which generation a Position Independent Executable.
This looks like it will do the trick - .text is (practically)
identical for varying values of TEXT_BASE and ld produces a .got
section as expected. However, ld creates a lot more sections than
just .got
Before I go down the path of dissecting all this new and wonderful
information, I thought I would quickly ask:
- Am I looking at the problem the wrong way?
- Has anyone here looked into making U-Boot 100% relocatable before?
- Is U-Boot already 100% relocatable (not just code) for any other
platforms?
- Has anyone here used pie before and had to write code to adjust
the offset tables?
- Does anyone know of a good reference for pie / .got / elf (I have
found bits and pieces here and there, but no definitive reference)
And lastly - Is it worth the effort, or I should I just set TEXT_BASE
to a known memory location and not bother with the relocation at all?
tia
Graeme
More information about the U-Boot
mailing list