Emulating Linux binaries under Mac OS X

前端 未结 6 1291
Happy的楠姐
Happy的楠姐 2021-02-01 16:11

How do I run Linux binaries under Mac OS X?

Googling around I found a couple of emulators but none for running Linux binaries on a Mac. There are quite a few posts about

6条回答
  •  孤独总比滥情好
    2021-02-01 16:52

    Well there is a project introducing something like Linux's binfmt_misc to OS X so now what you need is an ELF loader, a dynamic linker that can load both Mach-O and ELF, and some mechanism to translate Linux calls to OS X ones.

    Just for inspiration, you can implement the dynamic linker in the fashion that it ignores filename extension - both libfoo.so.1 (as an Linux ELF) and libfoo.1.dylib (as an Mach-O) can be loaded so that OS X versions of system libraries can be reused so that you do not need to write a "hosted on OS X" libc.so and syscalls can be handled by an kext that translates Linux calls to OS X ones in kernel.

    Or, in an more elegant way, implement a stripped down Linux kernel as a kext that makes the OS X kernel a dual-purpose. However that will require you to use two sets of libraries. (Binaries do not clash so it is largely okay)

提交回复
热议问题