Microchip Technology SW006021-1N 사용자 설명서
MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 222
2012 Microchip Technology Inc.
5.15
LINKING PROGRAMS
The compiler will automatically invoke the linker unless the compiler has been
requested to stop after producing an intermediate file.
requested to stop after producing an intermediate file.
The linker will run with options that are obtained from the command-line driver. These
options specify the memory of the device and how the psects should be placed in the
memory. No linker scripts are used.
options specify the memory of the device and how the psects should be placed in the
memory. No linker scripts are used.
The linker options passed to the linker can be adjusted by the user, but this is only
required in special circumstances. See Section 4.8.7 “-L-: Adjust Linker Options
Directly” for more information.)
required in special circumstances. See Section 4.8.7 “-L-: Adjust Linker Options
Directly” for more information.)
The linker creates a map file which details the memory assigned to psects and some
objects within the code. The map file is the best place to look for memory information.
See Section 7.4 “Map Files” for a detailed explanation of the detailed information in
this file.
objects within the code. The map file is the best place to look for memory information.
See Section 7.4 “Map Files” for a detailed explanation of the detailed information in
this file.
5.15.1
Program Sections
There is a lot of confusion as to what psects (program sections) actually are and even
more confusion as to how they are placed in memory. The following aside takes the
form of an analogy and examples, and serves as an introduction to how compilers must
generate code and have it allocated into memory. Such an understanding is vital for
assembly programmers and understanding “Can’t find space” error messages issued
by the linker. Like all analogies, it can be misleading and can only be taken so far, but
it relates the main principles of code generation, the linker and sections back to some-
thing that you should understand.
more confusion as to how they are placed in memory. The following aside takes the
form of an analogy and examples, and serves as an introduction to how compilers must
generate code and have it allocated into memory. Such an understanding is vital for
assembly programmers and understanding “Can’t find space” error messages issued
by the linker. Like all analogies, it can be misleading and can only be taken so far, but
it relates the main principles of code generation, the linker and sections back to some-
thing that you should understand.
By the end of this section, you should have a better understanding of:
• Why assembly code has to be packed and manipulated in sections
• Why the linker packs sections into classes rather than the device memory
• Why a “Can’t find space” error message may be issued even though there is
plenty of space left in a device’s memory
5.15.1.1
AN ANALOGY
Our analogy is based around a company which sells components. Customers through-
out the world place orders for these components. The consignments are sent from a
central warehouse in shipping containers to a regional office and then delivered to the
customer.
out the world place orders for these components. The consignments are sent from a
central warehouse in shipping containers to a regional office and then delivered to the
customer.
In the warehouse, a robot assembles each order. The required components are col-
lected and placed in a box of sufficient size. The box is labelled then placed on a con-
veyor belt. The label on the box indicates the destination city and country, as well as
any special packing instructions.
lected and placed in a box of sufficient size. The box is labelled then placed on a con-
veyor belt. The label on the box indicates the destination city and country, as well as
any special packing instructions.
At the other end of the conveyor belt, a packing machine reads the labels on the boxes
and sorts them by destination city. Thus, all the boxes destined for the same city are
collated into one holding bay.
and sorts them by destination city. Thus, all the boxes destined for the same city are
collated into one holding bay.
Once the day’s order are all processed, the collated boxes in each holding bay are first
wrapped in plastic to keep them together. These bundles are then placed into a ship-
ping container bound for that country. As there might be more than one destination city
in the same country, there could be many bundles placed in the same container.
wrapped in plastic to keep them together. These bundles are then placed into a ship-
ping container bound for that country. As there might be more than one destination city
in the same country, there could be many bundles placed in the same container.
And so ends another productive day in the warehouse.