rendered paste body#!/bin/sh
if [ ! -f CoreGraphics ]; then
echo "Cannot find CoreGraphics."
exit
elif [ -z "`file CoreGraphics | grep 'Mach-O fat'`" ]; then
echo "Not a Mach-O fat executable."
exit
fi
lipo -thin i386 CoreGraphics -output CoreGraphics.i386
echo "Thinned CoreGraphics to i386"
adds=`otool -tV CoreGraphics.i386 | grep fisttpl | awk '{ print $1 }' | perl -e 'while ($line = <STDIN>) { print hex($line) - 0x902ff000 . "\n"; }'`
if [ -z "$adds" ]; then
echo "Nothing to patch."
rm CoreGraphics.i386
exit
fi
for add in $adds; do
skip=`expr $add + 1`
byte=`dd if=CoreGraphics.i386 count=1 bs=1 skip=$skip 2>/dev/null`
data=`perl -e "printf '%c%c', 0xdf, unpack(C, '$byte')|0x30"`
echo "Patching at offset $add."
echo -n $data | dd of=CoreGraphics.i386 count=2 bs=1 seek=$add conv=notrunc 2>/dev/null
done
echo "Patched CoreGraphics.i386 for SSE2 CPUs"
mv CoreGraphics CoreGraphics.unpatched
lipo CoreGraphics.unpatched -thin ppc -output CoreGraphics.ppc
echo "Thinned out PPC binary to CoreGraphics.ppc"
lipo -info CoreGraphics.ppc
lipo -info CoreGraphics.i386
lipo -create CoreGraphics.i386 CoreGraphics.ppc -output CoreGraphics
echo "Combined CoreGraphics.i386 and CoreGraphics.ppc"
echo "done"