You copied the Doc URL to your clipboard.

How the linker resolves references

When the linker has constructed the list of libraries, it repeatedly scans each library in the list to resolve references. There are two separate lists of files that are maintained. The lists are scanned in the following order to resolve all dependencies:

  1. List of system libraries found in ../lib, or the directories specified by --libpath, ARMCCnLIB, or ARMLIB. These might also be specified by the -Jdir[,dir,...] compiler option.

  2. The list of all other files that have been loaded. These might be specified by the -Idir[,dir,...] compiler option.

Each list is scanned using the following process:

  1. Search all specified directories to select the most compatible library variants.

  2. Add the variants to the list of libraries.

  3. Scan each of the libraries to load the required members:

    1. For each currently unsatisfied non-weak reference, search sequentially through the list of libraries for a matching definition. The first definition found is marked for step b.

      The sequential nature of the search ensures that the linker chooses the library that appears earlier in the list if two or more libraries define the same symbol. This enables you to override function definitions from other libraries, for example, the ARM C libraries, by adding your libraries to the input file list. However you must be careful to consistently override all the symbols in a library member or the behavior cannot be predicted.

    2. Load the library members marked in stage 3a. As each member is loaded it might satisfy some unresolved references, possibly including weak ones. Loading a library member might also create new unresolved weak and non-weak references.

    3. Repeat these stages until all non-weak references are either resolved or cannot be resolved by any library.

  4. If any non-weak reference remains unsatisfied at the end of the scanning operation, generate an error message.

Was this page helpful? Yes No