

Now what we need is at least a special ld-linux.so that can do the following: Now we have a way to load convince macOS to load ELF, we need our special ld-linux.so which itself is a Mach-O executable that would load our ELF and run it. There exists a third party macOS kernel extension that provides exactly that.This would require something like binfmt_misc though. This does make things easier, as the executable file format can be used to distinguish whether the compatibility layer should be called. macOS uses Mach-O as its native executable format while Linux uses ELF.This means that for amd64 macOS and Linux should have compatible ABI and API.

Both macOS and Linux uses System V ABI for amd64 platform.This means in principle POSIX calls should have the same API. Both macOS and a rebranded Red Hat Enterprise Linux have been certified UNIX 03.It is technically doable in macOS but not without significant effort, although some of the effort is already done for us. OS X has a lot of FreeBSD in it, so porting its Linux support might be straightforward. OpenBSD and NetBSD have similar features. This feature appears to be in better shape than the above two. It fell into disrepair during the kernel 2.3 development series, most likely because the small Unix server battle was essentially over once 2.4 came out.įreeBSD's kernel can be configured to recognize Linux binaries and run them as if they were native. Linux's kernel once had a feature called iBCS that did the reverse, except that it didn't need a helper because the kernel recognized the "foreign" binaries directly.
RUN EXE ON MAC OS X ARCHIVE
The official site (down, archive link) says it's bitrotted. Solaris and UnixWare include a helper program called lxrun which works something like sudo: you pass your executable name and parameters to the helper and it fixes things up dynamically so that the executable can talk to the OS. It's been done successfully before on other platforms: The Darling project is attempting this, though as of this writing, it's in a pretty primitive state. This is doable if someone wants to spend enough time to make it happen. Now, I invite the world to correct me,and tell me everything that is wrong with my absurd line of thinking. I am only considering command line programs at this stage. Windowing systems would likely be a whole other headache. I definitely would not even go as far as to think of this with programs with GUI's in mind. so If the very first pillar gets destroyed, I doubt there would be much merit to the remaining tiers. That should be it for now, obviously each step of absurdity relies on the previous base, to even make sense. Printf("I like tortoises, but not porpoises") Ģ.)Assuming this program is compiled and statically linked, would our magical program still be able to repackage the raw binary in the Mach-O format and have it work on mac os X? Seeing as it would not need to rely on any other binaries, (for which the mac system would not have in this case)ģ.)What if we used this supposed program to convert all of the necessary shared libraries to the Mach-O format, and then instead compiled the program above with dynamic linking. We now have a program with source such as: #include
RUN EXE ON MAC OS X MAC OS X
Is not the main difference between the output a matter of ELF vs Mach-O? If one were to strip each binary of the formatting, leaving a flat binary, wouldn't the disassembled machine instructions be the same? (with perhaps a few differences depending on the compilers habits/tendencies).ġ.) If one were to develop a program to repackage the flat binary produced from our Ubuntu system, in the Mach-O formatting, would it run in the Mac OS X system? Then, if one only had the compiled binary of the supposed program above, and one had this mystical tool for repackaging flat binaries, would simple programs be able to run on the Mac OS X system?
RUN EXE ON MAC OS X CODE
The code is extremely simple, because I don't want to consider the implications of shared libraries yet. One compiles an equivalent program, Let us say something like: int main() One is running (insert your linux distro here: Ubuntu will be used henceforth), and the other is running let's say Mac OS X.

We have two systems with similar hardware (main point being the processor, let us say a standard intel core 2 duo). Ready? Ok! I will go through about 3 levels of ludicrosity, increasing as I go along. Brace yourselves, this question will likely appear naive and/or foolish, seeing as I am relatively new to the inner workings of unix like systems, and programming in general.
