Hardware Abstraction Layer for FreeRTOS
Collaboration diagram for Linker Script Macros:

Modules

 Driver specific Linker Macros
 

Macros

#define SYMBOL(name)   name = .
 
#define MEM_START   MEMORY {
 
#define MEM_ADD(name, origin, len)   name : ORIGIN = origin, LENGTH = len
 
#define MEM_STOP   }
 
#define SECTIONS_START   SECTIONS {
 
#define SECTION_START(name)   name : {
 
#define SECTION_STOP(location)   } > location AT > location
 
#define SECTION_STOP_RAM(location, flashLocation)   } > location AT > flashLocation
 
#define SECTIONS_STOP   }
 
#define VECTOR_START   SECTION_START(.vectors) . = ALIGN(4);
 
#define VECTOR_DEFAULT   *(.vectors)
 
#define VECTOR_STOP(location)   SECTION_STOP(location)
 
#define TEXT_START   SECTION_START(.text) . = ALIGN(4); SYMBOL(_start_text);
 
#define TEXT_DEFAULT   *(.text*) *(.init*) *(.fini) *(.eh_frame)
 
#define TEXT_FREERTOS   *(.text.freertos*)
 
#define TEXT_STOP(location)   SYMBOL(_end_text); SECTION_STOP(location)
 
#define UNWIND_TABLES
 
#define RODATA_START   SECTION_START(.rodata) . = ALIGN(4);
 
#define RODATA_DEFAULT   *(.rodata) *(.rodata*)
 
#define RODATA_STOP(location)   SECTION_STOP(location) SECTION_START(.unwind) UNWIND_TABLES SECTION_STOP(location)
 
#define DATA_TABLE_START   SYMBOL(_data_table);
 
#define DATA_TABLE(sname)
 
#define DATA_TABLE_STOP   SYMBOL(_data_table_end);
 
#define DATA_START   SECTION_START(.data) . = ALIGN(4); SYMBOL(_start_data);
 
#define DATA_DEFAULT
 
#define DATA_FREERTOS   *(.data.freertos*)
 
#define DATA_STOP(location, flashLocation)   SYMBOL(_end_data); SECTION_STOP_RAM(location, flashLocation)
 
#define BSS_START   SECTION_START(.bss) . = ALIGN(4); SYMBOL(__bss_start__);
 
#define BSS_DEFAULT
 
#define BSS_FREERTOS   *(.bss.freertos*)
 
#define BSS_STOP(location)   SYMBOL(__bss_end__); SECTION_STOP(location)
 
#define HEAP(location, stakSize)
 
#define STACK(location)
 
#define END   = SYMBOL(_end); PROVIDE(end = .);
 

Detailed Description

#include <linker.h>

This Marcos is for creating Linker Scripts

The Linker Files are create by C Preprocessor.

Example Code m0.lds.S:

#include <linker.h>
#include <driver.h>
ENTRY(reset_handler)
MEM_ADD(flash, 0x00000000, 0x20000)
MEM_ADD(sram, 0x00020000, 0x20000)
. = ORIGIN(flash);
VECTOR_STOP(flash)
DATA_TABLE(.data)
TEXT_STOP(flash)
DEV_DEFAULT(flash)
RODATA_STOP(flash)
DATA_STOP(sram, flash)
BSS_STOP(sram)
HEAP(sram, CONFIG_MACH_INIT_STACK_SIZE)
STACK(sram)

Macro Definition Documentation

◆ BSS_DEFAULT

#define 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*)

FreeRTOS BSS Section

◆ BSS_START

#define BSS_START   SECTION_START(.bss) . = ALIGN(4); SYMBOL(__bss_start__);

Start BSS Section This Macro define the symbol bss_start

◆ BSS_STOP

#define BSS_STOP (   location)    SYMBOL(__bss_end__); SECTION_STOP(location)

Stop BSS Section This Macro define the symbol bss_end

Parameters
locationLocation

◆ DATA_DEFAULT

#define DATA_DEFAULT
Value:
*(.data) \
*(.data*) \
*(.fini_array) \
*(.gnu.linkonce.d.*) \
. = ALIGN(8); \
__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*)

FreeRTOS Data Section

◆ DATA_START

#define DATA_START   SECTION_START(.data) . = ALIGN(4); SYMBOL(_start_data);

Start Data Section This Maco define the symbol _start_data

◆ DATA_STOP

#define DATA_STOP (   location,
  flashLocation 
)    SYMBOL(_end_data); SECTION_STOP_RAM(location, flashLocation)

Stop Data Section this Macro define the symbol _end_data

Parameters
locationLocation
flashLocationLocation 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
snameName of data section for example .data or .data.freertos

◆ DATA_TABLE_START

#define DATA_TABLE_START   SYMBOL(_data_table);

start Data Table Section

◆ DATA_TABLE_STOP

#define DATA_TABLE_STOP   SYMBOL(_data_table_end);

Stop Data Table Section

◆ END

#define END   = SYMBOL(_end); PROVIDE(end = .);

End Symbol

◆ HEAP

#define HEAP (   location,
  stakSize 
)
Value:
SECTION_START(.heap) \
. = ALIGN(4); \
SYMBOL(_heap_end); \
. = ((ORIGIN(location) + LENGTH(location)) - (stakSize)); \
. = ALIGN(4); \
_heap_top = . - 4; \
SECTION_STOP(location)

Define Heap Section

Parameters
locationLocation
stakSizeStack Size

◆ MEM_ADD

#define MEM_ADD (   name,
  origin,
  len 
)    name : ORIGIN = origin, LENGTH = len

Add a Memory Entry

Parameters
nameMemory Name like sram or flash
originMemory position
lenLength of Memory Entry

◆ MEM_START

#define MEM_START   MEMORY {

Define a Memory Block

◆ MEM_STOP

#define MEM_STOP   }

Stop Memory Block

◆ RODATA_DEFAULT

#define RODATA_DEFAULT   *(.rodata) *(.rodata*)

Default Entry in rodata

◆ RODATA_START

#define RODATA_START   SECTION_START(.rodata) . = ALIGN(4);

Start rodata Section

◆ RODATA_STOP

#define RODATA_STOP (   location)    SECTION_STOP(location) SECTION_START(.unwind) UNWIND_TABLES SECTION_STOP(location)

Stop rodata Section And add Unwind Tables after rodata Section

◆ SECTION_START

#define SECTION_START (   name)    name : {

Start Section

Parameters
nameSectionname

◆ SECTION_STOP

#define SECTION_STOP (   location)    } > location AT > location

Stop Section

Parameters
locationlocation

◆ SECTION_STOP_RAM

#define SECTION_STOP_RAM (   location,
  flashLocation 
)    } > location AT > flashLocation

Stop Section located in RAM

Parameters
locationLocation
flashLocationLocation in flash

◆ SECTIONS_START

#define SECTIONS_START   SECTIONS {

Start Sections Block

◆ SECTIONS_STOP

#define SECTIONS_STOP   }

Stop Section

◆ STACK

#define STACK (   location)
Value:
SECTION_START(.stackArea) \
. = ALIGN(4); \
SYMBOL(_start_stack); \
_end_stack = (ORIGIN(location) + LENGTH(location)); \
__freertos_irq_stack_top = (ORIGIN(location) + LENGTH(location)); \
SECTION_STOP(location)

Define Stack Section

Parameters
locationLocation

◆ SYMBOL

#define SYMBOL (   name)    name = .

Define a Symbol

Parameters
nameSymbolname

◆ TEXT_DEFAULT

#define TEXT_DEFAULT   *(.text*) *(.init*) *(.fini) *(.eh_frame)

Default Entry for text section

◆ TEXT_FREERTOS

#define TEXT_FREERTOS   *(.text.freertos*)

FreeRTOS Text Section

◆ TEXT_START

#define TEXT_START   SECTION_START(.text) . = ALIGN(4); SYMBOL(_start_text);

Start Text Section

◆ TEXT_STOP

#define TEXT_STOP (   location)    SYMBOL(_end_text); SECTION_STOP(location)

Stop Text Section

Parameters
locationLocation

◆ UNWIND_TABLES

#define UNWIND_TABLES

◆ VECTOR_DEFAULT

#define VECTOR_DEFAULT   *(.vectors)

Define entry in Vector section

◆ VECTOR_START

#define VECTOR_START   SECTION_START(.vectors) . = ALIGN(4);

Start vector Section

◆ VECTOR_STOP

#define VECTOR_STOP (   location)    SECTION_STOP(location)

Stop Vector Section

Parameters
locationLocation
ALIGN
#define ALIGN(x)
Definition: system.h:105
MIN
#define MIN(a, b)
Definition: system.h:186
BSS_START
#define BSS_START
Definition: linker.h:229
HEAP
#define HEAP(location, stakSize)
Definition: linker.h:256
driver.h
DATA_DEFAULT
#define DATA_DEFAULT
Definition: linker.h:199
VECTOR_DEFAULT
#define VECTOR_DEFAULT
Definition: linker.h:119
MEM_STOP
#define MEM_STOP
Definition: linker.h:83
MAX
#define MAX(a, b)
Definition: system.h:179
TEXT_DEFAULT
#define TEXT_DEFAULT
Definition: linker.h:133
DEV_DEFAULT
#define DEV_DEFAULT(location)
Definition: driver.h:21
SECTION_START
#define SECTION_START(name)
Definition: linker.h:92
TEXT_STOP
#define TEXT_STOP(location)
Definition: linker.h:142
BSS_DEFAULT
#define BSS_DEFAULT
Definition: linker.h:233
TEXT_START
#define TEXT_START
Definition: linker.h:129
VECTOR_START
#define VECTOR_START
Definition: linker.h:115
DATA_STOP
#define DATA_STOP(location, flashLocation)
Definition: linker.h:223
VECTOR_STOP
#define VECTOR_STOP(location)
Definition: linker.h:124
RODATA_DEFAULT
#define RODATA_DEFAULT
Definition: linker.h:157
MEM_ADD
#define MEM_ADD(name, origin, len)
Definition: linker.h:79
SECTIONS_START
#define SECTIONS_START
Definition: linker.h:87
MEM_START
#define MEM_START
Definition: linker.h:72
DATA_TABLE
#define DATA_TABLE(sname)
Definition: linker.h:173
DATA_TABLE_START
#define DATA_TABLE_START
Definition: linker.h:167
DATA_TABLE_STOP
#define DATA_TABLE_STOP
Definition: linker.h:190
SECTIONS_STOP
#define SECTIONS_STOP
Definition: linker.h:111
linker.h
DATA_START
#define DATA_START
Definition: linker.h:195
RODATA_STOP
#define RODATA_STOP(location)
Definition: linker.h:162
STACK
#define STACK(location)
Definition: linker.h:267
RODATA_START
#define RODATA_START
Definition: linker.h:153
BSS_STOP
#define BSS_STOP(location)
Definition: linker.h:250