Giter Site home page Giter Site logo

maloader's Introduction

Maloader Build Status

This is a userland Mach-O loader for linux.

Installation

$ make release

Usage

$ ./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 toolchains of Xcode

Recent Xcode toolchains are built by clang/libc++. This means some C++ programs do not work with ld-mac linked against libstdc++. To build ld-mac with clang/libc++, run

$ make clean
$ make USE_LIBCXX=1

You need compiler toolchain binaries on your Linux. unpack_xcode.sh in this repository helps you to set up them if you have a dmg package of Xcode. This script was checked with Xcode 4.3.3, 4.4.1, 4.5.2, 4.6.2, and 5.0.1. It would work even on other Xcode releases, but you may need to modify the script by yourself. How things are stored in dmg packages heavily depend on the version of Xcode. You can use this like

$ ./unpack_xcode.sh ~/Downloads/xcode_5.0.1_command_line_tools*.dmg

This will create xcode_5.0.1_command_line_tools*/root. We will call this directory as $ROOT.

$ ./ld-mac $ROOT/usr/bin/clang --sysroot=$ROOT -c mach/hello.c
$ file hello.o
hello.o: Mach-O 64-bit x86_64 object

To link binaries on Linux, you also need necessary dylibs in root/usr/lib. For example, simple hello world program requires /usr/lib/libSystem.dylib and /usr/lib/system. Do something like

(mac)$ tar -cvzf sys.tgz /usr/lib/libSystem* /usr/lib/system
(mac)$ scp sys.tgz $USER@linux:/tmp
(linux)$ cd $ROOT && tar -xvzf /tmp/sys.tgz

Also note that it seems ld does not like the version number of Xcode. So you need to move xcode_5.0.1_command_line_tools*/root to somewhere else. For example:

$ ln -sf xcode_5.0.1_command_line_tools_10.9_20131022/root
$ ./ld-mac $ROOT/usr/bin/clang --sysroot=$ROOT -g mach/hello.c
$ ./ld-mac ./a.out
Hello, 64bit world!

How to use compiler toolchains of Xcode 3.2.6

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

$ git clone [email protected]: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 release
$ ./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

$ ./binfmt_misc.sh
$ /usr/i686-apple-darwin10/usr/bin/gcc mach/hello.c
$ ./a.out

To remove the entries, run the following command:

$ ./binfmt_misc.sh stop

How to try 32bit support

$ make clean
$ make all BITS=32

If you see permission errors like:

ld-mac: ./mach/hello.c.bin mmap(file) failed: Operation not permitted

you should run the following command to allow users to mmap files to addresses less than 0x10000.

$ sudo sh -c 'echo 4096 > /proc/sys/vm/mmap_min_addr'

Or, running ld-mac as a super user would also work.

How to run both 64bit Mach-O and 32bit Mach-O binaries

$ make both
$ ./binfmt_misc.sh start `pwd`/ld-mac.sh
$ /usr/i686-apple-darwin10/usr/bin/gcc -arch i386 mach/hello.c -o hello32
$ /usr/i686-apple-darwin10/usr/bin/gcc -arch x86_64 mach/hello.c -o hello64
$ /usr/i686-apple-darwin10/usr/bin/gcc -arch i386 -arch x86_64 mach/hello.c -o hello
$ ./hello32
Hello, 32bit world!
$ ./hello64
Hello, 64bit world!
$ ./hello
Hello, 64bit world!
$ LD_MAC_BITS=32 ./hello
Hello, 32bit world!

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
  • clang

not OK

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

Notice

TODO

  • read dwarf for better backtracing
  • make llvm-gcc work
  • improve 32bit support
  • handle dwarf and C++ exception

License

Simplified BSD License or GPLv3.

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/

See http://www.gnu.org/licenses/gpl-3.0.txt for GPLv3.

maloader's People

Contributors

mayah avatar shinh avatar sylvainpelissier avatar yoshisatoyanagisawa avatar yugui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maloader's Issues

maloader problems on Debian Testing

Firstly, maloader won't build properly with gcc/g++ 4.6 on this distribution. It's fairly contemporary with Linux 3.0.0, gcc 4.6, etc.

The 'macho2elf' and 'ldmac' binaries can be made to build by installing:

gcc-4.5
cpp-4.5
libstdc++6-4.5-dev

After installing and running:

CC=gcc-4.5 CXX=g++-4.5 make

XCode 4.0 gcc fails with:

collect2: ld terminated with signal 11 [Segmentation fault]
Segmentation fault(11) 1 (@0x100173b60) PC: 0x1000fbcb5

/opt/darwin/usr/bin/../libexec/gcc/i686-apple-darwin10/4.2.1/ld(lazy_load_dylib+1e0) [0x1000fbcb5(fbcb5)]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf020) [0x7fc6e10cf020]

The installed version of libpthread is 2.13

XCode 4.1 llvm-gcc fails with:

collect2: ld terminated with signal 6 [Aborted]
__cxa_throw: obj=0xb7bf70
library not found for -lcrt1.10.6.o
Aborted(6) -6 (@0x3e800002e25) PC: 0x7f7db146b405

/opt/xcode/usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/ld(_Z6throwfPKcz+b2) [0x1000014d2(14d2)]
/home/alex/machloader/libmac.so(strlcpy+0) [0x7f7db1232897]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x180) [0x7f7db146e680]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35) [0x7f7db146b405]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf020) [0x7f7db1f6e020]

Any help would be appreciated!

qmake help wanted

I'm trying to run qmake with maloader and I get undefined symbols:

$ LD_LIBRARY_PATH=~/opencflite-476.17.2/.libs ~/maloader.git/ld-mac ./bin/qmake
FSCopyAliasInfo: undefined symbol
FSGetCatalogInfo: undefined symbol
FSIsAliasFile: undefined symbol
FSNewAlias: undefined symbol
FSPathMakeRef: undefined symbol
FSPathMakeRefWithOptions: undefined symbol
FSResolveAliasFile: undefined symbol
Gestalt: undefined symbol
LSFindApplicationForInfo: undefined symbol
CFURLCreateFromFSRef: undefined symbol
Segmentation fault(11) 1 (@(nil)) PC: (nil)

linux-gate.so.1(__kernel_rt_sigreturn+0) [0xf778dd80]

Is there any way to get it working?

I'v got some problems with atos and libCoreFoundation.so

Hi. First to say, awsome project i works just wonderful with dwarfdump but when i needed to use "atos" from the xcode toolchain i ran into the problem with libCoreFoundation.so not not beeing found.

i'v got libCoreFoundation.so* in /usr/local/lib/ and as you then can conclude i have installed opencflite-476.19.0 and made it work.

But when i open atos i get:

../xcode_3.2.6_and_ios_sdk_4.3/root/usr/bin/atos -arch armv7
Couldn't load libCoreFoundation.so for /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
NSNonOwnedPointerHashCallBacks: undefined symbol
OBJC_CLASS_$_NSAssertionHandler: undefined symbol
OBJC_CLASS_$_NSAutoreleasePool: undefined symbol
OBJC_CLASS_$_NSMutableString: undefined symbol
OBJC_CLASS_$_NSProcessInfo: undefined symbol
OBJC_CLASS_$_NSString: undefined symbol
_NSConcreteStackBlock: undefined symbol
objc_msgSend_fixup: undefined symbol
objc_msgSend_fixup: undefined symbol
objc_msgSend_fixup: undefined symbol
objc_msgSend_fixup: undefined symbol
objc_msgSend_fixup: undefined symbol
objc_msgSend_fixup: undefined symbol
objc_msgSend_fixup: undefined symbol
objc_msgSend_fixup: undefined symbol
OBJC_CLASS_$_NSMutableArray: undefined symbol
OBJC_CLASS_$_NSMutableDictionary: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
__CFConstantStringClassReference: undefined symbol
AuthorizationCopyRights: undefined symbol
AuthorizationCreate: undefined symbol
AuthorizationFree: undefined symbol
AuthorizationFreeItemSet: undefined symbol
CSIsNull: undefined symbol
CSSourceInfoGetFilename: undefined symbol
CSSourceInfoGetLineNumber: undefined symbol
CSSymbolGetName: undefined symbol
CSSymbolGetRange: undefined symbol
CSSymbolOwnerGetBaseAddress: undefined symbol
CSSymbolOwnerGetName: undefined symbol
CSSymbolOwnerGetSourceInfoWithAddress: undefined symbol
CSSymbolOwnerGetSymbolWithAddress: undefined symbol
CSSymbolicatorCreateWithPathAndArchitecture: undefined symbol
CSSymbolicatorCreateWithTask: undefined symbol
CSSymbolicatorForeachSymbolOwnerAtTime: undefined symbol
CSSymbolicatorGetSymbolOwnerCountAtTime: undefined symbol
CSSymbolicatorGetSymbolOwnerWithAddressAtTime: undefined symbol
NSCountHashTable: undefined symbol
NSCreateHashTable: undefined symbol
NSEndHashTableEnumeration: undefined symbol
NSEnumerateHashTable: undefined symbol
NSHashInsert: undefined symbol
NSNextHashEnumeratorItem: undefined symbol
NXGetArchInfoFromCpuType: undefined symbol
errc: undefined symbol
getprogname: undefined symbol
objc_enumerationMutation: undefined symbol
objc_msgSend: undefined symbol
pidFromHint: undefined symbol
posix_spawnattr_setbinpref_np: undefined symbol
proc_name: undefined symbol
proc_pidinfo: undefined symbol
proc_pidpath: undefined symbol
psName: undefined symbol
task_for_pid: undefined symbol
task_stop_peeking: undefined symbol
Undefined function called

Any ideas on what im doing wrong?

Cheers
Emil

cannot build on ubuntu12.04 using clang3.4

I am trying to compile maloader using clang-3.4 on Ubuntu 12.04 (precise) amd64. Previously, when I compile maloader using gcc-4.6, all went well. The clang-3.4 were installed by apt as instructed http://llvm.org/apt/. Here is my building process.

$ git clone https://github.com/shinh/maloader.git

$ cd maloader

$ export USE_LIBCXX=1

$ make
clang -g -Iinclude -Wall -MMD -fno-omit-frame-pointer -O -m64 -stdlib=libc++ -DUSE_LIBCXX -fPIC -c -o libmac/mac.o libmac/mac.c
clang: warning: argument unused during compilation: '-stdlib=libc++'
clang -shared libmac/mac.o libmac/strmode.c -g -Iinclude -Wall -MMD -fno-omit-frame-pointer -O -m64 -stdlib=libc++ -DUSE_LIBCXX -fPIC -o libmac.so -m64
clang: warning: argument unused during compilation: '-stdlib=libc++'
clang++ -g -Iinclude -Wall -MMD -fno-omit-frame-pointer -O -m64 -stdlib=libc++ -DUSE_LIBCXX -W -Werror -c -o extract.o extract.cc
extract.cc:38:10: fatal error: 'map' file not found

include

     ^

1 error generated.
make: *** [extract.o] Error 1

I have installed gcc-4.8, which has the correspondent header at /usr/include/c++/4.8/profile/map.h

But when I modified the CFLAGS from
GCCFLAGS+=-g -Iinclude -Wall -MMD -fno-omit-frame-pointer -O $(GCC_EXTRA_FLAGS)
to
GCCFLAGS+=-g -Iinclude -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -Wall -MMD -fno-omit-frame-pointer -O $(GCC_EXTRA_FLAGS)

It cannot be linked:

$ make clean
rm -f .o *.d */.o /.d libmac.so extract macho2elf ld-mac

$ make
clang -g -Iinclude -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -Wall -MMD -fno-omit-frame-pointer -O -m64 -stdlib=libc++ -DUSE_LIBCXX -fPIC -c -o libmac/mac.o libmac/mac.c
clang: warning: argument unused during compilation: '-stdlib=libc++'
clang -shared libmac/mac.o libmac/strmode.c -g -Iinclude -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -Wall -MMD -fno-omit-frame-pointer -O -m64 -stdlib=libc++ -DUSE_LIBCXX -fPIC -o libmac.so -m64
clang: warning: argument unused during compilation: '-stdlib=libc++'
clang++ -g -Iinclude -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -Wall -MMD -fno-omit-frame-pointer -O -m64 -stdlib=libc++ -DUSE_LIBCXX -W -Werror -c -o extract.o extract.cc
clang++ -g -Iinclude -I/usr/include/c++/4.8 -I/usr/include/x86_64-linux-gnu/c++/4.8 -Wall -MMD -fno-omit-frame-pointer -O -m64 -stdlib=libc++ -DUSE_LIBCXX -W -Werror -c -o fat.o fat.cc
clang++ extract.o fat.o -o extract -g -I. -W -Wall -m64 -lc++ -lsupc++
/usr/bin/ld: cannot find -lc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [extract] Error 1

So I wander what had happened and how should I specify LDFLAGS

Dwarfdump & libCoreFoundation.so

I'm seeing the following error running dwarfdump.

Couldn't load libCoreFoundation.so for /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEED0Ev: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEED1Ev: undefined symbol
_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5uflowEv: undefined symbol
_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6xsgetnEPcl: undefined symbol
_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6xsputnEPKcl: undefined symbol
_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9showmanycEv: undefined symbol
_ZNSt3__14coutE: undefined symbol
_ZNSt3__15ctypeIcE2idE: undefined symbol
_ZNSt3__17codecvtIcc11__mbstate_tE2idE: undefined symbol
_ZTINSt3__113basic_ostreamIcNS_11char_traitsIcEEEE: undefined symbol
_ZTINSt3__113basic_ostreamIcNS_11char_traitsIcEEEE: undefined symbol
_ZTINSt3__113basic_ostreamIcNS_11char_traitsIcEEEE: undefined symbol
_ZTINSt3__115basic_streambufIcNS_11char_traitsIcEEEE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTINSt3__119__shared_weak_countE: undefined symbol
_ZTv0_n24_NSt3__113basic_ostreamIcNS_11char_traitsIcEEED0Ev: undefined symbol
_ZTv0_n24_NSt3__113basic_ostreamIcNS_11char_traitsIcEEED1Ev: undefined symbol
_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE12find_last_ofEPKcmm: undefined symbol
_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16find_last_not_ofEPKcmm: undefined symbol
_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE17find_first_not_ofEPKcmm: undefined symbol
_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findEPKcmm: undefined symbol
_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4findEcm: undefined symbol
_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEPKc: undefined symbol
_ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv: undefined symbol
_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv: undefined symbol
_ZNKSt3__16locale9has_facetERNS0_2idE: undefined symbol
_ZNKSt3__16locale9use_facetERNS0_2idE: undefined symbol
_ZNKSt3__18ios_base6getlocEv: undefined symbol
_ZNSt3__112__next_primeEm: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE5eraseEmm: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKc: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKcm: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEmc: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKcm: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_mmRKS4_: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev: undefined symbol
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSERKS5_: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryC1ERS3_: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEED2Ev: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEd: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEf: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEi: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEj: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEm: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEt: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEx: undefined symbol
_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEy: undefined symbol
_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEEC2Ev: undefined symbol
_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEED2Ev: undefined symbol
_ZNSt3__119__shared_weak_count12__add_sharedEv: undefined symbol
_ZNSt3__119__shared_weak_count16__release_sharedEv: undefined symbol
_ZNSt3__119__shared_weak_countD2Ev: undefined symbol
_ZNSt3__16localeC1ERKS0_: undefined symbol
_ZNSt3__16localeD1Ev: undefined symbol
_ZNSt3__18ios_base33__set_badbit_and_consider_rethrowEv: undefined symbol
_ZNSt3__18ios_base4initEPv: undefined symbol
_ZNSt3__18ios_base5clearEj: undefined symbol
_ZNSt3__18ios_base5iwordEi: undefined symbol
_ZNSt3__18ios_base6xallocEv: undefined symbol
_ZNSt3__19basic_iosIcNS_11char_traitsIcEEED2Ev: undefined symbol
_ZNSt8bad_castC1Ev: undefined symbol
Undefined function called
Aborted(6) -6 (@0x1f400001d37) PC: 0x7f217c3358a5

dwarfdump [0x100008d2c(8d2c)]
maloader/ld-mac() [0x4025e2]
/lib64/libc.so.6(abort+0x175) [0x7f217c337085]
/lib64/libc.so.6(gsignal+0x35) [0x7f217c3358a5]
/lib64/libpthread.so.0(+0xf500) [0x7f217ce45500]
Aborted

It's on your OK list and I had it running fine at one point, so hopefully you could help out.

segfault in __darwin_fflush()

i was trying to use maloader to run a CLI OSx binary on kubuntu 11.10, 64bit. The program starts up and is able to show its basic usage to the console. however, it crashes when trying to use it to do more stuff. using gdb, i tracked the crash back to "int __darwin_fflush(__darwin_FILE* fp)". it is somehow being passed a NULL pointer, which isnt handled, and leads to a segfault. changing this function to check for NULL pointer fixes the crash and the program runs normally.

the man page for fflush() says that it is supposed to handle NULL pointer as a special case.
http://www.manpagez.com/man/3/fflush/

this is how i have changed it in my own code. i havents actually looked into how maloader is working, so it may be completely wrong.

int __darwin_fflush(__darwin_FILE* fp) {
if( !fp )
{
return fflush( NULL );
}
return fflush(fp->linux_fp);
}

Error when compiling

sudo make release
make clean
make[1]: Entering directory '/root/Downloads/maloader'
rm -f *.o *.d /.o /.d libmac.so extract macho2elf ld-mac
make[1]: Leaving directory '/root/Downloads/maloader'
make all "GCC_EXTRA_FLAGS=-DNOLOG -DNDEBUG"
make[1]: Entering directory '/root/Downloads/maloader'
cc -g -Iinclude -Wall -MMD -fno-omit-frame-pointer -O -DNOLOG -DNDEBUG -fPIC -c -o libmac/mac.o libmac/mac.c
cc -shared libmac/mac.o libmac/strmode.c -g -Iinclude -Wall -MMD -fno-omit-frame-pointer -O -DNOLOG -DNDEBUG -fPIC -o libmac.so -DNOLOG -DNDEBUG -luuid -lz
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
Makefile:92: recipe for target 'libmac.so' failed
make[1]: *** [libmac.so] Error 1
make[1]: Leaving directory '/root/Downloads/maloader'
Makefile:47: recipe for target 'release' failed
make: *** [release] Error 2

On libcs with warn_unused_result on fwrite, maloader doesn't compile

fwrite is, in at least some recent versions of glibc, marked as warn_unused_result. Since maloader in a number of places discards the result of fwrite and the Makefile specifies -Werror, it fails to compile on these systems. Disabling -Werror in the Makefile is a workaround.

The sys info of the system I'm testing on:

Gentoo Base System release 1.12.13
GNU C Library stable release version 2.10.1 (Compiled by GNU CC version 4.3.4)
gcc (Gentoo 4.3.4 p1.1, pie-10.1.5) 4.3.4
g++ (Gentoo 4.3.4 p1.1, pie-10.1.5) 4.3.4

Rez - any advice appreciated

I'm calling

LD_LIBRARY_PATH=/usr/local/lib32 ./ld-mac32 /usr/i686-apple-darwin10/usr/bin/Rez

and the dump is

__is_threaded: undefined symbol
AddResource: undefined symbol
BlockMoveData: undefined symbol
CharacterByteType: undefined symbol
CloseResFile: undefined symbol
CopyPascalStringToC: undefined symbol
CoreEndianFlipData: undefined symbol
Count1Resources: undefined symbol
CurResFile: undefined symbol
DateToSeconds: undefined symbol
Debugger: undefined symbol
DisposeHandle: undefined symbol
FSClose: undefined symbol
FSCreateResourceFile: undefined symbol
FSGetDataForkName: undefined symbol
FSGetResourceForkName: undefined symbol
FSRead: undefined symbol
FSWrite: undefined symbol
FSpDelete: undefined symbol
FSpMakeFSRef: undefined symbol
FSpOpenDataForkAsResourceFile: undefined symbol
FSpOpenResFile: undefined symbol
Get1IndResource: undefined symbol
Get1NamedResource: undefined symbol
Get1Resource: undefined symbol
GetDateTime: undefined symbol
GetEOF: undefined symbol
GetResAttrs: undefined symbol
GetResFileAttrs: undefined symbol
GetResInfo: undefined symbol
HLock: undefined symbol
HNoPurge: undefined symbol
HPurge: undefined symbol
HUnlock: undefined symbol
HomeResFile: undefined symbol
NativePathNameToFSSpec: undefined symbol
PBHGetFInfoSync: undefined symbol
PBHOpenDFSync: undefined symbol
PBHOpenRFSync: undefined symbol
PBHSetFInfoSync: undefined symbol
PtrToHand: undefined symbol
ReleaseResource: undefined symbol
RemoveResource: undefined symbol
ResError: undefined symbol
SecondsToDate: undefined symbol
SetEOF: undefined symbol
SetFPos: undefined symbol
SetResAttrs: undefined symbol
SetResInfo: undefined symbol
SetResLoad: undefined symbol
UpdateResFile: undefined symbol
UseResFile: undefined symbol
WriteResource: undefined symbol
Undefined function called
Aborted(6) -6 (@0x4787) PC: 0xf7780430

0x1
/usr/i686-apple-darwin10/usr/bin/Rez(_mh_execute_header+8ad) [0x18ad(8ad)]
/usr/i686-apple-darwin10/usr/bin/Rez(_mh_execute_header+21a0) [0x31a0(21a0)]
./ld-mac32() [0x804a1bc]
/lib/libc.so.6(abort+0x143) [0xf7485c03]
/lib/libc.so.6(gsignal+0x4f) [0xf748431f]
linux-gate.so.1(__kernel_vsyscall+0x10) [0xf7780430]
linux-gate.so.1(__kernel_rt_sigreturn+0) [0xf7780410]
Aborted

I've found the Rez is 32bit app so I've compiled OpenCF Lite as 32bit and placed it to /usr/local/lib32 (/usr/local/lib contains 64bit OpenCF Lite as well). The 32bit apps (like hello world) are works. But some of them produces an errors (I guess it is because it uses Carbon functions).

Not sure but maybe there is a workaround available?

I've copied most of the MacOSX 10.6 contents (except /Applications) to my linux box.

The otool running from the linux displays the following:

$ ./ld-mac32 /usr/i686-apple-darwin10/usr/bin/otool -L /usr/i686-apple-darwin10/usr/bin/Rez
/usr/i686-apple-darwin10/usr/bin/Rez (architecture i386):
        /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 44.0.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 830.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.29.0)
/usr/i686-apple-darwin10/usr/bin/Rez (architecture ppc7400):
        /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 44.0.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 830.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.29.0)

The /System and /Library are symlinks to the mac installation as well as /usr/lib/system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.