Book HomeMac OS X for Unix GeeksSearch this book

5.6. Prebinding

Whenever you install an update to the Mac OS X operating system, there is a long phase at the end called optimization. What the splash screen calls "optimization" is a particular type of optimization, called prebinding, which applies only to Mach-O executables. We will only describe the essential idea behind prebinding. For more details and specific instructions on building libraries and executables with prebinding enabled, consult the document /Developer/Documentation/ReleaseNotes/Prebinding.html.

To understand what prebinding is and how it can speed up the launch of an application, let's consider what happens when you launch an application that was built without prebinding. When such an application (or dynamic library) is built, ld (the static linker) records the names of undefined symbols (i.e., the names of symbols that the application must link against). Later, when the application is launched, the dynamic linker (dyld) must bind the undefined references from the application to their definitions.

In contrast, if an executable or dynamic library is built with prebinding, the binding essentially occurs at build time. In particular, the library is predefined at some specified address range, a process that would otherwise have to occur when an application is launched. Rather than mark symbols as undefined, the dynamic linker can use address symbols in a prebound library to reference when some other application or dynamic library links against it. Additionally, if the prebound library depends on other libraries (a common situation), then the static linker records the timestamps of the other libraries. Later, when the prebound library is used, the dynamic linker checks the timestamps of the dependent libraries and checks for the existence of overlapping executable addresses. If the timestamps do not match those of the build timestamps, or if there are overlapping executable addresses, the prebinding is broken and normal binding is performed.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.