Hardware Abstraction Layer for FreeRTOS
linker.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Author: Andreas Werner <kernel@andy89.org>
4  * Date: 2016
5  */
6 #ifndef LINKER_H_
7 
63 #ifdef LINKER_SCRIPT
64 
68 #define SYMBOL(name) name = .
69 
72 #define MEM_START MEMORY {
73 
79 #define MEM_ADD(name, origin, len) name : ORIGIN = origin, LENGTH = len
80 
83 #define MEM_STOP }
84 
87 #define SECTIONS_START SECTIONS {
88 
92 #define SECTION_START(name) name : {
93 #ifdef CONFIG_MACH_HAS_NO_LOCATION
94 # define SECTION_STOP(location) }
95 #else
96 
100 # define SECTION_STOP(location) } > location AT > location
101 #endif
102 
107 #define SECTION_STOP_RAM(location, flashLocation) } > location AT > flashLocation
108 
111 #define SECTIONS_STOP }
112 
115 #define VECTOR_START SECTION_START(.vectors) . = ALIGN(4);
116 
119 #define VECTOR_DEFAULT *(.vectors)
120 
124 #define VECTOR_STOP(location) SECTION_STOP(location)
125 
129 #define TEXT_START SECTION_START(.text) . = ALIGN(4); SYMBOL(_start_text);
130 
133 #define TEXT_DEFAULT *(.text*) *(.init*) *(.fini) *(.eh_frame)
134 
137 #define TEXT_FREERTOS *(.text.freertos*)
138 
142 #define TEXT_STOP(location) SYMBOL(_end_text); SECTION_STOP(location)
143 
144 #ifdef CONFIG_GENERATE_UNWIND_TABLES
145 # define UNWIND_TABLES SYMBOL(__exidx_start); *(.ARM.exidx* .gnu.linkonce.armexidx.*) SYMBOL(__exidx_end);
146 #else
147 # define UNWIND_TABLES
148 #endif
149 
153 #define RODATA_START SECTION_START(.rodata) . = ALIGN(4);
154 
157 #define RODATA_DEFAULT *(.rodata) *(.rodata*)
158 
162 #define RODATA_STOP(location) SECTION_STOP(location) SECTION_START(.unwind) UNWIND_TABLES SECTION_STOP(location)
163 
167 #define DATA_TABLE_START SYMBOL(_data_table);
168 #ifndef CONFIG_ARCH_64BIT
169 
173 #define DATA_TABLE(sname) \
174  LONG(LOADADDR(sname)); \
175  LONG(ADDR(sname)); \
176  LONG(SIZEOF(sname));
177 #else
178 
182 #define DATA_TABLE(sname) \
183  QUAD(LOADADDR(sname)); \
184  QUAD(ADDR(sname)); \
185  QUAD(SIZEOF(sname));
186 #endif
187 
190 #define DATA_TABLE_STOP SYMBOL(_data_table_end);
191 
195 #define DATA_START SECTION_START(.data) . = ALIGN(4); SYMBOL(_start_data);
196 
199 #define DATA_DEFAULT \
200  *(.data) \
201  *(.data*) \
202  *(.fini_array) \
203  *(.gnu.linkonce.d.*) \
204  . = ALIGN(8); \
205  __sdata_begin__ = .; \
206  *(.srodata.cst16) \
207  *(.srodata.cst8) \
208  *(.srodata.cst4) \
209  *(.srodata.cst2) \
210  *(.srodata .srodata.*) \
211  *(.sdata .sdata.* .gnu.linkonce.s.*)
212 
216 #define DATA_FREERTOS *(.data.freertos*)
217 
223 #define DATA_STOP(location, flashLocation) SYMBOL(_end_data); SECTION_STOP_RAM(location, flashLocation)
224 
229 #define BSS_START SECTION_START(.bss) . = ALIGN(4); SYMBOL(__bss_start__);
230 
233 #define BSS_DEFAULT \
234  *(.dynsbss) \
235  *(.sbss .sbss.* .gnu.linkonce.sb.*) \
236  *(.scommon) \
237  *(.bss) \
238  *(.bss*)\
239  PROVIDE(__global_pointer$ = MIN(__sdata_begin__ + 0x800, \
240  MAX(_start_data + 0x800, __bss_end__ - 0x800)));
241 
244 #define BSS_FREERTOS *(.bss.freertos*)
245 
250 #define BSS_STOP(location) SYMBOL(__bss_end__); SECTION_STOP(location)
251 
256 #define HEAP(location, stakSize) SECTION_START(.heap) \
257  . = ALIGN(4); \
258  SYMBOL(_heap_end); \
259  . = ((ORIGIN(location) + LENGTH(location)) - (stakSize)); \
260  . = ALIGN(4); \
261  _heap_top = . - 4; \
262  SECTION_STOP(location)
263 
267 #define STACK(location) SECTION_START(.stackArea) \
268  . = ALIGN(4); \
269  SYMBOL(_start_stack); \
270  _end_stack = (ORIGIN(location) + LENGTH(location)); \
271  __freertos_irq_stack_top = (ORIGIN(location) + LENGTH(location)); \
272  SECTION_STOP(location)
273 
276 #define END = SYMBOL(_end); PROVIDE(end = .);
277 
278 #endif
279 
280 #endif