7.2. What does the dynamic linker need to do?

This section summarizes the actions that the dynamic linker or operating system has to do. It includes a rough walk through of the following steps carried out by the dynamic linker or operating system.

  1. Invoke the dynamic linker.

  2. Read any dependencies.

  3. Load all files into memory.

  4. Resolve (dynamic) relocations.

A dynamic linker is normally closely integrated into an operating system and the exact tasks it has to perform depends on the operating system. However the basic operations and the order these operations are performed in are normally very similar.

Note

The dynamic linker might optimize a number of these steps to improve startup times for applications and avoid unnecessary work.

When an application is executed that has one or more dependencies, the dynamic linker is called. In many cases there is only a single dynamic linker available in an operating system and this is called automatically. However, on some operating systems it is possible to have more than one dynamic linker and the operating system selects the appropriate dynamic linker based on information in the executable image. It is also possible on some systems to debug and trace the execution of an application and its dependencies. For example, under Linux it is possible to set the LD_DEBUG environment variable to output information from the dynamic linker.

When the dynamic linker is invoked, one of the first actions it performs is to process the dependency list for the executable image. The dependencies are the other executable modules that the executable image needs to execute. The dynamic linker must load these modules. It then processes the dependencies of the loaded modules. This process continues until all the dependencies of each module have been processed by the dynamic linker.

When all the dependencies are resolved, the dynamic linker can load the executable and all the required modules into memory. Again the load address for each executable and module is operating system specific.

When all the executable and modules are loaded into memory the dynamic linker can process the dynamic relocations in the application and modules. This includes the relocations against the PLT and the GOT.

When the relocations have been processed the executable image is ready to be executed. Therefore control passes to the application by branching to the entry point of the application.

Copyright © 2010 ARM. All rights reserved.ARM DAI 0242A
Non-ConfidentialID011411