[llvm-dev] Relinking (syscall-free) ELF executable into Mach-O and PE executables

Zachary Turner via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 23 08:15:43 PDT 2018


I was actually proposing something like where you write a fully working
executable (identical to what the linker writes today), but you
*additionally* write an extra section that contained information about the
type and location of all applied relocations.  This way you could re-write
relocations on a subsequent link where the executable was used as an
input.  I don't know if any linkers currently have a mode where you can do
this though, and it sounds like OP might want to use only functionality
that is currently available in an existing linker today.

On Mon, Jul 23, 2018 at 3:10 AM Pavel Labath <labath at google.com> wrote:

> On Mon, 23 Jul 2018 at 05:31, Zachary Turner via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> >
> > Couldn’t you write the relocations to the ELF executable?  I don’t know
> if current linkers have support for this, but it seems possible in theory
> to make a relinkable executable.  If you want to do this with an already
> linked executable though, then yea this won’t be possible.
>
> You can do a "ld --relocatable" to create an elf file that can be used
> as further input to the linker (so relocations will be preserved,
> etc.). However, that file will not be a fully functional executable
> until you do a final non-relocatable link on it.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180723/38b495d9/attachment.html>


More information about the llvm-dev mailing list