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
6 Examples 6.1 Controlling
6.1.2 Related examples in
- Page 1 and 2: AVR32795:
- Page 3 and 4: 3 Basic linker script concepts 3.1
- Page 5 and 6: 4 Default versus specific linker sc
- Page 7 and 8: 32158A-AVR-01/11 } INTRAM_ALIGN PT_
- Page 9: 5.3.2.2 Text 32158A-AVR-01/11 Figur
- 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/
6 Examples<br />
6.1 C<strong>on</strong>trolling <str<strong>on</strong>g>the</str<strong>on</strong>g> locati<strong>on</strong> of functi<strong>on</strong>s and variables in <str<strong>on</strong>g>the</str<strong>on</strong>g> flash<br />
6.1.1 Process flow<br />
10 <str<strong>on</strong>g><strong>AVR</strong>32795</str<strong>on</strong>g><br />
A. Define a custom secti<strong>on</strong>, .flash_nvram, located in flash:<br />
A.1. Handle a default or pre-defined size for this secti<strong>on</strong>:<br />
/* Use a default flash NVRAM size if flash NVRAM size was not defined. */<br />
__flash_nvram_size__ = DEFINED(__flash_nvram_size__)?__flash_nvram_size__:4K;<br />
A.2. Describe <str<strong>on</strong>g>the</str<strong>on</strong>g> output secti<strong>on</strong>, .flash_nvram:<br />
.flash_nvram ORIGIN(FLASH) + LENGTH(FLASH) - __flash_nvram_size__ :<br />
{<br />
*(.flash_nvram)<br />
} >FLASH AT>FLASH :FLASH_NVRAM<br />
B. Locate a variable in a custom secti<strong>on</strong>, .flash_nvram:<br />
� Extensi<strong>on</strong>s to <str<strong>on</strong>g>the</str<strong>on</strong>g> C language family:<br />
o Specifying attributes of variables<br />
__attribute__((__secti<strong>on</strong>__(".flash_nvram"))) static int flash_nvram_data;<br />
C. Locate a functi<strong>on</strong> in a custom secti<strong>on</strong>, .flash_nvram:<br />
� Extensi<strong>on</strong>s to <str<strong>on</strong>g>the</str<strong>on</strong>g> C language family:<br />
o Declaring attributes of functi<strong>on</strong>s<br />
VMA of this output secti<strong>on</strong><br />
Include all input secti<strong>on</strong>s .flash_nvram<br />
Assign this secti<strong>on</strong> to a program segment (cf PHDRS{ })<br />
Specify <str<strong>on</strong>g>the</str<strong>on</strong>g> memory regi<strong>on</strong> FLASH for <str<strong>on</strong>g>the</str<strong>on</strong>g> secti<strong>on</strong>’s LMA<br />
Assign this secti<strong>on</strong> to <str<strong>on</strong>g>the</str<strong>on</strong>g> FLASH regi<strong>on</strong> of memory (cf. MEMORY{ })<br />
__attribute__ ((__secti<strong>on</strong>__(".flash_nvram"))) void Func(void) {…}<br />
NOTE Placing a variable or a functi<strong>on</strong> at a specific address has to be d<strong>on</strong>e through <str<strong>on</strong>g>the</str<strong>on</strong>g> linker<br />
script (place <str<strong>on</strong>g>the</str<strong>on</strong>g> custom secti<strong>on</strong> at <str<strong>on</strong>g>the</str<strong>on</strong>g> specific address).<br />
32158A-<strong>AVR</strong>-01/11