![](https://csdnimg.cn/release/download_crawler_static/87256026/bg14.jpg)
XLINK-613
20
Input files and modules
IAR Linker and Library Tools
Reference Guide
directive is used for giving a module the
LIBRARY attribute, and the NAME directive is
used for giving a module the
PROGRAM attribute.
The IAR XLIB Librarian is used for creating and managing libraries. Among other
tasks, it can be used for altering the attribute (
PROGRAM/LIBRARY) of any other module
after it has been compiled or assembled.
FORMATTERS FOR PRINTF AND SCANF
The linker supports automatic selection of the most suitable formatter for printf- and
scanf-related functions, based on your application’s requirements and on information
from the compiler. This feature requires support in the compiler and in the library; see
your compiler documentation for information about whether this support exists. If no
function satisfies all the requirements of the application, error 177 is generated.
To override this automatic selection, choose a formatter manually using the option -e.
When automatic selection is used, the map file lists which formatters that were chosen.
SEGMENTS
Once the IAR XLINK Linker has identified the modules to be loaded for an application,
one of its most important functions is to assign load addresses to the various code and
data segments that are being used by the application.
In assembler language applications the programmer is responsible for declaring and
naming relocatable segments and determining how they are used. In C/C++ applications
the compiler creates and uses a set of predefined code and data segments, and the
programmer has only limited control over segment naming and usage.
Each module contains a number of segment parts. Each segment part belongs to a
segment, and contains either bytes of code or data, or reserves space in RAM. Using the
XLINK segment control command line options (
-Z or -P), you can cause load addresses
to be assigned to segments and segment parts.
After module linking is completed, XLINK removes the segment parts that were not
required. It accomplishes this by first including all
ROOT segment parts in loaded
modules, and then adding enough other segment parts to satisfy all dependencies.
Dependencies are either references to external symbols defined in other modules or
segment part references within a module. The
ROOT segment parts normally consists of
the root of the C runtime boot process and any interrupt vector elements.
Compilers and assemblers that produce UBROF 7 or later can put individual functions
and variables into separate segment parts, and can represent all dependencies between
segment parts in the object file. This enables XLINK to exclude functions and variables
that are not required in the build process.