Table of Contents
Previous topic Next topic
LINKER->Overview and Command Line Operation
The linker combines object modules created with the compiler and/or the assembler to create the final code that will run on your target system. It carries out the following functions:
The linker will also construct a call tree of your C functions. It will use this to perform an overlay analysis of the local data areas of any non-reentrant functions, sharing memory wherever possible. It will report potential recursion of non-reentrant functions. At the same time, the parameter space for non-reentrant functions with variable numbers of arguments will be sized to the maximum required by any of the calls to that function.
- scans each module to collect segment and variable information
- arranges and positions segments at appropriate memory locations to suit the memory organisation of the target system and any specific location information supplied by the user
- finalises the values of all variables and calculates the results of any incomplete expressions
- extracts and relocates the code from each module to produce the final target program
- optionally updates the listing files produced by the compiler and/or assembler adding the final absolute address information.
- carries out a complete type check across all modules examining global variables, functions (return type, parameter types and numbers, reentrant attributes, interrupt attributes, and memory model type) and structure and union member types to ensure total program integrity
The target program can be produced in a number of different formats including Intel hex, Intel OMF51, Motorola 'S' record, HP/Microtec IEEE695 format or as a binary rom image. No conversion utility has to be used - the linker directly outputs the program in the specified format.
An optional link map will show the final location and sizes of all segments and the values of all global variables.
The linker can be automatically invoked when the CL command is used. However, the linker can also be run separately with the command line:
LINK [ofiles], [pfile], [mfile], [lfiles] [/options]
where [ofiles] is a list (separated by spaces) of the object files to be linked
[pfile] is the name of the file in which the program code will be placed
[mfile] is the name of the file in which the link map will be placed
[lfiles] is a list (separated by spaces) of the library files which should be searched for unresolved references
[/options] is a list (separated by spaces) of linker options.
A semicolon placed after a file name causes default filenames to be used for the remaining filenames.