This Marcos is for creating Linker Scripts
The Linker Files are create by C Preprocessor.
Example Code m0.lds.S:
ENTRY(reset_handler)
MEM_ADD(flash, 0x00000000, 0x20000)
. = ORIGIN(flash);
HEAP(sram, CONFIG_MACH_INIT_STACK_SIZE)
◆ BSS_DEFAULT
Value: *(.dynsbss) \
*(.sbss .sbss.* .gnu.linkonce.sb.*) \
*(.scommon) \
*(.bss) \
*(.bss*)\
PROVIDE(__global_pointer$ =
MIN(__sdata_begin__ + 0x800, \
MAX(_start_data + 0x800, __bss_end__ - 0x800)));
Default BSS Section entrys
◆ BSS_FREERTOS
#define BSS_FREERTOS *(.bss.freertos*) |
◆ BSS_START
Start BSS Section This Macro define the symbol bss_start
◆ BSS_STOP
Stop BSS Section This Macro define the symbol bss_end
- Parameters
-
◆ DATA_DEFAULT
Value: *(.data) \
*(.data*) \
*(.fini_array) \
*(.gnu.linkonce.d.*) \
__sdata_begin__ = .; \
*(.srodata.cst16) \
*(.srodata.cst8) \
*(.srodata.cst4) \
*(.srodata.cst2) \
*(.srodata .srodata.*) \
*(.sdata .sdata.* .gnu.linkonce.s.*)
Default in Data Section
◆ DATA_FREERTOS
#define DATA_FREERTOS *(.data.freertos*) |
◆ DATA_START
Start Data Section This Maco define the symbol _start_data
◆ DATA_STOP
Stop Data Section this Macro define the symbol _end_data
- Parameters
-
location | Location |
flashLocation | Location in flash |
◆ DATA_TABLE
#define DATA_TABLE |
( |
|
sname | ) |
|
Value: LONG(LOADADDR(sname)); \
LONG(ADDR(sname)); \
LONG(SIZEOF(sname));
Add a Entry in a data table
- Parameters
-
sname | Name of data section for example .data or .data.freertos |
◆ DATA_TABLE_START
#define DATA_TABLE_START SYMBOL(_data_table); |
◆ DATA_TABLE_STOP
#define DATA_TABLE_STOP SYMBOL(_data_table_end); |
◆ END
#define END = SYMBOL(_end); PROVIDE(end = .); |
◆ HEAP
#define HEAP |
( |
|
location, |
|
|
|
stakSize |
|
) |
| |
Value:
SYMBOL(_heap_end); \
. = ((ORIGIN(location) + LENGTH(location)) - (stakSize)); \
_heap_top = . - 4; \
SECTION_STOP(location)
Define Heap Section
- Parameters
-
location | Location |
stakSize | Stack Size |
◆ MEM_ADD
#define MEM_ADD |
( |
|
name, |
|
|
|
origin, |
|
|
|
len |
|
) |
| name : ORIGIN = origin, LENGTH = len |
Add a Memory Entry
- Parameters
-
name | Memory Name like sram or flash |
origin | Memory position
|
len | Length of Memory Entry |
◆ MEM_START
#define MEM_START MEMORY { |
◆ MEM_STOP
◆ RODATA_DEFAULT
#define RODATA_DEFAULT *(.rodata) *(.rodata*) |
◆ RODATA_START
◆ RODATA_STOP
Stop rodata Section And add Unwind Tables after rodata Section
◆ SECTION_START
#define SECTION_START |
( |
|
name | ) |
name : { |
◆ SECTION_STOP
#define SECTION_STOP |
( |
|
location | ) |
} > location AT > location |
◆ SECTION_STOP_RAM
#define SECTION_STOP_RAM |
( |
|
location, |
|
|
|
flashLocation |
|
) |
| } > location AT > flashLocation |
Stop Section located in RAM
- Parameters
-
location | Location |
flashLocation | Location in flash |
◆ SECTIONS_START
#define SECTIONS_START SECTIONS { |
◆ SECTIONS_STOP
◆ STACK
#define STACK |
( |
|
location | ) |
|
Value:
SYMBOL(_start_stack); \
_end_stack = (ORIGIN(location) + LENGTH(location)); \
__freertos_irq_stack_top = (ORIGIN(location) + LENGTH(location)); \
SECTION_STOP(location)
Define Stack Section
- Parameters
-
◆ SYMBOL
#define SYMBOL |
( |
|
name | ) |
name = . |
Define a Symbol
- Parameters
-
◆ TEXT_DEFAULT
#define TEXT_DEFAULT *(.text*) *(.init*) *(.fini) *(.eh_frame) |
Default Entry for text section
◆ TEXT_FREERTOS
#define TEXT_FREERTOS *(.text.freertos*) |
◆ TEXT_START
◆ TEXT_STOP
Stop Text Section
- Parameters
-
◆ UNWIND_TABLES
◆ VECTOR_DEFAULT
#define VECTOR_DEFAULT *(.vectors) |
Define entry in Vector section
◆ VECTOR_START
◆ VECTOR_STOP
Stop Vector Section
- Parameters
-