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 /* used by the startup to initialize data */
120 _sidata = LOADADDR(.data);
122 /* Initialized data sections goes into RAM, load LMA copy after code */
126 _sdata = .; /* create a global symbol at data start */
127 *(.data) /* .data sections */
128 *(.data*) /* .data* sections */
131 _edata = .; /* define a global symbol at data end */
132 } >RAM AT> MOVABLE_FLASH
134 /* Uninitialized data section */
138 /* This is used by the startup in order to initialize the .bss secion */
139 _sbss = .; /* define a global symbol at bss start */
140 __bss_start__ = _sbss;
142 *(SORT_BY_ALIGNMENT(.bss*))
146 _ebss = .; /* define a global symbol at bss end */
150 /* used during startup to initialized fastram_data */
151 _sfastram_idata = LOADADDR(.fastram_data);
153 /* Initialized FAST_DATA section for unsuspecting developers */
157 _sfastram_data = .; /* create a global symbol at data start */
158 *(.fastram_data) /* .data sections */
159 *(.fastram_data*) /* .data* sections */
162 _efastram_data = .; /* define a global symbol at data end */
163 } >FASTRAM AT> FLASH1
166 .fastram_bss (NOLOAD) :
168 __fastram_bss_start__ = .;
170 *(SORT_BY_ALIGNMENT(.fastram_bss*))
172 __fastram_bss_end__ = .;
175 .persistent_data (NOLOAD) :
177 __persistent_data_start__ = .;
180 __persistent_data_end__ = .;
183 /* User_heap_stack section, used to check that there is enough RAM left */
184 _heap_stack_end = ORIGIN(STACKRAM) + LENGTH(STACKRAM) - _Hot_Reboot_Flags_Size;
185 _heap_stack_begin = _heap_stack_end - _Min_Stack_Size - _Min_Heap_Size;
186 . = _heap_stack_begin;
191 PROVIDE ( _end = . );
192 . = . + _Min_Heap_Size;
193 . = . + _Min_Stack_Size;
197 /* MEMORY_bank1 section, code must be located here explicitly */
198 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
201 *(.mb1text) /* .mb1text sections (code) */
202 *(.mb1text*) /* .mb1text* sections (code) */
203 *(.mb1rodata) /* read-only data (constants) */
207 /* Remove information from the standard libraries */
215 .ARM.attributes 0 : { *(.ARM.attributes) }