ldscript.ld 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. ******************************************************************************
  3. **
  4. ** File : LinkerScript.ld
  5. **
  6. ** Author : Auto-generated by STM32CubeIDE
  7. **
  8. ** Abstract : Linker script for STM32F103Z(C/D/E/G/GTx Device from STM32F1 series
  9. ** 256/386/512K/786/1024bytes FLASH
  10. ** 48/64/96Kbytes 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. ** Copyright (c) 2019 STMicroelectronics
  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. /* Entry Point */
  52. ENTRY(Reset_Handler)
  53. /* Highest address of the user mode stack */
  54. _estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of "RAM" Ram type memory */
  55. _Min_Heap_Size = 0x200; /* required amount of heap */
  56. _Min_Stack_Size = 0x400; /* required amount of stack */
  57. /* Memories definition */
  58. MEMORY
  59. {
  60. RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
  61. FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
  62. }
  63. /* Sections */
  64. SECTIONS
  65. {
  66. /* The startup code into "FLASH" Rom type memory */
  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 into "FLASH" Rom type memory */
  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 into "FLASH" Rom type memory */
  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 : {
  96. . = ALIGN(4);
  97. *(.ARM.extab* .gnu.linkonce.armextab.*)
  98. . = ALIGN(4);
  99. } >FLASH
  100. .ARM : {
  101. . = ALIGN(4);
  102. __exidx_start = .;
  103. *(.ARM.exidx*)
  104. __exidx_end = .;
  105. . = ALIGN(4);
  106. } >FLASH
  107. .preinit_array :
  108. {
  109. . = ALIGN(4);
  110. PROVIDE_HIDDEN (__preinit_array_start = .);
  111. KEEP (*(.preinit_array*))
  112. PROVIDE_HIDDEN (__preinit_array_end = .);
  113. . = ALIGN(4);
  114. } >FLASH
  115. .init_array :
  116. {
  117. . = ALIGN(4);
  118. PROVIDE_HIDDEN (__init_array_start = .);
  119. KEEP (*(SORT(.init_array.*)))
  120. KEEP (*(.init_array*))
  121. PROVIDE_HIDDEN (__init_array_end = .);
  122. . = ALIGN(4);
  123. } >FLASH
  124. .fini_array :
  125. {
  126. . = ALIGN(4);
  127. PROVIDE_HIDDEN (__fini_array_start = .);
  128. KEEP (*(SORT(.fini_array.*)))
  129. KEEP (*(.fini_array*))
  130. PROVIDE_HIDDEN (__fini_array_end = .);
  131. . = ALIGN(4);
  132. } >FLASH
  133. /* Used by the startup to initialize data */
  134. _sidata = LOADADDR(.data);
  135. /* Initialized data sections into "RAM" Ram type memory */
  136. .data :
  137. {
  138. . = ALIGN(4);
  139. _sdata = .; /* create a global symbol at data start */
  140. *(.data) /* .data sections */
  141. *(.data*) /* .data* sections */
  142. . = ALIGN(4);
  143. _edata = .; /* define a global symbol at data end */
  144. } >RAM AT> FLASH
  145. /* Uninitialized data section into "RAM" Ram type memory */
  146. . = ALIGN(4);
  147. .bss :
  148. {
  149. /* This is used by the startup in order to initialize the .bss section */
  150. _sbss = .; /* define a global symbol at bss start */
  151. __bss_start__ = _sbss;
  152. *(.bss)
  153. *(.bss*)
  154. *(COMMON)
  155. . = ALIGN(4);
  156. _ebss = .; /* define a global symbol at bss end */
  157. __bss_end__ = _ebss;
  158. } >RAM
  159. /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
  160. ._user_heap_stack :
  161. {
  162. . = ALIGN(8);
  163. PROVIDE ( end = . );
  164. PROVIDE ( _end = . );
  165. . = . + _Min_Heap_Size;
  166. . = . + _Min_Stack_Size;
  167. . = ALIGN(8);
  168. } >RAM
  169. /* Remove information from the compiler libraries */
  170. /DISCARD/ :
  171. {
  172. libc.a ( * )
  173. libm.a ( * )
  174. libgcc.a ( * )
  175. }
  176. .ARM.attributes 0 : { *(.ARM.attributes) }
  177. }