Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

Tutorial: Using prelink


A significant portion of application startup time is spent in the dynamic linker performing relocations and resolving symbols from shared libraries. This process is performed every time a program loads. Performing this process ahead-of-time and caching the results, such that it does not need to be done on program load is known as prelinking. For an in depth description of the prelinking process see http://people.redhat.com/jakub/prelink/prelink.pdf.

Due to the way prelinking works it is incompatible with any per process address space randomization security features of the Linux kernel. You should be aware of the security implications this has on your device. Because of this, prelink can be configured to randomly assign the base address at which shared libraries are loaded into a processes address space.

This tutorial describes how to use prelink to optimize programs and shared libraries on an embedded ARM device.


This tutorial assumes that


The process of preparing your device for prelinking is as follows:

  1. Build Qt Extended using the -fPIC compiler flag.
  2. Install Qt Extended onto your device.
  3. Copy prelink and prelink-rtld binaries to /usr/bin on your device.
  4. Copy prelink.conf to /etc on your device.

Once the above steps have been completed run the following commands on your device to prelink all programs and libraries:

    export LD_LIBRARY_PATH=/opt/Qtopia/lib:/lib:/usr/lib
    prelink -amR

This will take some time to run so be patient! Once it has completed check that /etc/prelink.cache exists and contains information.

The prelink command should be rerun each time programs and shared libraries (including plug-ins) are updated.

To undo the prelinking, run the command:

    prelink -au

Example Configuration File

The following is an example prelink.conf file which is appropriate for most system:

    # This config file contains a list of directories both with binaries
    # and libraries prelink should consider by default.
    # If a directory name is prefixed with `-l ', the directory hierarchy
    # will be walked as long as filesystem boundaries are not crossed.
    # If a directory name is prefixed with `-h ', symbolic links in a
    # directory hierarchy are followed.

    # System libraries
    -l /lib
    -l /usr/lib
    -l /usr/local/lib

    # System binaries
    -l /bin
    -l /usr/bin
    -l /usr/local/bin
    -l /sbin
    -l /usr/sbin
    -l /usr/local/sbin

    # Qt Extended
    -l /opt/Qtopia/lib
    -l /opt/Qtopia/bin
    -l /opt/Qtopia/plugins
    -l /opt/Qtopia/qt_plugins

Copyright © 2009 Trolltech Trademarks
Qt Extended 4.4.3