On Feb 17, 2007, at 1:58 PM, Kent Sorensen wrote: I would like randomize the link order of my application from build to build, and with link order I mean the sequence in which the object code from the compiled project files are written to the application file.
Can I just rearrange the files in the project list, or does Xcode use some more involved methods to determine how to build the binary ?
I've got a problem with piracy of my application and I want to mask certain small changes to the program code with a large number of other differences. If I make a change in a particular routine that checks serial numbers, and release a build without any other changes it is conceivable that the before and after application files can be compared and the precise location of the serial number check is compromised.
So, while it is an odd request, I believe there is a sane reason. This is part of a multi level approach to combatting piracy that by and large has been successful. Back in the CW days I rearranged the build order tab to achieve the same effect.
The order that source files are listed in the Compile Sources build phase of the target is the order in which they are linked, so you can control the order of linkage in exactly the same way as in CW, just by dragging the files around.
In a well-factored target this should have no effect on functionality. In a target with latent dependency errors this may cause the build to break in cases where order of linkage is important. (Frankly I haven't seen one of these errors, in CW or in Xcode, in over a decade—but it's still possible.)
Note that randomizing the order of linkage pretty much destroys any locality of scope you may have in your app and will tend to cause all your object code to be resident at all times, diminishing your application performance. That's why we recommend using order files to give the linker some advice on what routines are commonly used vs. less common, to keep your swapped-in working set low.
Come to think of it, an order file might be the best solution to your problem. Create a "real" order file for your shipping product, but for the beta releases, just use your favorite Unix utility to randomize the entries in the order file. That way you don't have to change your project or its link order, but you achieve the effect of scrambling your binary.
Chrs |