Pan ruochen wrote:
Hi All, I want to create a raw binary excutable for MIPS arch, which can relocate itself to any load address at runtime without an externel loader. How should I compile the sources and write the linker script for this purpose?
The Linux glibc dynamic linker is such a program. So I would say: Do what glibc does. At a minimum you will need to write a little bit of assembly code to calculate the load address at runtime (using the bal instruction) and set the stack pointer. Then if you end up with any relocations you will have to process them. Assuming you use the o32 ABI, if you compile everything with -fpic there will only be relocations for global data. If you can arrange for no global data, you will not have to process any relocations. David Daney