Removing Useless Code from Universal Binaries

Disclaimer:

Please make backups prior to doing anything found in this article.  I take no responsibility for any problems that may occur.

What are Universal Binaries?:

The Universal Binary, as called by Apple, is an application bundle (.app) designed to run on both Intel and PowerPC-based Apple computers running OS X.

The introduction of the UB in 2005 meant that software developers could maintain a single binary capable of running on both platforms instead a separate one for both Intel and PPC.

Another advantage is that one would not have to rely upon emulation via Rosetta, which can often be sluggish.

The Problem:

While the Universal Binary is useful to developers, it causes a couple of issues for users.

The first issue being that quite often universal binaries are larger that one for a single platform.

Another issue is that time can be wasted while your machine selects the correct code to execute.

But fear not, I have a simple solution.

The Solution:

A quick search of Google will reveal a number of solutions for removing foreign code from a UB, however they are all merely wrappers for tools already at your disposal, and in many cases are sketchy at best.

My solution is both free and relatively safe.

First step, open up a terminal emulator.

Now, we are going to cd to '/Applications/0xED.app/Contents/MacOS/', which is where the 0xED binary lays.

We don't want to waste our time stripping out the code if we don't need to, so we will first check to see if this universal or not:

Since it is, we will remove the PPC code, as it is unecessary on my Intel-based machine.

At this point we actually have a couple of options fore removing the code; the first is to remove a given architecture and the second is to remove all architectures except the one needed.

Method 1 (-remove):

And with that, we have removed all PPC code, stripped down the bundle size from 1.1MB to 773KB, and have possibly sped up its execution somewhat.

Method 2 (-thin):

And with our second method we have created a thinned binary, containing only the specified architecture, removing all other types.  This method is only handy if there are more than two platforms present.

Keep on hacking. -tek

Posted: 09-DEC-2007 .. This document was jacked from: http://www.hackcanada.com/canadian/zines/k_1ine/K-1ine_50.txt