Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 Manuel D’Utilisation

Codes de produits
SW006021-1
Page de 518
MPLAB
®
 XC8 C COMPILER
USER’S GUIDE
 2012 Microchip Technology Inc.
DS52053B-page 277
Chapter 7.  Linker
7.1
INTRODUCTION
This chapter describes the theory behind, and the usage of, the linker.
The application name of the linker is HLINK. In most instances it will not be necessary 
to invoke the linker directly, as the compiler driver, xc8, will automatically execute the 
linker with all necessary arguments. Using the linker directly is not simple, and should 
be attempted only by those with a sound knowledge of the compiler and linking in gen-
eral. The compiler often makes assumptions about the way in which the program will 
be linked. If the psects are not linked correctly, code failure may result.
If it is absolutely necessary to use the linker directly, the best way to start is to copy the 
linker arguments constructed by the compiler driver, and modify them as appropriate. 
This will ensure that the necessary startup module and arguments are present.
The following topics are examined in this chapter of the MPLAB XC8 C Compiler User’s 
Guide:
7.2
OPERATION
A command to the linker takes the following form:
hlink [optionsfiles
The options are zero or more linker options, each of which modifies the behavior of 
the linker in some way. The files is one or more object files, and zero or more object 
code library names (.lib extension). P-code libraries (.lpp extension) are always 
passed to the code generator application and cannot be passed to the linker.
The options recognized by the linker are listed in Table 7-1 and discussed in the 
following paragraphs.
TABLE 7-1:
LINKER COMMAND-LINE OPTIONS
Option
 Effect
-8
Use 8086 style segment:offset address form
-A
class=low-high ,...
Specify address ranges for a class
-C
x
Call graph options
-C
psect=class
Specify a class name for a global psect
-C
baseaddr
Produce binary output file based at baseaddr
-D
class=delta
Specify a class delta value
-D
symfile
Produce old-style symbol file
-E
errfile
Write error messages to errfile
-F
Produce .obj file with only symbol records
-G
 spec
Specify calculation for segment selectors
-H
 symfile
Generate symbol file
-H+
 symfile
Generate enhanced symbol file