MacOSX/QemuWork

The goal of qemu-darwin-user is to run darwin/x86 process on a darwin/ppc host (and vice versa). It would allow wine/darwin/x86 to run on a Mac OS X/PPC host.

qemu-darwin-user is also known as Attesor for inversed Rosetta.

Status

  • PowerPC on PowerPC: simple app without dyld works. Simple App should work providing that you are running on a 32 bits PowerPC.
  • Intel x86 on PowerPC: simple app without dyld works. Simple App using the dynamic linker works with dyld from Mac OS X 10.4.6 (eg: bin/ls).

Screenshot

Here is a "screenshot" of ls for Mac OS X/x86 running threw qemu-darwin-user on a iMac G5.

iMac-G5:/Volumes/Builds/Build8C46/BuildRoot steg$ uname -p && file bin/ls
powerpc
bin/ls: Mach-O fat file with 1 architecture
bin/ls (for architecture i386): Mach-O executable i386
iMac-G5:/Volumes/Builds/Build8C46/BuildRoot steg$ qemu-i386 -L /Volumes/Builds/Build8C46/BuildRoot/ -d in_asm bin/ls
Starting bin/ls with qemu
----------------
AppleInternal   Network         Users           cores           mach            sbin            var
Developer       SourceCache     XCD             dev             mach_kernel     tmp
Library         System          bin             etc             private         usr

Todo

Major issues

  • <strike>implement signal handling.</strike>

  • support threading.
  • <s>make qemu-user able to launch executable at the default address space (0x1000)</s> patch.

  • <s>understand why the commpage doesn't have valid ppc32 instruction on a Mac/ppc</s> (because I am on a 64 bits Proc!).

Minor issues

  • finish syscall implementation
    • ioctls.
    • fcntl.
    • ...
  • finish the commpage handling.
  • merge with qemu cvs:
    • <s>Remove the old lcall hack, so we don't need hack in libqemu</s> patch

    • Prepare a patch against qemu cvs

Get the code

cvs -d:pserver:anonymous:@darwine.cvs.sourceforge.net:/cvsroot/darwine checkout qemu

Prepare the build/test environment

  • Make sure you have the latest Developer Tools
  • check if the x86 build environment is present:

$ file /Developer/SDKs/MacOSX10.4u.sdk/usr/lib/libSystem.B.dylib 

which should report:

/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/libSystem.B.dylib: Mach-O fat file with 3 architectures
/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/libSystem.B.dylib (for architecture ppc64):     Mach-O 64-bit dynamically linked shared library stub ppc64
/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/libSystem.B.dylib (for architecture i386):      Mach-O dynamically linked shared library stub i386
/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/libSystem.B.dylib (for architecture ppc):       Mach-O dynamically linked shared library stub ppc

Build a FAT dyld using darwinbuild

$ hdiutil create -size 4g -type UDIF -fs HFSX -volname Builds -uid 0 -gid 0 -attach Builds.dmg
  • Initialize the image

$ cd /Volumes/Builds
$ sudo mkdir Build8C46
$ cd Build8C46
$ sudo darwinbuild -init 8C46
  • build dyld

$ sudo darwinbuild dyld

Build the code

  • Make sure gcc-3.3 is used: gcc-4.0 can't build qemu.

$ sudo gcc_select 3.3
  • Then you can just type:

$ ./configure --target-list="i386-darwin-user ppc-darwin-user"
$ make
$ sudo make install

Test it

  • Simple helloworld wich doesn't relay on dyld (darwin dynamic linker)

$ cd path/to/qemu
$ gcc -g -arch i386  -seg1addr 0x500000 -e _main -nostdlib -o helloworld-i386-nostd tests/helloworld-i386-nostd.c 
$ i386-darwin-user/qemu-i386 -L /Volumes/Builds/Build8C46/BuildRoot/ -d in_asm,cpu /absolute/path/to/helloworld-i386-nostd
  • helloworld with dyld (darwin dynamic linker) not relocated

$ cd path/to/qemu
$ gcc -g -arch i386 -o helloworld-i386 tests/helloworld.c -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/
$ i386-darwin-user/qemu-i386 -L /Volumes/Builds/Build8C46/BuildRoot/ -d in_asm,cpu /absolute/path/to/helloworld-i386
  • printenv from the darwinbuild root

$ cd /Volumes/Builds/Build8C46/BuildRoot/usr/bin
$ qemu-i386 -L /Volumes/Builds/Build8C46/BuildRoot/ printenv

Links

MacOSX/QemuWork (last edited 2008-05-03 02:43:37 by nathan.n)