How to dynamically load a Relocatable ELF executable?

I am trying to write an elf executable bootloader for the ARM platform. I have some queries here

1) How to create an executable file that is relocatable or independent in position of ELF (what are the parameters of the compiler and linker) 2) How to load this generated ELF executable file.

Like astart, I did some work and it works fine. I use a fixed address for RO_Base and do not split segments when building (without using any --split option), so I get continuous code, data, bss sections. after that, I load the elf to the same address as RO_Base, and execute the code as a new thread. it works fine. I did not make any moves, etc.

Now I want to make it dynamic and able to load to any address, creating a roaming ELF and modifying Loader for the corresponding changes. Please help me in his work.

Thanks,

+5
source share
2 answers

Just use the -r flag for the linker to make the file moveable.

Use something like this to move the file to memory.

0
source

This is a big topic. I will come to the link "Linkers and loaders" by John R. Levin. Here is the manuscript of the book, Chapter 7 Moving , I hope this is useful

0
source

All Articles