Darwin/macOS emulation layer for Linux
Go to file
2011-03-16 23:50:54 +09:00
include The first code commit. 2011-03-10 00:55:54 +09:00
libmac Add getc and dummy implementations for signals 2011-03-16 23:50:54 +09:00
mach Add a test for ctor and dtor. 2011-03-16 09:30:48 +09:00
extract.cc Add fat.h and fat.cc to share code in extract.cc 2011-03-11 02:52:03 +09:00
fat.cc Add fat.h and fat.cc to share code in extract.cc 2011-03-11 02:52:03 +09:00
fat.h Add fat.h and fat.cc to share code in extract.cc 2011-03-11 02:52:03 +09:00
ld-mac.cc Split MachOLoader::load into 2 functions. 2011-03-16 15:04:47 +09:00
mach-o.cc Store LC_LOAD_DYLIB 2011-03-16 14:55:36 +09:00
mach-o.h Store LC_LOAD_DYLIB 2011-03-16 14:55:36 +09:00
macho2elf.cc The first code commit. 2011-03-10 00:55:54 +09:00
Makefile Link pthread from ld-mac to workaround a gdb bug 2011-03-16 23:49:56 +09:00
no_trampoline.tab The first code commit. 2011-03-10 00:55:54 +09:00
README Update README to notice OpenCFLite 2011-03-16 09:22:52 +09:00
rename.tab Add getc and dummy implementations for signals 2011-03-16 23:50:54 +09:00
unpack_xcode.sh Fix symlinks in unpack_xcode.sh 2011-03-15 04:25:12 +09:00

This is a Mach-O loader for linux.

* Usage

% make
% ./ld-mac mac_binary [options...]

You need OpenCFLite (http://sourceforge.net/projects/opencflite/)
installed if you want to run some programs such as dsymutil.
opencflite-476.17.2 is recommended.

* How to use compiler tool chains of Xcode

Get xcode_3.2.6_and_ios_sdk_4.3__final.dmg (or another xcode package).

% git clone git@github.com:shinh/maloader.git
% ./maloader/unpack_xcode.sh xcode_3.2.6_and_ios_sdk_4.3__final.dmg
% sudo cp -a xcode_3.2.6_and_ios_sdk_4.3__final/root /usr/i686-apple-darwin10
% cd maloader
% make
% ./ld-mac /usr/i686-apple-darwin10/usr/bin/gcc mach/hello.c
% ./ld-mac a.out

* How to run Mach-O binaries using binfmt_misc

% sudo sh -c 'echo :Mach-O fat:M::\\xca\\xfe\\xba\\xbe::/home/i/wrk/maloader/ld-mac: > /proc/sys/fs/binfmt_misc/register'
% sudo sh -c 'echo :Mach-O 64bit:M::\\xcf\\xfa\\xed\\xfe::/home/i/wrk/maloader/ld-mac: > /proc/sys/fs/binfmt_misc/register'
% /usr/i686-apple-darwin10/usr/bin/gcc mach/hello.c
% ./a.out

To remove the entries, run the following commands:

% sudo sh -c 'echo -1 > /proc/sys/fs/binfmt_misc/Mach-O\ fat'
% sudo sh -c 'echo -1 > /proc/sys/fs/binfmt_misc/Mach-O\ 64bit'

* Which programs should work

OK

- gcc-4.2 (link with -g requires OpenCFLite)
- otool
- nm
- dyldinfo
- dwarfdump
- strip
- size
- dsymutil (need OpenCFLite)
- cpp-4.2

not OK

- llvm-gcc
- gnumake and bsdmake
- lex and flex
- ar
- m4
- gdb
- libtool
- nasm and ndisasm (i386)
- mpicc, mpicxx, and mpic++

* Notice

- Running all Mac binaries isn't my goal. Only command line tools such
  as compiler tool chain can be executed by this loader.
- Currently, this only supports x86-64.

* License

Simplified BSD License.

Note that all files in "include" directory and some files in "libmac"
were copied from Apple's Libc-594.9.1.
http://www.opensource.apple.com/release/mac-os-x-1064/