link.lds 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. ** LinkerScript
  3. ** Note: For specific memory allocation, linker and startup files must be customized.
  4. ** Refer to STM32CubeIDE user guide (UM2609), chapter "Modify the linker script".
  5. */
  6. /* Entry Point */
  7. ENTRY(Reset_Handler)
  8. /* Highest address of the user mode stack */
  9. _estack = ORIGIN(RAM1) + LENGTH(RAM1); /* end of "SRAM1" Ram type memory */
  10. _Min_Heap_Size = 0x200; /* required amount of heap */
  11. _Min_Stack_Size = 0x400; /* required amount of stack */
  12. /* Memories definition */
  13. MEMORY
  14. {
  15. ROM (rx) : ORIGIN = 0x08000000, LENGTH = 128K /* Flash memory dedicated to CM4 */
  16. RAM1 (xrw) : ORIGIN = 0x20000000, LENGTH = 16K /* Non-backup SRAM1 dedicated to CM4 */
  17. RAM2 (xrw) : ORIGIN = 0x20008000, LENGTH = 16K /* Backup SRAM2 dedicated to CM4 */
  18. }
  19. /* Sections */
  20. SECTIONS
  21. {
  22. /* The startup code into "ROM" Rom type memory */
  23. .isr_vector :
  24. {
  25. . = ALIGN(8);
  26. KEEP(*(.isr_vector)) /* Startup code */
  27. . = ALIGN(8);
  28. } >ROM
  29. /* The program code and other data into "ROM" Rom type memory */
  30. .text :
  31. {
  32. . = ALIGN(8);
  33. *(.text) /* .text sections (code) */
  34. *(.text*) /* .text* sections (code) */
  35. *(.glue_7) /* glue arm to thumb code */
  36. *(.glue_7t) /* glue thumb to arm code */
  37. *(.eh_frame)
  38. KEEP (*(.init))
  39. KEEP (*(.fini))
  40. . = ALIGN(8);
  41. _etext = .; /* define a global symbols at end of code */
  42. } >ROM
  43. /* Constant data into "ROM" Rom type memory */
  44. .rodata :
  45. {
  46. . = ALIGN(8);
  47. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  48. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  49. . = ALIGN(8);
  50. } >ROM
  51. .ARM.extab : {
  52. . = ALIGN(8);
  53. *(.ARM.extab* .gnu.linkonce.armextab.*)
  54. . = ALIGN(8);
  55. } >ROM
  56. .ARM : {
  57. . = ALIGN(8);
  58. __exidx_start = .;
  59. *(.ARM.exidx*)
  60. __exidx_end = .;
  61. . = ALIGN(8);
  62. } >ROM
  63. .preinit_array :
  64. {
  65. . = ALIGN(8);
  66. PROVIDE_HIDDEN (__preinit_array_start = .);
  67. KEEP (*(.preinit_array*))
  68. PROVIDE_HIDDEN (__preinit_array_end = .);
  69. . = ALIGN(8);
  70. } >ROM
  71. .init_array :
  72. {
  73. . = ALIGN(8);
  74. PROVIDE_HIDDEN (__init_array_start = .);
  75. KEEP (*(SORT(.init_array.*)))
  76. KEEP (*(.init_array*))
  77. PROVIDE_HIDDEN (__init_array_end = .);
  78. . = ALIGN(8);
  79. } >ROM
  80. .fini_array :
  81. {
  82. . = ALIGN(8);
  83. PROVIDE_HIDDEN (__fini_array_start = .);
  84. KEEP (*(SORT(.fini_array.*)))
  85. KEEP (*(.fini_array*))
  86. PROVIDE_HIDDEN (__fini_array_end = .);
  87. . = ALIGN(8);
  88. } >ROM
  89. /* Used by the startup to initialize data */
  90. _sidata = LOADADDR(.data);
  91. /* Initialized data sections into "SRAM1" Ram type memory */
  92. .data :
  93. {
  94. . = ALIGN(8);
  95. _sdata = .; /* create a global symbol at data start */
  96. *(.data) /* .data sections */
  97. *(.data*) /* .data* sections */
  98. . = ALIGN(8);
  99. _edata = .; /* define a global symbol at data end */
  100. } >RAM1 AT> ROM
  101. /* Uninitialized data section into "SRAM1" Ram type memory */
  102. . = ALIGN(8);
  103. .bss :
  104. {
  105. /* This is used by the startup in order to initialize the .bss section */
  106. _sbss = .; /* define a global symbol at bss start */
  107. __bss_start__ = _sbss;
  108. *(.bss)
  109. *(.bss*)
  110. *(COMMON)
  111. . = ALIGN(8);
  112. _ebss = .; /* define a global symbol at bss end */
  113. __bss_end__ = _ebss;
  114. } >RAM1
  115. /* Data section into "SRAM1" Ram type memory: Non-backup SRAM1 dedicated to CM4 */
  116. . = ALIGN(8);
  117. RAM1_region :
  118. {
  119. _sRAM1_region = .; /* define a global symbol at section start */
  120. *(.RAM1_region)
  121. . = ALIGN(8);
  122. _eRAM1_region = .; /* define a global symbol at section end */
  123. } >RAM1
  124. /* Data section into "SRAM2" Ram type memory: Backup SRAM2 dedicated to CM4 */
  125. . = ALIGN(8);
  126. RAM2_region :
  127. {
  128. _sRAM2_region = .; /* define a global symbol at section start */
  129. *(.RAM2_region)
  130. . = ALIGN(8);
  131. _eRAM2_region = .; /* define a global symbol at section end */
  132. } >RAM2
  133. /* User_heap_stack section, used to check that there is enough "SRAM1" Ram type memory left */
  134. ._user_heap_stack :
  135. {
  136. . = ALIGN(8);
  137. PROVIDE ( end = . );
  138. PROVIDE ( _end = . );
  139. . = . + _Min_Heap_Size;
  140. . = . + _Min_Stack_Size;
  141. . = ALIGN(8);
  142. } >RAM1
  143. /* Remove information from the compiler libraries */
  144. /DISCARD/ :
  145. {
  146. libc.a ( * )
  147. libm.a ( * )
  148. libgcc.a ( * )
  149. }
  150. .ARM.attributes 0 : { *(.ARM.attributes) }
  151. }