06.02.2013 Views

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.26 How <strong>the</strong> linker resolves references<br />

4.26.1 See also<br />

Image structure and generation<br />

When <strong>the</strong> linker has constructed <strong>the</strong> list of libraries, it repeatedly scans each library in <strong>the</strong> list to<br />

resolve references. There are two separate lists of files that are maintained. The lists are scanned<br />

in <strong>the</strong> following order to resolve all dependencies:<br />

1. List of system libraries found in <strong>the</strong> directories specified by --libpath, <strong>ARM</strong>CC41LIB, or<br />

<strong>ARM</strong>LIB. These might also be specified by <strong>the</strong> -Jdir[,dir,...] compiler option.<br />

2. The list of all o<strong>the</strong>r files that have been loaded. These might be specified by <strong>the</strong><br />

-Idir[,dir,...] compiler option.<br />

Each list is scanned using <strong>the</strong> following process:<br />

1. Search all specified directories to select <strong>the</strong> most compatible library variants.<br />

2. Add <strong>the</strong> variants to <strong>the</strong> list of libraries.<br />

3. Scan each of <strong>the</strong> libraries to load <strong>the</strong> required members:<br />

a. For each currently unsatisfied non-weak reference, search sequentially through <strong>the</strong><br />

list of libraries for a matching definition. The first definition found is marked for<br />

step b.<br />

The sequential nature of <strong>the</strong> search ensures that <strong>the</strong> linker chooses <strong>the</strong> library that<br />

appears earlier in <strong>the</strong> list if two or more libraries define <strong>the</strong> same symbol. This<br />

enables you to override function definitions from o<strong>the</strong>r libraries, for example, <strong>the</strong><br />

<strong>ARM</strong> C libraries, by adding your libraries to <strong>the</strong> input file list. However you must<br />

be careful to consistently override all <strong>the</strong> symbols in a library member or <strong>the</strong><br />

behavior is unpredictable.<br />

b. Load <strong>the</strong> library members marked in stage 3a. As each member is loaded it might<br />

satisfy some unresolved references, possibly including weak ones. Loading a<br />

library member might also create new unresolved weak and non-weak references.<br />

c. Repeat <strong>the</strong>se stages until all non-weak references are ei<strong>the</strong>r resolved or cannot be<br />

resolved by any library.<br />

4. If any non-weak reference remains unsatisfied at <strong>the</strong> end of <strong>the</strong> scanning operation,<br />

generate an error message.<br />

Concepts<br />

• About weak references and definitions on page 4-32<br />

• How <strong>the</strong> linker performs library searching, selection, and scanning on page 4-35<br />

• Controlling how <strong>the</strong> linker searches for <strong>the</strong> <strong>ARM</strong> standard libraries on page 4-36<br />

• Specifying user libraries when linking on page 4-38.<br />

Reference<br />

<strong>Linker</strong> Reference:<br />

• --libpath=pathlist on page 2-96.<br />

<strong>Compiler</strong> Reference:<br />

• -Idir[,dir,...] on page 3-112<br />

• -Jdir[,dir,...] on page 3-123.<br />

Introducing <strong>the</strong> <strong>ARM</strong> <strong>Compiler</strong> <strong>toolchain</strong>:<br />

• Toolchain environment variables on page 2-14.<br />

<strong>ARM</strong> DUI 0474C Copyright © 2010-2011 <strong>ARM</strong>. All rights reserved. 4-39<br />

ID080411 Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!