2 *****************************************************************************
4 ** File : stm32_flash_f4_split.ld
6 ** Abstract : Common linker script for STM32 devices.
8 *****************************************************************************
14 /* Highest address of the user mode stack */
15 _Hot_Reboot_Flags_Size = 16;
16 _estack = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - _Hot_Reboot_Flags_Size; /* end of RAM */
18 /* Base address where the config is stored. */
19 __config_start = ORIGIN(FLASH_CONFIG);
20 __config_end = ORIGIN(FLASH_CONFIG) + LENGTH(FLASH_CONFIG);
22 /* Generate a link error if heap and stack don't fit into RAM */
23 _Min_Heap_Size = 0; /* required amount of heap */
24 _Min_Stack_Size = 0x800; /* required amount of stack */
26 /* Define output sections */
30 * The ISR vector table is loaded at the beginning of the FLASH,
31 * But it is linked (space reserved) at the beginning of the VECTAB region,
32 * which is aliased either to FLASH or RAM.
33 * When linked to RAM, the table can optionally be copied from FLASH to RAM
34 * for table relocation.
37 _isr_vector_table_flash_base = LOADADDR(.isr_vector);
38 PROVIDE (isr_vector_table_flash_base = _isr_vector_table_flash_base);
43 PROVIDE (isr_vector_table_base = .);
44 KEEP(*(.isr_vector)) /* Startup code */
46 PROVIDE (isr_vector_table_end = .);
49 /* System memory (read-only bootloader) interrupt vector */
50 .system_isr_vector (NOLOAD) :
53 PROVIDE (system_isr_vector_table_base = .);
54 KEEP(*(.system_isr_vector)) /* Bootloader code */
58 /* The program code and other data goes into FLASH */
62 *(.text) /* .text sections (code) */
63 *(.text*) /* .text* sections (code) */
64 *(.rodata) /* .rodata sections (constants, strings, etc.) */
65 *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
66 *(.glue_7) /* glue arm to thumb code */
67 *(.glue_7t) /* glue thumb to arm code */
74 _etext = .; /* define a global symbols at end of code */
78 .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
87 PROVIDE_HIDDEN (__preinit_array_start = .);
88 KEEP (*(.preinit_array*))
89 PROVIDE_HIDDEN (__preinit_array_end = .);
93 PROVIDE_HIDDEN (__init_array_start = .);
94 KEEP (*(SORT(.init_array.*)))
95 KEEP (*(.init_array*))
96 PROVIDE_HIDDEN (__init_array_end = .);
100 PROVIDE_HIDDEN (__fini_array_start = .);
101 KEEP (*(.fini_array*))
102 KEEP (*(SORT(.fini_array.*)))
103 PROVIDE_HIDDEN (__fini_array_end = .);
107 PROVIDE_HIDDEN (__pg_registry_start = .);
108 KEEP (*(.pg_registry))
109 KEEP (*(SORT(.pg_registry.*)))
110 PROVIDE_HIDDEN (__pg_registry_end = .);
114 PROVIDE_HIDDEN (__pg_resetdata_start = .);
115 KEEP (*(.pg_resetdata))
116 PROVIDE_HIDDEN (__pg_resetdata_end = .);
119 /* Storage for the address for the configuration section so we can grab it out of the hex file */
123 KEEP (*(.custom_defaults_start_address))
125 KEEP (*(.custom_defaults_end_address))
127 __custom_defaults_internal_start = .;
128 KEEP (*(.custom_defaults))
130 } >FLASH_CUSTOM_DEFAULTS
132 PROVIDE_HIDDEN (__custom_defaults_start = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? ORIGIN(FLASH_CUSTOM_DEFAULTS_EXTENDED) : __custom_defaults_internal_start);
133 PROVIDE_HIDDEN (__custom_defaults_end = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? ORIGIN(FLASH_CUSTOM_DEFAULTS_EXTENDED) + LENGTH(FLASH_CUSTOM_DEFAULTS_EXTENDED) : ORIGIN(FLASH_CUSTOM_DEFAULTS) + LENGTH(FLASH_CUSTOM_DEFAULTS));
135 /* used by the startup to initialize data */
136 _sidata = LOADADDR(.data);
138 /* Initialized data sections goes into RAM, load LMA copy after code */
142 _sdata = .; /* create a global symbol at data start */
143 *(.data) /* .data sections */
144 *(.data*) /* .data* sections */
147 _edata = .; /* define a global symbol at data end */
148 } >RAM AT> MOVABLE_FLASH
150 /* Uninitialized data section */
154 /* This is used by the startup in order to initialize the .bss secion */
155 _sbss = .; /* define a global symbol at bss start */
156 __bss_start__ = _sbss;
158 *(SORT_BY_ALIGNMENT(.bss*))
162 _ebss = .; /* define a global symbol at bss end */
166 /* used during startup to initialized fastram_data */
167 _sfastram_idata = LOADADDR(.fastram_data);
169 /* Initialized FAST_DATA section for unsuspecting developers */
173 _sfastram_data = .; /* create a global symbol at data start */
174 *(.fastram_data) /* .data sections */
175 *(.fastram_data*) /* .data* sections */
178 _efastram_data = .; /* define a global symbol at data end */
179 } >FASTRAM AT> FLASH1
182 .fastram_bss (NOLOAD) :
184 __fastram_bss_start__ = .;
186 *(SORT_BY_ALIGNMENT(.fastram_bss*))
188 __fastram_bss_end__ = .;
191 .persistent_data (NOLOAD) :
193 __persistent_data_start__ = .;
196 __persistent_data_end__ = .;
199 /* User_heap_stack section, used to check that there is enough RAM left */
200 _heap_stack_end = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - _Hot_Reboot_Flags_Size;
201 _heap_stack_begin = _heap_stack_end - _Min_Stack_Size - _Min_Heap_Size;
202 . = _heap_stack_begin;
207 PROVIDE ( _end = . );
208 . = . + _Min_Heap_Size;
209 . = . + _Min_Stack_Size;
213 /* MEMORY_bank1 section, code must be located here explicitly */
214 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
217 *(.mb1text) /* .mb1text sections (code) */
218 *(.mb1text*) /* .mb1text* sections (code) */
219 *(.mb1rodata) /* read-only data (constants) */
223 /* Remove information from the standard libraries */
231 .ARM.attributes 0 : { *(.ARM.attributes) }