| [20] | 1 | /* | 
|---|
 | 2 | ****************************************************************************** | 
|---|
 | 3 | ** | 
|---|
 | 4 |  | 
|---|
 | 5 | **  File        : LinkerScript.ld | 
|---|
 | 6 | ** | 
|---|
 | 7 | **  Author              : STM32CubeMX | 
|---|
 | 8 | ** | 
|---|
 | 9 | **  Abstract    : Linker script for STM32G473RCTx series | 
|---|
 | 10 | **                256Kbytes FLASH and 128Kbytes RAM | 
|---|
 | 11 | ** | 
|---|
 | 12 | **                Set heap size, stack size and stack location according | 
|---|
 | 13 | **                to application requirements. | 
|---|
 | 14 | ** | 
|---|
 | 15 | **                Set memory bank area and size if external memory is used. | 
|---|
 | 16 | ** | 
|---|
 | 17 | **  Target      : STMicroelectronics STM32 | 
|---|
 | 18 | ** | 
|---|
 | 19 | **  Distribution: The file is distributed “as is,” without any warranty | 
|---|
 | 20 | **                of any kind. | 
|---|
 | 21 | ** | 
|---|
 | 22 | ***************************************************************************** | 
|---|
 | 23 | ** @attention | 
|---|
 | 24 | ** | 
|---|
 | 25 | ** <h2><center>© COPYRIGHT(c) 2025 STMicroelectronics</center></h2> | 
|---|
 | 26 | ** | 
|---|
 | 27 | ** Redistribution and use in source and binary forms, with or without modification, | 
|---|
 | 28 | ** are permitted provided that the following conditions are met: | 
|---|
 | 29 | **   1. Redistributions of source code must retain the above copyright notice, | 
|---|
 | 30 | **      this list of conditions and the following disclaimer. | 
|---|
 | 31 | **   2. Redistributions in binary form must reproduce the above copyright notice, | 
|---|
 | 32 | **      this list of conditions and the following disclaimer in the documentation | 
|---|
 | 33 | **      and/or other materials provided with the distribution. | 
|---|
 | 34 | **   3. Neither the name of STMicroelectronics nor the names of its contributors | 
|---|
 | 35 | **      may be used to endorse or promote products derived from this software | 
|---|
 | 36 | **      without specific prior written permission. | 
|---|
 | 37 | ** | 
|---|
 | 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 
|---|
 | 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
|---|
 | 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 
|---|
 | 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | 
|---|
 | 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
|---|
 | 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 
|---|
 | 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 
|---|
 | 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 
|---|
 | 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
|---|
 | 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
|---|
 | 48 | ** | 
|---|
 | 49 | ***************************************************************************** | 
|---|
 | 50 | */ | 
|---|
 | 51 |  | 
|---|
 | 52 | /* Entry Point */ | 
|---|
 | 53 | ENTRY(Reset_Handler) | 
|---|
 | 54 |  | 
|---|
 | 55 | /* Specify the memory areas */ | 
|---|
 | 56 | MEMORY | 
|---|
 | 57 | { | 
|---|
 | 58 | RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 128K | 
|---|
 | 59 | FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 256K | 
|---|
 | 60 | } | 
|---|
 | 61 |  | 
|---|
 | 62 | /* Highest address of the user mode stack */ | 
|---|
 | 63 | _estack = ORIGIN(RAM) + LENGTH(RAM);    /* end of RAM */ | 
|---|
 | 64 | /* Generate a link error if heap and stack don't fit into RAM */ | 
|---|
 | 65 | _Min_Heap_Size = 0x200;      /* required amount of heap  */ | 
|---|
 | 66 | _Min_Stack_Size = 0x400; /* required amount of stack */ | 
|---|
 | 67 |  | 
|---|
 | 68 | /* Define output sections */ | 
|---|
 | 69 | SECTIONS | 
|---|
 | 70 | { | 
|---|
 | 71 |   /* The startup code goes first into FLASH */ | 
|---|
 | 72 |   .isr_vector : | 
|---|
 | 73 |   { | 
|---|
 | 74 |     . = ALIGN(4); | 
|---|
 | 75 |     KEEP(*(.isr_vector)) /* Startup code */ | 
|---|
 | 76 |     . = ALIGN(4); | 
|---|
 | 77 |   } >FLASH | 
|---|
 | 78 |  | 
|---|
 | 79 |   /* The program code and other data goes into FLASH */ | 
|---|
 | 80 |   .text : | 
|---|
 | 81 |   { | 
|---|
 | 82 |     . = ALIGN(4); | 
|---|
 | 83 |     *(.text)           /* .text sections (code) */ | 
|---|
 | 84 |     *(.text*)          /* .text* sections (code) */ | 
|---|
 | 85 |     *(.glue_7)         /* glue arm to thumb code */ | 
|---|
 | 86 |     *(.glue_7t)        /* glue thumb to arm code */ | 
|---|
 | 87 |     *(.eh_frame) | 
|---|
 | 88 |  | 
|---|
 | 89 |     KEEP (*(.init)) | 
|---|
 | 90 |     KEEP (*(.fini)) | 
|---|
 | 91 |  | 
|---|
 | 92 |     . = ALIGN(4); | 
|---|
 | 93 |     _etext = .;        /* define a global symbols at end of code */ | 
|---|
 | 94 |   } >FLASH | 
|---|
 | 95 |  | 
|---|
 | 96 |   /* Constant data goes into FLASH */ | 
|---|
 | 97 |   .rodata : | 
|---|
 | 98 |   { | 
|---|
 | 99 |     . = ALIGN(4); | 
|---|
 | 100 |     *(.rodata)         /* .rodata sections (constants, strings, etc.) */ | 
|---|
 | 101 |     *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */ | 
|---|
 | 102 |     . = ALIGN(4); | 
|---|
 | 103 |   } >FLASH | 
|---|
 | 104 |  | 
|---|
 | 105 |   .ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | 
|---|
 | 106 |   { | 
|---|
 | 107 |     . = ALIGN(4); | 
|---|
 | 108 |     *(.ARM.extab* .gnu.linkonce.armextab.*) | 
|---|
 | 109 |     . = ALIGN(4); | 
|---|
 | 110 |   } >FLASH | 
|---|
 | 111 |  | 
|---|
 | 112 |   .ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | 
|---|
 | 113 |   { | 
|---|
 | 114 |     . = ALIGN(4); | 
|---|
 | 115 |     __exidx_start = .; | 
|---|
 | 116 |     *(.ARM.exidx*) | 
|---|
 | 117 |     __exidx_end = .; | 
|---|
 | 118 |     . = ALIGN(4); | 
|---|
 | 119 |   } >FLASH | 
|---|
 | 120 |  | 
|---|
 | 121 |   .preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | 
|---|
 | 122 |   { | 
|---|
 | 123 |     . = ALIGN(4); | 
|---|
 | 124 |     PROVIDE_HIDDEN (__preinit_array_start = .); | 
|---|
 | 125 |     KEEP (*(.preinit_array*)) | 
|---|
 | 126 |     PROVIDE_HIDDEN (__preinit_array_end = .); | 
|---|
 | 127 |     . = ALIGN(4); | 
|---|
 | 128 |   } >FLASH | 
|---|
 | 129 |  | 
|---|
 | 130 |   .init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | 
|---|
 | 131 |   { | 
|---|
 | 132 |     . = ALIGN(4); | 
|---|
 | 133 |     PROVIDE_HIDDEN (__init_array_start = .); | 
|---|
 | 134 |     KEEP (*(SORT(.init_array.*))) | 
|---|
 | 135 |     KEEP (*(.init_array*)) | 
|---|
 | 136 |     PROVIDE_HIDDEN (__init_array_end = .); | 
|---|
 | 137 |     . = ALIGN(4); | 
|---|
 | 138 |   } >FLASH | 
|---|
 | 139 |  | 
|---|
 | 140 |   .fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */ | 
|---|
 | 141 |   { | 
|---|
 | 142 |     . = ALIGN(4); | 
|---|
 | 143 |     PROVIDE_HIDDEN (__fini_array_start = .); | 
|---|
 | 144 |     KEEP (*(SORT(.fini_array.*))) | 
|---|
 | 145 |     KEEP (*(.fini_array*)) | 
|---|
 | 146 |     PROVIDE_HIDDEN (__fini_array_end = .); | 
|---|
 | 147 |     . = ALIGN(4); | 
|---|
 | 148 |   } >FLASH | 
|---|
 | 149 |  | 
|---|
 | 150 |   /* used by the startup to initialize data */ | 
|---|
 | 151 |   _sidata = LOADADDR(.data); | 
|---|
 | 152 |  | 
|---|
 | 153 |   /* Initialized data sections goes into RAM, load LMA copy after code */ | 
|---|
 | 154 |   .data : | 
|---|
 | 155 |   { | 
|---|
 | 156 |     . = ALIGN(4); | 
|---|
 | 157 |     _sdata = .;        /* create a global symbol at data start */ | 
|---|
 | 158 |     *(.data)           /* .data sections */ | 
|---|
 | 159 |     *(.data*)          /* .data* sections */ | 
|---|
 | 160 |     *(.RamFunc)        /* .RamFunc sections */ | 
|---|
 | 161 |     *(.RamFunc*)       /* .RamFunc* sections */ | 
|---|
 | 162 |  | 
|---|
 | 163 |     . = ALIGN(4); | 
|---|
 | 164 |   } >RAM AT> FLASH | 
|---|
 | 165 |  | 
|---|
 | 166 |  /* Initialized TLS data section */ | 
|---|
 | 167 |   .tdata : ALIGN(4) | 
|---|
 | 168 |   { | 
|---|
 | 169 |     *(.tdata .tdata.* .gnu.linkonce.td.*) | 
|---|
 | 170 |     . = ALIGN(4); | 
|---|
 | 171 |     _edata = .;        /* define a global symbol at data end */ | 
|---|
 | 172 |     PROVIDE(__data_end = .); | 
|---|
 | 173 |     PROVIDE(__tdata_end = .); | 
|---|
 | 174 |   } >RAM AT> FLASH | 
|---|
 | 175 |  | 
|---|
 | 176 |   PROVIDE( __tdata_start = ADDR(.tdata) ); | 
|---|
 | 177 |   PROVIDE( __tdata_size = __tdata_end - __tdata_start ); | 
|---|
 | 178 |  | 
|---|
 | 179 |   PROVIDE( __data_start = ADDR(.data) ); | 
|---|
 | 180 |   PROVIDE( __data_size = __data_end - __data_start ); | 
|---|
 | 181 |  | 
|---|
 | 182 |   PROVIDE( __tdata_source = LOADADDR(.tdata) ); | 
|---|
 | 183 |   PROVIDE( __tdata_source_end = LOADADDR(.tdata) + SIZEOF(.tdata) ); | 
|---|
 | 184 |   PROVIDE( __tdata_source_size = __tdata_source_end - __tdata_source ); | 
|---|
 | 185 |  | 
|---|
 | 186 |   PROVIDE( __data_source = LOADADDR(.data) ); | 
|---|
 | 187 |   PROVIDE( __data_source_end = __tdata_source_end ); | 
|---|
 | 188 |   PROVIDE( __data_source_size = __data_source_end - __data_source ); | 
|---|
 | 189 |   /* Uninitialized data section */ | 
|---|
 | 190 |   .tbss (NOLOAD) : ALIGN(4) | 
|---|
 | 191 |   { | 
|---|
 | 192 |      /* This is used by the startup in order to initialize the .bss secion */ | 
|---|
 | 193 |     _sbss = .;         /* define a global symbol at bss start */ | 
|---|
 | 194 |     __bss_start__ = _sbss; | 
|---|
 | 195 |     *(.tbss .tbss.*) | 
|---|
 | 196 |     . = ALIGN(4); | 
|---|
 | 197 |     PROVIDE( __tbss_end = . ); | 
|---|
 | 198 |   } >RAM | 
|---|
 | 199 |  | 
|---|
 | 200 |   PROVIDE( __tbss_start = ADDR(.tbss) ); | 
|---|
 | 201 |   PROVIDE( __tbss_size = __tbss_end - __tbss_start ); | 
|---|
 | 202 |   PROVIDE( __tbss_offset = ADDR(.tbss) - ADDR(.tdata) ); | 
|---|
 | 203 |  | 
|---|
 | 204 |   PROVIDE( __tls_base = __tdata_start ); | 
|---|
 | 205 |   PROVIDE( __tls_end = __tbss_end ); | 
|---|
 | 206 |   PROVIDE( __tls_size = __tls_end - __tls_base ); | 
|---|
 | 207 |   PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) ); | 
|---|
 | 208 |   PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1) ); | 
|---|
 | 209 |   PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) ); | 
|---|
 | 210 |   PROVIDE( __arm64_tls_tcb_offset = MAX(16, __tls_align) ); | 
|---|
 | 211 |  | 
|---|
 | 212 |   .bss (NOLOAD) : ALIGN(4) | 
|---|
 | 213 |   { | 
|---|
 | 214 |     *(.bss) | 
|---|
 | 215 |     *(.bss*) | 
|---|
 | 216 |     *(COMMON) | 
|---|
 | 217 |  | 
|---|
 | 218 |       . = ALIGN(4); | 
|---|
 | 219 |     _ebss = .;         /* define a global symbol at bss end */ | 
|---|
 | 220 |     __bss_end__ = _ebss; | 
|---|
 | 221 |       PROVIDE( __bss_end = .); | 
|---|
 | 222 |   } >RAM | 
|---|
 | 223 |   PROVIDE( __non_tls_bss_start = ADDR(.bss) ); | 
|---|
 | 224 |  | 
|---|
 | 225 |   PROVIDE( __bss_start = __tbss_start ); | 
|---|
 | 226 |   PROVIDE( __bss_size = __bss_end - __bss_start ); | 
|---|
 | 227 |  | 
|---|
 | 228 |   /* User_heap_stack section, used to check that there is enough RAM left */ | 
|---|
 | 229 |   ._user_heap_stack (NOLOAD) : | 
|---|
 | 230 |   { | 
|---|
 | 231 |     . = ALIGN(8); | 
|---|
 | 232 |     PROVIDE ( end = . ); | 
|---|
 | 233 |     PROVIDE ( _end = . ); | 
|---|
 | 234 |     . = . + _Min_Heap_Size; | 
|---|
 | 235 |     . = . + _Min_Stack_Size; | 
|---|
 | 236 |     . = ALIGN(8); | 
|---|
 | 237 |   } >RAM | 
|---|
 | 238 |  | 
|---|
 | 239 |  | 
|---|
 | 240 |  | 
|---|
 | 241 |   /* Remove information from the standard libraries */ | 
|---|
 | 242 |   /DISCARD/ : | 
|---|
 | 243 |   { | 
|---|
 | 244 |     libc.a:* ( * ) | 
|---|
 | 245 |     libm.a:* ( * ) | 
|---|
 | 246 |     libgcc.a:* ( * ) | 
|---|
 | 247 |   } | 
|---|
 | 248 |  | 
|---|
 | 249 | } | 
|---|