SWRA446 February 2015 CC1310 , CC1310 , CC2620 , CC2620 , CC2630 , CC2630 , CC2640 , CC2640 , CC2640R2F , CC2640R2F , CC2640R2F-Q1 , CC2640R2F-Q1 , CC2650 , CC2650 , CC2650MODA , CC2650MODA
The linker file cc26x0f128.lds is found in the folder cc26xxware/linker_files/ in the software example package.
The following variables are defined in the linker script.
_estack | This variable is used in the startup file and defines the top of the stack to be at the end of SRAM. |
_Min_Heap_Size | This variable defines required amount of heap. The linker file will report an error if there is not enough space for this amount of heap in the RAM. |
_Min_Stack_Size | This variable defines required amount of stack. The linker file will report an error if there is not enough space for this amount of stack in the RAM. |
The following commands are called in the linker script.
ENTRY | Defines the entry point, i.e. the first instruction to execute in the program. The entry point is set to ResetISR, which is a function implemented in the startup file. |
MEMORY | This command describes the location and size of blocks of memory in the target. |
ORIGIN defines the start address of the memory block. | |
LENGTH defines the size of the memory block. | |
Attributes can be placed in parenthesis after the memory block name. The attributes used in this linker file is | |
‘R’ Read-only section | |
‘W’ Write section | |
‘X’ Executable section | |
SECTIONS | This commend tells the linker how to map input sections into output sections and how to place the output sections in memory. |
This linker script contains the output sections .text, .data, .bss and .ccfg. In addition a section called _user_heap_stack is defined. This is to make sure that there is enough space in the SRAM region for the required amount of heap and stack. | |
The below code defines the output section .text: | |
.text :
{
_text = .;
KEEP(*(.vectors))
*(.text*)
*(.rodata*)
_etext = .;
} > FLASH= 0
|
|
_text = .; sets the symbol _text to the value of the location counter. The location counter has value 0 at the beginning of the SECTIONS command. Then follows the input sections that should be placed in this output section. KEEP(*(.vectors)) will keep the symbols *(.vectors) in the section even if symbols are not referenced. The ‘*’ is a wildcard symbol. *(.text*)and *(.rodata*) means that all .text* and .rodata* input sections in all input files should be placed in this section. _etext = .; sets the symbol _etext to the value of the location counter. > FLASH= 0 assigns the section to the memory region FLASH, and fills unspecified regions of the memory with 0. | |
In the definition of the .data section, the keyword AT(lma) is used. This keyword specifies the load address (lma) of the section. |