Pergunta

Is it possible to relocate an already linked elf file to another address and update internal references too ?

For example, having a statically linked elf file linked at 0x50000, how can I move it to 0x1000000 and update pointers & addresses ?

Foi útil?

Solução

Is it possible to relocate an already linked elf file to another address

In general: no. The linker discards relocation records, required to update internal references within the executable.

Now, if your executable uses no global data and doesn't take addresses of any functions, and you are on an architecture where JMPs and CALLs are pc-relative, then it might be possible to just update the PT_LOAD segments and .e_entry in the Elf{32,64}_Ehdr.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top