Turbo's OSX "Snow Leopard" 10.6.9 Update Project and hacks @ 0xfeedbeef.com

Here's a list of some things I've done to support OSX 10.6.8 on my MacBook Pro. If you brick your computer trying a hack listed here, it's not my fault.

If you're not comfortable messing around with the command line, turn back now.

GOAL: Update Snow Leopard components using available open source code to provide the latest updates for users on OSX 10.6.8
 Purpose: There are a number of people who think that OSX 10.6 was Apple's best version - myself included.
  Apple stopped providing support for 10.6 years ago. I propose to rectify this situation using available Open source code from Apple as well as third parties.
 Notes: Updates should include both security updates and feature updates to support newer software versions.
  I have begin work on this, starting with an updated compiler (Clang 3.3 targeting OSX 10.6)

TODO: Document how to build an updated clang-3.3 with the special sauce

Update dyld so Clang can use TLV (Thread Local Variables)
 Purpose: Lots of newer code (such as WebKit) expect to be able to use TLV, which weren't available in dyld on 10.6.8
 Notes: I first looked at implementing this by building dyld-195 for 10.6, but there is a bunch of missing code.

  This also requires patches to Apple's version of clang, and ld, to allow use of TLS/TLV on 10.6.

  It turns out that supporting TLV on 10.6.8 doesn't actually need much code, so we hack libSystem a bit to trick it into loading a TLV support dylib.
  Every app on OSX requires libSystem, so this is a good place to start.
  libSystem.dylib has a dependency on /usr/lib/system/libmathCommon.A.dylib, lets hijack that and use it to force load our TLV support.
  Start with the source code for dyld-195.6, and without building the whole thing make a new dylib with the code we want

clang -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.9.sdk \ -dynamiclib -current_version 1.0 -compatibility_version 1.0 \ -Wl,-reexport_library,/usr/lib/system/libmathCommon.A.dylib -install_name libtlv.dylib -init _tlv_initializer -flat_namespace \ -o /tmp/libtlv.dylib -I $PWD/include/mach-o $PWD/src/threadLocalHelpers.s $PWD/src/threadLocalVariables.c

 Notes: It turns out that compiling Apple's code causes a malloc failure in early image loading, so we define a fixed-size array to replace it.
  Next, trick libSystem into loading our new TLV support dylib. Exclude PPC:

sudo cp /tmp/libtlv.dylib /usr/lib/system/ cd /usr/lib sudo cp -avi libSystem.B.dylib libSystem.B.orig_dylib sudo cp -avi libSystem.B.orig_dylib libSystem.B.hacked sudo lipo -thin ppc7400 libSystem.B.orig_dylib -o libSystem.B.ppc sudo install_name_tool -change /usr/lib/system/libmathCommon.A.dylib /usr/lib/system/libtlv.dylib libSystem.B.hacked sudo lipo -replace ppc7400 libSystem.B.ppc libSystem.B.hacked -o libSystem.B.dylib

 Notes: install_name_tool will refuse to change the DYLIB stub files that are part of the SDKs, use this instead:

perl -pi -e 's|/usr/lib/system/libmathCommon.A.dylib|/usr/lib/system/libtlv.dylib\0XXXXXXXX|g' libSystem.B.dylib

Modified 2015-07-28 11:53:27
Contact turbo here