···11-This is a userland Mach-O loader for linux.
22-33-* Usage
44-55-% make release
66-% ./ld-mac mac_binary [options...]
77-88-You need OpenCFLite (http://sourceforge.net/projects/opencflite/)
99-installed if you want to run some programs such as dsymutil.
1010-opencflite-476.17.2 is recommended.
1111-1212-* How to use compiler tool chains of Xcode
1313-1414-Get xcode_3.2.6_and_ios_sdk_4.3__final.dmg (or another xcode package).
1515-1616-% git clone git@github.com:shinh/maloader.git
1717-% ./maloader/unpack_xcode.sh xcode_3.2.6_and_ios_sdk_4.3__final.dmg
1818-% sudo cp -a xcode_3.2.6_and_ios_sdk_4.3__final/root /usr/i686-apple-darwin10
1919-% cd maloader
2020-% make release
2121-% ./ld-mac /usr/i686-apple-darwin10/usr/bin/gcc mach/hello.c
2222-% ./ld-mac a.out
2323-2424-* How to run Mach-O binaries using binfmt_misc
2525-2626-% ./binfmt_misc.sh
2727-% /usr/i686-apple-darwin10/usr/bin/gcc mach/hello.c
2828-% ./a.out
2929-3030-To remove the entries, run the following command:
3131-3232-% ./binfmt_misc.sh stop
3333-3434-* How to try 32bit support
3535-3636-% make clean
3737-% make all BITS=32
3838-3939-If you see permission errors like
4040-4141-ld-mac: ./mach/hello.c.bin mmap(file) failed: Operation not permitted
4242-4343-you should run the following command to allow users to mmap files to
4444-addresses less than 0x10000.
4545-4646-% sudo sh -c 'echo 4096 > /proc/sys/vm/mmap_min_addr'
4747-4848-Or, running ld-mac as a super user would also work.
4949-5050-* How to run both 64bit Mach-O and 32bit Mach-O binaries
5151-5252-% make both
5353-% ./binfmt_misc.sh start `pwd`/ld-mac.sh
5454-% /usr/i686-apple-darwin10/usr/bin/gcc -arch i386 mach/hello.c -o hello32
5555-% /usr/i686-apple-darwin10/usr/bin/gcc -arch x86_64 mach/hello.c -o hello64
5656-% /usr/i686-apple-darwin10/usr/bin/gcc -arch i386 -arch x86_64 mach/hello.c -o hello
5757-% ./hello32
5858-Hello, 32bit world!
5959-% ./hello64
6060-Hello, 64bit world!
6161-% ./hello
6262-Hello, 64bit world!
6363-% LD_MAC_BITS=32 ./hello
6464-Hello, 32bit world!
6565-6666-* Which programs should work
6767-6868-OK
6969-7070-- gcc-4.2 (link with -g requires OpenCFLite)
7171-- otool
7272-- nm
7373-- dyldinfo
7474-- dwarfdump
7575-- strip
7676-- size
7777-- dsymutil (need OpenCFLite)
7878-- cpp-4.2
7979-- clang
8080--- clang-70 (xcode 3.2.6): OK, but linking wasn't checked due to lack of sysroot
8181--- clang-137 (xcode 4.0): OK
8282-8383-not OK
8484-8585-- llvm-gcc
8686-- gnumake and bsdmake
8787-- lex and flex
8888-- ar
8989-- m4
9090-- gdb
9191-- libtool
9292-- nasm and ndisasm (i386)
9393-- mpicc, mpicxx, and mpic++
11+This is a userspace compatibility layer for runniing Darwin/OS X binaries on Linux.
22+For more information, visit http://darling.dolezel.info
9439595-* Notice
9696-9797-- Running all Mac binaries isn't my goal. Only command line tools such
9898- as compiler tool chain can be executed by this loader.
9999-- A slide about this: http://shinh.skr.jp/slide/ldmac/000.html
100100-101101-* TODO
102102-103103-- read dwarf for better backtracing
104104-- make llvm-gcc work
105105-- make ld in xcode4 work
106106-- improve 32bit support
107107-- handle dwarf and C++ exception
108108-109109-* License
110110-111111-Simplified BSD License.
112112-113113-Note that all files in "include" directory and some files in "libmac"
114114-were copied from Apple's Libc-594.9.1.
115115-http://www.opensource.apple.com/release/mac-os-x-1064/