Section A.4. Universal Binaries


A.4. Universal Binaries

We discussed the structure of a Universal Binary in Chapter 2. In the x86 version of Mac OS X, almost all[2] Mach-O executablesincluding the kernelare Universal Binaries.

[2] The executable that corresponds to Rosetta is not Universalit is x86-only.

Even with a Universal installation of the entire operating system, for such an installation to boot on both the PowerPC and x86 platforms, the respective firmware implementations will have to understand the partitioning scheme in use.


$ file /mach_kernel /mach_kernel: Mach-O universal binary with 2 architectures /mach_kernel (for architecture ppc):    Mach-O executable ppc /mach_kernel (for architecture i386):   Mach-O executable i386 $ lipo -thin ppc /mach_kernel -output /tmp/mach_kernel.ppc $ lipo -thin i386 /mach_kernel -output /tmp/mach_kernel.i386 $ ls -l /tmp/mach_kernel.* -rw-r-----   1 amit  wheel  4023856 Feb  4 17:30 /tmp/mach_kernel.i386 -rw-r-----   1 amit  wheel  4332672 Feb  4 17:30 /tmp/mach_kernel.ppc


Note that the x86 kernel is somewhat smaller than the PowerPC kernel. Let us look at another examplethat of the system library.

... -rw-r-----   1 amit  wheel  1873472 Feb  4 17:30 /tmp/libSystem.B.dylib.i386 -rw-r-----   1 amit  wheel  2216288 Feb  4 17:30 /tmp/libSystem.B.dylib.ppc


Again, we see that the x86 version of the system library is somewhat smaller. In general, x86 binaries are smaller than PowerPC binaries. One reason is that the latter has a fixed instruction size (4 bytes, with 4-byte alignment), whereas the x86 has variable-size instructions (ranging from 1 byte to over 10 bytes). Figure A3 shows a simple experiment to compare the size of an "empty" C program's executables when the program is compiled for x86, PowerPC, and 64-bit PowerPC.

Figure A3. Compiling an "empty" C program on the x86, PowerPC, and 64-bit PowerPC

$ cat empty.c main() {} $ gcc -arch i386 -o empty-i386 empty.c $ gcc -arch ppc -o empty-ppc empty.c $ gcc -arch ppc64 -o empty-ppc64 empty.c $ ls -l empty-* -rwxr-xr-x   1 amit  wheel  14692 Feb  4 17:33 empty-i386 -rwxr-xr-x   1 amit  wheel  17448 Feb  4 17:33 empty-ppc -rwxr-xr-x   1 amit  wheel  14838 Feb  4 17:33 empty-ppc64




Mac OS X Internals. A Systems Approach
Mac OS X Internals: A Systems Approach
ISBN: 0321278542
EAN: 2147483647
Year: 2006
Pages: 161
Authors: Amit Singh

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net