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

Zachary Turner via llvm-dev llvm-dev at lists.llvm.org
Sun Jul 22 21:31:28 PDT 2018


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.

On Fri, Jul 20, 2018 at 10:30 AM Reid Kleckner via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Typically people do this kind of thing by writing a loader for the
> executable format you want to run, and they create libc stubs that either
> delegate or reimplement enough functionality to get the app in question to
> run. Wine, for example, uses this approach. It loads native PE executables,
> and implements enough of the win32 API to run some applications.
>
> "Re-linking" would be tough because linking typically throws away static
> relocations that you would need.
>
> On Fri, Jul 20, 2018 at 12:46 AM ardi via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> Hi,
>>
>> Let's suppose we have an ELF executable that doesn't issue any syscall
>> (I mean, syscalls are issued from an external dynamic library, not
>> from the executable, and we can ignore such dynamic library because we
>> have the proper equivalent library with the proper syscalls in MacOS
>> and Windows).
>>
>> So, the question: Is it "currently possible" (by "currently possible"
>> I mean that all the needed tools/code already exist) to somehow
>> "unlink" the code and data from the ELF executable, and relink it as
>> two new executables: one Mach-O and another PE?
>>
>> Would this be possible with just LLVM tools, or would other
>> libraries/tools also be needed?
>>
>> Thanks a lot!
>>
>> ardi
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180722/b68b7bc4/attachment.html>


More information about the llvm-dev mailing list