STM32F103XX_FLASH.ld 7.9 KB

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