Atmel CAVR-4 Manual De Usuario

Descargar
Página de 323
CAVR-4
Part 1. Using the compiler
33
Placing code and data 
This chapter introduces the concept of segments, and describes the different 
segment groups and segment types. It also describes how they correspond to 
the memory and function types, and how they interact with the runtime 
environment. The methods for placing segments in memory, which means 
customizing a linker command file, are described.
The intended readers of this chapter are the system designers that are 
responsible for mapping the segments of the application to appropriate 
memory areas of the hardware system.
Segments and memory
In an embedded system, there are many different types of physical memory. Also, it is 
often critical where parts of your code and data are located in the physical memory. For 
this reason it is important that the development tools meet these requirements.
WHAT IS A SEGMENT?
A segment is a logical entity containing a piece of data or code that should be mapped 
to a physical location in memory. Each segment consists of many segment parts
Normally, each function or variable with static storage duration is placed in a segment 
part. A segment part is the smallest linkable unit, which allows the linker to include only 
those units that are referred to. The segment could be placed either in RAM or in ROM. 
Segments that are placed in RAM do not have any content, they only occupy space.
The AVR IAR C/C++ Compiler has a number of predefined segments for different 
purposes. Each segment has a name that describes the contents of the segment, and a 
segment memory type that denotes the type of content. In addition to the predefined 
segments, you can define your own segments.
At compile time, the compiler assigns each segment its contents. The IAR XLINK 
Linker™ is responsible for placing the segments in the physical memory range, in 
accordance with the rules specified in the linker command file. There are supplied linker 
command files, but, if necessary, they can be easily modified according to the 
requirements of your target system and application. It is important to remember that, 
from the linker's point of view, all segments are equal; they are simply named parts of 
memory.