Keil Logo

Technical Support

On-Line Manuals

Linker User Guide

Preface Overview of the Linker Linking Models Supported by armlink Image Structure and Generation The structure of an ARM ELF image Views of the image at each link stage Input sections, output sections, regions, and prog Load view and execution view of an image Methods of specifying an image memory map with the Image entry points Simple images Types of simple image Type 1 image structure, one load region and contig Type 2 image structure, one load region and non-co Type 3 image structure, multiple load regions and Section placement with the linker Default section placement Section placement with the FIRST and LAST attribut Section alignment with the linker Linker support for creating demand-paged files Linker reordering of execution regions containing Linker-generated veneers What is a veneer? Veneer sharing Veneer types Generation of position independent to absolute ven Reuse of veneers when scatter-loading Command-line options used to control the generatio Weak references and definitions How the linker performs library searching, selecti How the linker searches for the ARM standard libra Specifying user libraries when linking How the linker resolves references The strict family of linker options Linker Optimization Features Getting Image Details Accessing and Managing Symbols with armlink Scatter-loading Features Scatter File Syntax Linker Command-line Options Linker Steering File Command Reference Via File Syntax

How the linker searches for the ARM standard libraries

3.10 How the linker searches for the ARM standard libraries

The linker searches for the ARM® standard libraries using information specified on the command-line, or by examining environment variables.

By default, the linker searches for the ARM standard libraries in ../lib, relative to the location of the armlink executable. Use the --libpath command-line option or the ARMLIB or ARMCC5LIB environment variables to specify a different location.
Some libraries are stored in subdirectories. If the compiler requires a library from a particular subdirectory, it adds an import of a special symbol to identify the subdirectory to the linker. The names of subdirectories are placed in each compiled object by using a symbol of the form Lib$$Request$$sub_dir_name.

The --libpath command-line option

Use the --libpath command-line option with a comma-separated list of parent directories. This list must end with the parent directory of the ARM library directories armlib and cpplib.
The linker searches subdirectories given by the symbol Lib$$Request$$sub_dir_name, if you include the path separator character on the end of the library path:
  • \ on Windows.
For example, for --libpath=mylibs\ and the symbol Lib$$Request$$armlib the linker searches the directories:
mylibs
mylibs\armlib

Note

When the linker command-line option --libpath is used, any paths specified by the ARMCC5LIB variable are not searched.
The sequential nature of the search ensures that armlink chooses the library that appears earlier in the list if two or more libraries define the same symbol.

The ARMCC5LIB or ARMLIB environment variable

You can use either of the ARMLIB or ARMCC5LIB environment variables to specify a library path.
The linker searches subdirectories given by the symbol Lib$$Request$$sub_dir_name, if you include the path separator character on the end of the path specified in ARMCC5LIB:
  • \ on Windows.
For example, if ARMCC5LIB is set to install_directory\lib\, the linker searches the directories:
lib
lib\armlib
lib\cpplib

Library search order

The linker searches for libraries in the following order:
  1. At the location specified with the command-line option --libpath.
  2. At the location specified in ARMCC5LIB.
  3. At the location specified in ARMLIB.
  4. In ../lib, relative to the location of the armlink executable.

How the linker selects ARM library variants

The ARM Compiler toolchain includes a number of variants of each of the libraries, that are built using different build options. For example, architecture versions, endianness, and instruction set. The variant of the ARM library is coded into the library name. The linker must select the best-suited variant from each of the directories identified during the library search.
The linker accumulates the attributes of each input object and then selects the library variant best suited to those attributes. If more than one of the selected libraries are equally suited, the linker retains the first library selected and rejects all others.
The --no_scanlib option prevents the linker from searching the directories for the ARM standard libraries.
Related reference
Non-ConfidentialPDF file icon PDF versionARM DUI0377H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.