1/*
2** LinkerScript
3** Note: For specific memory allocation, linker and startup files must be customized.
4**       Refer to STM32CubeIDE user guide (UM2609), chapter "Modify the linker script".
5*/
6
7/* Entry Point */
8ENTRY(Reset_Handler)
9
10/* Highest address of the user mode stack */
11_estack = ORIGIN(RAM1) + LENGTH(RAM1); /* end of "SRAM1" Ram type memory */
12
13_Min_Heap_Size  = 0x200; /* required amount of heap  */
14_Min_Stack_Size = 0x400; /* required amount of stack */
15
16/* Memories definition */
17MEMORY
18{
19  ROM    (rx)    : ORIGIN = 0x08000000, LENGTH = 128K   /* Flash memory dedicated to CM4 */
20  RAM1   (xrw)   : ORIGIN = 0x20000000, LENGTH = 16K    /* Non-backup SRAM1 dedicated to CM4 */
21  RAM2   (xrw)   : ORIGIN = 0x20008000, LENGTH = 16K    /* Backup SRAM2 dedicated to CM4 */
22}
23
24/* Sections */
25SECTIONS
26{
27  /* The startup code into "ROM" Rom type memory */
28  .isr_vector :
29  {
30    . = ALIGN(8);
31    KEEP(*(.isr_vector)) /* Startup code */
32    . = ALIGN(8);
33  } >ROM
34
35  /* The program code and other data into "ROM" Rom type memory */
36  .text :
37  {
38    . = ALIGN(8);
39    *(.text)           /* .text sections (code) */
40    *(.text*)          /* .text* sections (code) */
41    *(.glue_7)         /* glue arm to thumb code */
42    *(.glue_7t)        /* glue thumb to arm code */
43    *(.eh_frame)
44
45    KEEP (*(.init))
46    KEEP (*(.fini))
47
48    . = ALIGN(8);
49    _etext = .;        /* define a global symbols at end of code */
50  } >ROM
51
52  /* Constant data into "ROM" Rom type memory */
53  .rodata :
54  {
55    . = ALIGN(8);
56    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
57    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
58    . = ALIGN(8);
59  } >ROM
60
61  .ARM.extab   : {
62    . = ALIGN(8);
63    *(.ARM.extab* .gnu.linkonce.armextab.*)
64    . = ALIGN(8);
65  } >ROM
66
67  .ARM : {
68    . = ALIGN(8);
69    __exidx_start = .;
70    *(.ARM.exidx*)
71    __exidx_end = .;
72    . = ALIGN(8);
73  } >ROM
74
75  .preinit_array     :
76  {
77    . = ALIGN(8);
78    PROVIDE_HIDDEN (__preinit_array_start = .);
79    KEEP (*(.preinit_array*))
80    PROVIDE_HIDDEN (__preinit_array_end = .);
81    . = ALIGN(8);
82  } >ROM
83
84  .init_array :
85  {
86    . = ALIGN(8);
87    PROVIDE_HIDDEN (__init_array_start = .);
88    KEEP (*(SORT(.init_array.*)))
89    KEEP (*(.init_array*))
90    PROVIDE_HIDDEN (__init_array_end = .);
91    . = ALIGN(8);
92  } >ROM
93
94  .fini_array :
95  {
96    . = ALIGN(8);
97    PROVIDE_HIDDEN (__fini_array_start = .);
98    KEEP (*(SORT(.fini_array.*)))
99    KEEP (*(.fini_array*))
100    PROVIDE_HIDDEN (__fini_array_end = .);
101    . = ALIGN(8);
102  } >ROM
103
104  /* Used by the startup to initialize data */
105  _sidata = LOADADDR(.data);
106
107  /* Initialized data sections into "SRAM1" Ram type memory */
108  .data :
109  {
110    . = ALIGN(8);
111    _sdata = .;        /* create a global symbol at data start */
112    *(.data)           /* .data sections */
113    *(.data*)          /* .data* sections */
114
115    . = ALIGN(8);
116    _edata = .;        /* define a global symbol at data end */
117
118  } >RAM1 AT> ROM
119
120  /* Uninitialized data section into "SRAM1" Ram type memory */
121  . = ALIGN(8);
122  .bss :
123  {
124    /* This is used by the startup in order to initialize the .bss section */
125    _sbss = .;         /* define a global symbol at bss start */
126    __bss_start__ = _sbss;
127    *(.bss)
128    *(.bss*)
129    *(COMMON)
130
131    . = ALIGN(8);
132    _ebss = .;         /* define a global symbol at bss end */
133    __bss_end__ = _ebss;
134  } >RAM1
135
136  /* Data section into "SRAM1" Ram type memory: Non-backup SRAM1 dedicated to CM4 */
137  . = ALIGN(8);
138  RAM1_region :
139  {
140    _sRAM1_region = .;         /* define a global symbol at section start */
141    *(.RAM1_region)
142
143    . = ALIGN(8);
144    _eRAM1_region = .;         /* define a global symbol at section end */
145  } >RAM1
146
147  /* Data section into "SRAM2" Ram type memory: Backup SRAM2 dedicated to CM4 */
148  . = ALIGN(8);
149  RAM2_region :
150  {
151    _sRAM2_region = .;         /* define a global symbol at section start */
152    *(.RAM2_region)
153
154    . = ALIGN(8);
155    _eRAM2_region = .;         /* define a global symbol at section end */
156  } >RAM2
157
158  /* User_heap_stack section, used to check that there is enough "SRAM1" Ram  type memory left */
159  ._user_heap_stack :
160  {
161    . = ALIGN(8);
162    PROVIDE ( end = . );
163    PROVIDE ( _end = . );
164    . = . + _Min_Heap_Size;
165    . = . + _Min_Stack_Size;
166    . = ALIGN(8);
167  } >RAM1
168
169  /* Remove information from the compiler libraries */
170  /DISCARD/ :
171  {
172    libc.a ( * )
173    libm.a ( * )
174    libgcc.a ( * )
175  }
176
177  .ARM.attributes 0 : { *(.ARM.attributes) }
178}
179