stm32l562xx.ld 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* Linker script to configure memory regions. */
  2. /*
  3. * SPDX-License-Identifier: BSD-3-Clause
  4. ******************************************************************************
  5. * @attention
  6. *
  7. * Copyright (c) 2016-2020 STMicroelectronics.
  8. * All rights reserved.
  9. *
  10. * This software component is licensed by ST under BSD 3-Clause license,
  11. * the "License"; You may not use this file except in compliance with the
  12. * License. You may obtain a copy of the License at:
  13. * opensource.org/licenses/BSD-3-Clause
  14. *
  15. ******************************************************************************
  16. */
  17. /* vectsise is ((125 * 4) + 7) & 0xFFFFFFF8) = 0x1F8
  18. Vects at start of RAM(?) - so add offset*/
  19. _Min_Stack_Size = 0x400;
  20. MEMORY
  21. {
  22. FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 0x80000
  23. RAM (rwx) : ORIGIN = 0x200001F8, LENGTH = 0x3FE08
  24. }
  25. /* Linker script to place sections and symbol values. Should be used together
  26. * with other linker script that defines memory regions FLASH and RAM.
  27. * It references following symbols, which must be defined in code:
  28. * Reset_Handler : Entry of reset handler
  29. *
  30. * It defines following symbols, which code can use without definition:
  31. * __exidx_start
  32. * __exidx_end
  33. * __etext
  34. * __data_start__
  35. * __preinit_array_start
  36. * __preinit_array_end
  37. * __init_array_start
  38. * __init_array_end
  39. * __fini_array_start
  40. * __fini_array_end
  41. * __data_end__
  42. * __bss_start__
  43. * __bss_end__
  44. * __end__
  45. * end
  46. * __HeapLimit
  47. * __StackLimit
  48. * __StackTop
  49. * __stack
  50. * _estack
  51. */
  52. ENTRY(Reset_Handler)
  53. SECTIONS
  54. {
  55. .text :
  56. {
  57. KEEP(*(.isr_vector))
  58. *(.text*)
  59. KEEP(*(.init))
  60. KEEP(*(.fini))
  61. /* .ctors */
  62. *crtbegin.o(.ctors)
  63. *crtbegin?.o(.ctors)
  64. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  65. *(SORT(.ctors.*))
  66. *(.ctors)
  67. /* .dtors */
  68. *crtbegin.o(.dtors)
  69. *crtbegin?.o(.dtors)
  70. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  71. *(SORT(.dtors.*))
  72. *(.dtors)
  73. *(.rodata*)
  74. KEEP(*(.eh_frame*))
  75. } > FLASH
  76. .ARM.extab :
  77. {
  78. *(.ARM.extab* .gnu.linkonce.armextab.*)
  79. } > FLASH
  80. __exidx_start = .;
  81. .ARM.exidx :
  82. {
  83. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  84. } > FLASH
  85. __exidx_end = .;
  86. /* Location counter can end up 2byte aligned with narrow Thumb code but
  87. __etext is assumed by startup code to be the LMA of a section in RAM
  88. which must be 8-byte aligned */
  89. __etext = ALIGN (8);
  90. _sidata = .;
  91. .data : AT (__etext)
  92. {
  93. __data_start__ = .;
  94. _sdata = .;
  95. *(vtable)
  96. *(.data*)
  97. . = ALIGN(4);
  98. /* preinit data */
  99. PROVIDE_HIDDEN (__preinit_array_start = .);
  100. KEEP(*(.preinit_array))
  101. PROVIDE_HIDDEN (__preinit_array_end = .);
  102. . = ALIGN(4);
  103. /* init data */
  104. PROVIDE_HIDDEN (__init_array_start = .);
  105. KEEP(*(SORT(.init_array.*)))
  106. KEEP(*(.init_array))
  107. PROVIDE_HIDDEN (__init_array_end = .);
  108. . = ALIGN(4);
  109. /* finit data */
  110. PROVIDE_HIDDEN (__fini_array_start = .);
  111. KEEP(*(SORT(.fini_array.*)))
  112. KEEP(*(.fini_array))
  113. PROVIDE_HIDDEN (__fini_array_end = .);
  114. KEEP(*(.jcr*))
  115. . = ALIGN(4);
  116. /* All data end */
  117. __data_end__ = .;
  118. _edata = .;
  119. } > RAM
  120. /* Uninitialized data section
  121. * This region is not initialized by the C/C++ library and can be used to
  122. * store state across soft reboots. */
  123. .uninitialized (NOLOAD):
  124. {
  125. . = ALIGN(32);
  126. __uninitialized_start = .;
  127. *(.uninitialized)
  128. KEEP(*(.keep.uninitialized))
  129. . = ALIGN(32);
  130. __uninitialized_end = .;
  131. } > RAM
  132. .bss :
  133. {
  134. . = ALIGN(4);
  135. __bss_start__ = .;
  136. _sbss = .;
  137. *(.bss*)
  138. *(COMMON)
  139. . = ALIGN(4);
  140. __bss_end__ = .;
  141. _ebss = .;
  142. } > RAM
  143. .heap (COPY):
  144. {
  145. __end__ = .;
  146. PROVIDE(end = .);
  147. *(.heap*)
  148. . = ORIGIN(RAM) + LENGTH(RAM) - 0x1000; /*0x1000 = MBED_BOOT_STACK_SIZE */
  149. __HeapLimit = .;
  150. } > RAM
  151. /* .stack_dummy section doesn't contains any symbols. It is only
  152. * used for linker to calculate size of stack sections, and assign
  153. * values to stack symbols later */
  154. .stack_dummy (COPY):
  155. {
  156. *(.stack*)
  157. } > RAM
  158. /* Set stack top to end of RAM, and stack limit move down by
  159. * size of stack_dummy section */
  160. __StackTop = ORIGIN(RAM) + LENGTH(RAM);
  161. _estack = __StackTop;
  162. __StackLimit = __StackTop - 0x1000; /*0x1000 = MBED_BOOT_STACK_SIZE */
  163. PROVIDE(__stack = __StackTop);
  164. /* Check if data + heap + stack exceeds RAM limit */
  165. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  166. }