Executing ELF binaries in OSX
The answer is probably: Depends on how the ELF file was generated.
Based on this article, and this sentence:
- A common misconception is that ELF files are just for executables...
- We already have seen they can be used for partial pieces ...
Not all ELF files will be executed, even if you have a proper setup.
Based on this article, there is a group pf ELF files called FatELF:
- FatELF is a file format that embeds multiple ELF binaries for different architectures into one file
- Ship one file that works across Linux and FreeBSD
Based on this page from Apple
- The BSD portion of the OS X kernel is derived primarily from FreeBSD
So, for Mac OS X, FatELF is the "beginning of the answer".
And finally, based on this page:
Object file converter
This utility can be used for converting object files between COFF/PE, OMF, ELF and Mach-O formats for all 32-bit and 64-bit x86 platforms. Can modify symbol names in object files. Can build, modify and convert function libraries across platforms. Can dump object files and executable files. Also includes a very good disassembler supporting the SSE4, AVX, AVX2, AVX512, FMA3, FMA4, XOP and Knights Corner instruction sets. Source code included (GPL).
You have a chance to active what you want.
PS: there is another page about XBinary, I didn't analyze it.
This document discusses XBinary, a new software that lets you add kernel-level support for executing files in arbitrary binary formats on Mac OS X
On its own, ELF binaries mean nothing. Few binaries run alone - You'd need supporting libraries, APIs and ABIs and other shiny things.
When running QEMU you still need most of the OS - just that its not tied as closely with the host system I suspect.
In theory if you had something like 'wine' but acting as a linux(or other *nix syle OS) -> OS X compatibility layer you could get what you want, but such a beast does not exist.
SO no, you can't run an arbitary, precompiled ELF binary on OS X