ldscript.ld 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. ******************************************************************************
  3. **
  4. ** File : LinkerScript.ld
  5. **
  6. ** Author : Auto-generated by STM32CubeIDE
  7. **
  8. ** Abstract : Linker script for STM32F103V(8/B/C/E/F/GTx Device from STM32F1 series
  9. ** 64/128/256/512/768/1024Kbytes FLASH
  10. ** 20/20/48/64/64/96/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. . = ALIGN(4);
  90. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  91. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  92. . = ALIGN(4);
  93. } >FLASH
  94. .ARM.extab : {
  95. . = ALIGN(4);
  96. *(.ARM.extab* .gnu.linkonce.armextab.*)
  97. . = ALIGN(4);
  98. } >FLASH
  99. .ARM : {
  100. . = ALIGN(4);
  101. __exidx_start = .;
  102. *(.ARM.exidx*)
  103. __exidx_end = .;
  104. . = ALIGN(4);
  105. } >FLASH
  106. .preinit_array : {
  107. . = ALIGN(4);
  108. PROVIDE_HIDDEN (__preinit_array_start = .);
  109. KEEP (*(.preinit_array*))
  110. PROVIDE_HIDDEN (__preinit_array_end = .);
  111. . = ALIGN(4);
  112. } >FLASH
  113. .init_array : {
  114. . = ALIGN(4);
  115. PROVIDE_HIDDEN (__init_array_start = .);
  116. KEEP (*(SORT(.init_array.*)))
  117. KEEP (*(.init_array*))
  118. PROVIDE_HIDDEN (__init_array_end = .);
  119. . = ALIGN(4);
  120. } >FLASH
  121. .fini_array : {
  122. . = ALIGN(4);
  123. PROVIDE_HIDDEN (__fini_array_start = .);
  124. KEEP (*(SORT(.fini_array.*)))
  125. KEEP (*(.fini_array*))
  126. PROVIDE_HIDDEN (__fini_array_end = .);
  127. . = ALIGN(4);
  128. } >FLASH
  129. /* Used by the startup to initialize data */
  130. _sidata = LOADADDR(.data);
  131. /* Initialized data sections into "RAM" Ram type memory */
  132. .data : {
  133. . = ALIGN(4);
  134. _sdata = .; /* create a global symbol at data start */
  135. *(.data) /* .data sections */
  136. *(.data*) /* .data* sections */
  137. . = ALIGN(4);
  138. _edata = .; /* define a global symbol at data end */
  139. } >RAM AT> FLASH
  140. /* Uninitialized data section into "RAM" Ram type memory */
  141. . = ALIGN(4);
  142. .bss : {
  143. /* This is used by the startup in order to initialize the .bss secion */
  144. _sbss = .; /* define a global symbol at bss start */
  145. __bss_start__ = _sbss;
  146. *(.bss)
  147. *(.bss*)
  148. *(COMMON)
  149. . = ALIGN(4);
  150. _ebss = .; /* define a global symbol at bss end */
  151. __bss_end__ = _ebss;
  152. } >RAM
  153. /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
  154. ._user_heap_stack : {
  155. . = ALIGN(8);
  156. PROVIDE ( end = . );
  157. PROVIDE ( _end = . );
  158. . = . + _Min_Heap_Size;
  159. . = . + _Min_Stack_Size;
  160. . = ALIGN(8);
  161. } >RAM
  162. /* Remove information from the compiler libraries */
  163. /DISCARD/ : {
  164. libc.a ( * )
  165. libm.a ( * )
  166. libgcc.a ( * )
  167. }
  168. .ARM.attributes 0 : { *(.ARM.attributes) }
  169. }