2 *****************************************************************************
4 ** File : stm32_flash.ld
6 ** Abstract : Common linker script for STM32 devices.
8 *****************************************************************************
14 /* Highest address of the user mode stack */
15 _estack = ORIGIN(STACKRAM) + LENGTH(STACKRAM); /* end of RAM */
17 /* Base address where the config is stored. */
18 __config_start = ORIGIN(FLASH_CONFIG);
19 __config_end = ORIGIN(FLASH_CONFIG) + LENGTH(FLASH_CONFIG);
21 /* Define output sections */
24 /* The startup code goes first into FLASH */
28 PROVIDE (isr_vector_table_base = .);
29 KEEP(*(.isr_vector)) /* Startup code */
33 /* The program code and other data goes into FLASH */
37 *(.text) /* .text sections (code) */
38 *(.text*) /* .text* sections (code) */
39 *(.rodata) /* .rodata sections (constants, strings, etc.) */
40 *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
41 *(.glue_7) /* glue arm to thumb code */
42 *(.glue_7t) /* glue thumb to arm code */
49 _etext = .; /* define a global symbols at end of code */
52 tcm_code = LOADADDR(.tcm_code);
63 .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
72 PROVIDE_HIDDEN (__preinit_array_start = .);
73 KEEP (*(.preinit_array*))
74 PROVIDE_HIDDEN (__preinit_array_end = .);
78 PROVIDE_HIDDEN (__init_array_start = .);
79 KEEP (*(SORT(.init_array.*)))
80 KEEP (*(.init_array*))
81 PROVIDE_HIDDEN (__init_array_end = .);
85 PROVIDE_HIDDEN (__fini_array_start = .);
86 KEEP (*(.fini_array*))
87 KEEP (*(SORT(.fini_array.*)))
88 PROVIDE_HIDDEN (__fini_array_end = .);
92 PROVIDE_HIDDEN (__pg_registry_start = .);
93 KEEP (*(.pg_registry))
94 KEEP (*(SORT(.pg_registry.*)))
95 PROVIDE_HIDDEN (__pg_registry_end = .);
99 PROVIDE_HIDDEN (__pg_resetdata_start = .);
100 KEEP (*(.pg_resetdata))
101 PROVIDE_HIDDEN (__pg_resetdata_end = .);
105 PROVIDE_HIDDEN (__busdev_registry_start = .);
106 KEEP (*(.busdev_registry))
107 KEEP (*(SORT(.busdev_registry.*)))
108 PROVIDE_HIDDEN (__busdev_registry_end = .);
111 /* used by the startup to initialize data */
114 /* Initialized data sections goes into RAM, load LMA copy after code */
118 _sdata = .; /* create a global symbol at data start */
119 *(.data) /* .data sections */
120 *(.data*) /* .data* sections */
123 _edata = .; /* define a global symbol at data end */
126 /* Uninitialized data section */
130 /* This is used by the startup in order to initialize the .bss secion */
131 _sbss = .; /* define a global symbol at bss start */
132 __bss_start__ = _sbss;
134 *(SORT_BY_ALIGNMENT(.bss*))
138 _ebss = .; /* define a global symbol at bss end */
142 .fastram_bss (NOLOAD) :
144 __fastram_bss_start__ = .;
146 *(SORT_BY_ALIGNMENT(.fastram_bss*))
148 __fastram_bss_end__ = .;
151 /* User_heap_stack section, used to check that there is enough RAM left */
152 _heap_stack_end = ORIGIN(STACKRAM)+LENGTH(STACKRAM) - 8; /* 8 bytes to allow for alignment */
153 _heap_stack_begin = _heap_stack_end - _Min_Stack_Size - _Min_Heap_Size;
154 . = _heap_stack_begin;
159 PROVIDE ( _end = . );
160 . = . + _Min_Heap_Size;
161 . = . + _Min_Stack_Size;
165 /* MEMORY_bank1 section, code must be located here explicitly */
166 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
169 *(.mb1text) /* .mb1text sections (code) */
170 *(.mb1text*) /* .mb1text* sections (code) */
171 *(.mb1rodata) /* read-only data (constants) */
175 /* Remove information from the standard libraries */
183 .ARM.attributes 0 : { *(.ARM.attributes) }