On 05/10/07 16:42 -0600, Jordan Crouse wrote:
Okay - based on my previous e-mail, attached is the custom tool that I wrote to change the relative addresses of the initram binary so that it can be placed at an arbitrary place in the ROM and still work.
To start with, we ask LD to emit the relocation info for the segment into the ELF. The relocation tables list everywhere in the binary where a symbol reference is made. Using that information, we can easily walk the table and adjust each all the relative offsets so that they will work from a base address specified on the command line.
This tool just changes the code - a more complete solution would probably rewrite the entire ELF file so the offset was correct - I think thats as easy as re-writing the sh_addr for the sections, but I don't know for sure. I had to take a crash course in how relocs worked (thanks a million to Eric Biderman for arch/i386/boot/compressed/relocs.c in the Linux kernel
- it taught me much, and I borrowed some of the functions for this utility
too).
<SNIP>
I'm rambling, so I'm going to leave you here. Comments especially welcome, if I can do something smarter or better, I'm very interested to hear about it.
It occurs to me after all this that objcopy can do the same thing, and probably better. So we might be able to get away with no custom applications, unless we want to do the symbol table thing that we discussed before, and then this script would be useful for that (and I have a version of it that reads a custom symbol table). So much of this was probably for naught, but i learned a ton.
Jordan