AVR32795: Using the GNU Linker Scripts on AVR UC3 ... - Atmel
AVR32795: Using the GNU Linker Scripts on AVR UC3 ... - Atmel AVR32795: Using the GNU Linker Scripts on AVR UC3 ... - Atmel
2 Memory map 2
3 Basic linker script concepts 3.1 Sections 3.2 Section properties 3.3 VMA and LMA 3.4 Symbols 3.5 Well-known sections 32158A-AVR-01/11
- Page 1: AVR32795:
- Page 5 and 6: 4 Default versus specific linker sc
- Page 7 and 8: 32158A-AVR-01/11 } INTRAM_ALIGN PT_
- Page 9 and 10: 5.3.2.2 Text 32158A-AVR-01/11 Figur
- Page 11 and 12: 6.1.2 Related examples in t
- Page 13 and 14: 32158A-AVR-01/11 PROVIDE(_data_sdra
- Page 15 and 16: 32158A-AVR-01/11 AVR32795</
- Page 17 and 18: 8 Frequently asked questions 32158A
- Page 19 and 20: 32158A-AVR-01/11 AVR32795</
- Page 21 and 22: 11 Table of Contents 32158A-AVR-01/
3 Basic linker script c<strong>on</strong>cepts<br />
3.1 Secti<strong>on</strong>s<br />
3.2 Secti<strong>on</strong> properties<br />
3.3 VMA and LMA<br />
3.4 Symbols<br />
3.5 Well-known secti<strong>on</strong>s<br />
32158A-<strong>AVR</strong>-01/11<br />
<str<strong>on</strong>g><strong>AVR</strong>32795</str<strong>on</strong>g><br />
The linker combines input files (object file format) into a single output file<br />
(executable).<br />
Each object file has, am<strong>on</strong>g o<str<strong>on</strong>g>the</str<strong>on</strong>g>r things, a list of secti<strong>on</strong>s. We refer to a secti<strong>on</strong> in an<br />
input file as an input secti<strong>on</strong>. Similarly, a secti<strong>on</strong> in <str<strong>on</strong>g>the</str<strong>on</strong>g> output file is an output secti<strong>on</strong>.<br />
Each secti<strong>on</strong> in an object file has a name and a size. Most secti<strong>on</strong>s also have an<br />
associated block of data (<str<strong>on</strong>g>the</str<strong>on</strong>g> secti<strong>on</strong> c<strong>on</strong>tents).<br />
A secti<strong>on</strong> may be marked as loadable, which means that its c<strong>on</strong>tents should be<br />
loaded into memory when <str<strong>on</strong>g>the</str<strong>on</strong>g> executable is run.<br />
A secti<strong>on</strong> with no c<strong>on</strong>tents may be allocatable, which means that an area in memory<br />
should be set aside, but nothing in particular should be loaded <str<strong>on</strong>g>the</str<strong>on</strong>g>re (and, in some<br />
cases, this memory must be zeroed out).<br />
A secti<strong>on</strong> which is nei<str<strong>on</strong>g>the</str<strong>on</strong>g>r loadable nor allocatable typically c<strong>on</strong>tains some sort of<br />
debugging informati<strong>on</strong>.<br />
Every loadable or allocatable output secti<strong>on</strong> has two addresses. The first is <str<strong>on</strong>g>the</str<strong>on</strong>g> VMA,<br />
or virtual memory address. This is <str<strong>on</strong>g>the</str<strong>on</strong>g> address <str<strong>on</strong>g>the</str<strong>on</strong>g> secti<strong>on</strong> will have when <str<strong>on</strong>g>the</str<strong>on</strong>g> output<br />
file is run. The sec<strong>on</strong>d is <str<strong>on</strong>g>the</str<strong>on</strong>g> LMA, or load memory address. This is <str<strong>on</strong>g>the</str<strong>on</strong>g> address at<br />
which <str<strong>on</strong>g>the</str<strong>on</strong>g> secti<strong>on</strong> will be loaded. In most cases <str<strong>on</strong>g>the</str<strong>on</strong>g> two addresses will be <str<strong>on</strong>g>the</str<strong>on</strong>g> same.<br />
An example of when <str<strong>on</strong>g>the</str<strong>on</strong>g> LMA and VMA might be different is when a data secti<strong>on</strong> is<br />
loaded into ROM, and <str<strong>on</strong>g>the</str<strong>on</strong>g>n copied into RAM when <str<strong>on</strong>g>the</str<strong>on</strong>g> program starts up (a technique<br />
often used to initialize global variables in a ROM-based system). In this case, <str<strong>on</strong>g>the</str<strong>on</strong>g><br />
ROM address would be <str<strong>on</strong>g>the</str<strong>on</strong>g> LMA and <str<strong>on</strong>g>the</str<strong>on</strong>g> RAM address would be <str<strong>on</strong>g>the</str<strong>on</strong>g> VMA.<br />
Every object file also has a list of symbols, known as <str<strong>on</strong>g>the</str<strong>on</strong>g> symbol table. A symbol may<br />
be defined or undefined. Each symbol has a name, and each defined symbol has an<br />
address, am<strong>on</strong>g o<str<strong>on</strong>g>the</str<strong>on</strong>g>r informati<strong>on</strong>.<br />
The compilati<strong>on</strong> of a C or C++ program into an object file will generate a defined<br />
symbol for every defined functi<strong>on</strong> and global or static variable. Every undefined<br />
functi<strong>on</strong> or global variable which is referenced in <str<strong>on</strong>g>the</str<strong>on</strong>g> input file will become an<br />
undefined symbol.<br />
.text: usually c<strong>on</strong>tains <str<strong>on</strong>g>the</str<strong>on</strong>g> code, and is usually loaded to a n<strong>on</strong>-volatile memory,<br />
such as <str<strong>on</strong>g>the</str<strong>on</strong>g> internal flash.<br />
.data: initialized data; usually c<strong>on</strong>tains initialized variables.<br />
.bss: usually c<strong>on</strong>tains n<strong>on</strong>-initialized data.<br />
3