link.ld 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. ** ###################################################################
  3. ** Processors: MM32F3277G
  4. **
  5. ** Compiler: GNU C Compiler
  6. ** Build: b211202
  7. **
  8. ** Abstract:
  9. ** Linker file for the GNU C Compiler
  10. **
  11. ** Copyright 2021 MindMotion Microelectronics Co., Ltd.
  12. **
  13. ** SPDX-License-Identifier: BSD-3-Clause
  14. **
  15. **
  16. ** ###################################################################
  17. */
  18. /* Entry Point */
  19. ENTRY(Reset_Handler)
  20. HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
  21. STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
  22. /* Specify the memory areas */
  23. MEMORY
  24. {
  25. m_interrupts (RX) : ORIGIN = 0x08000000, LENGTH = 0x00000400
  26. m_text (RX) : ORIGIN = 0x08000400, LENGTH = 0x0007FC00 /* 512KB. */
  27. m_data (RW) : ORIGIN = 0x20000000, LENGTH = 0x00020000 /* 128KB. */
  28. }
  29. /* Define output sections */
  30. SECTIONS
  31. {
  32. /* The startup code goes first into internal flash */
  33. .interrupts :
  34. {
  35. . = ALIGN(4);
  36. KEEP(*(.isr_vector)) /* Startup code */
  37. . = ALIGN(4);
  38. } > m_interrupts
  39. /* The program code and other data goes into internal flash */
  40. .text :
  41. {
  42. . = ALIGN(4);
  43. *(.text) /* .text sections (code) */
  44. *(.text*) /* .text* sections (code) */
  45. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  46. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  47. *(.glue_7) /* glue arm to thumb code */
  48. *(.glue_7t) /* glue thumb to arm code */
  49. *(.eh_frame)
  50. KEEP (*(.init))
  51. KEEP (*(.fini))
  52. . = ALIGN(4);
  53. } > m_text
  54. .ARM.extab :
  55. {
  56. *(.ARM.extab* .gnu.linkonce.armextab.*)
  57. } > m_text
  58. .ARM :
  59. {
  60. __exidx_start = .;
  61. *(.ARM.exidx*)
  62. __exidx_end = .;
  63. } > m_text
  64. .ctors :
  65. {
  66. __CTOR_LIST__ = .;
  67. /* gcc uses crtbegin.o to find the start of
  68. the constructors, so we make sure it is
  69. first. Because this is a wildcard, it
  70. doesn't matter if the user does not
  71. actually link against crtbegin.o; the
  72. linker won't look for a file to match a
  73. wildcard. The wildcard also means that it
  74. doesn't matter which directory crtbegin.o
  75. is in. */
  76. KEEP (*crtbegin.o(.ctors))
  77. KEEP (*crtbegin?.o(.ctors))
  78. /* We don't want to include the .ctor section from
  79. from the crtend.o file until after the sorted ctors.
  80. The .ctor section from the crtend file contains the
  81. end of ctors marker and it must be last */
  82. KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
  83. KEEP (*(SORT(.ctors.*)))
  84. KEEP (*(.ctors))
  85. __CTOR_END__ = .;
  86. } > m_text
  87. .dtors :
  88. {
  89. __DTOR_LIST__ = .;
  90. KEEP (*crtbegin.o(.dtors))
  91. KEEP (*crtbegin?.o(.dtors))
  92. KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
  93. KEEP (*(SORT(.dtors.*)))
  94. KEEP (*(.dtors))
  95. __DTOR_END__ = .;
  96. } > m_text
  97. .preinit_array :
  98. {
  99. PROVIDE_HIDDEN (__preinit_array_start = .);
  100. KEEP (*(.preinit_array*))
  101. PROVIDE_HIDDEN (__preinit_array_end = .);
  102. } > m_text
  103. .init_array :
  104. {
  105. PROVIDE_HIDDEN (__init_array_start = .);
  106. KEEP (*(SORT(.init_array.*)))
  107. KEEP (*(.init_array*))
  108. PROVIDE_HIDDEN (__init_array_end = .);
  109. } > m_text
  110. .fini_array :
  111. {
  112. PROVIDE_HIDDEN (__fini_array_start = .);
  113. KEEP (*(SORT(.fini_array.*)))
  114. KEEP (*(.fini_array*))
  115. PROVIDE_HIDDEN (__fini_array_end = .);
  116. } > m_text
  117. __etext = .; /* define a global symbol at end of code */
  118. __DATA_ROM = .; /* Symbol is used by startup for data initialization */
  119. .data : AT(__DATA_ROM)
  120. {
  121. . = ALIGN(4);
  122. __DATA_RAM = .;
  123. __data_start__ = .; /* create a global symbol at data start */
  124. *(.data) /* .data sections */
  125. *(.data*) /* .data* sections */
  126. KEEP(*(.jcr*))
  127. . = ALIGN(4);
  128. __data_end__ = .; /* define a global symbol at data end */
  129. } > m_data
  130. __NDATA_ROM = __DATA_ROM + (__data_end__ - __data_start__);
  131. .ncache.init : AT(__NDATA_ROM)
  132. {
  133. __noncachedata_start__ = .; /* create a global symbol at ncache data start */
  134. *(NonCacheable.init)
  135. . = ALIGN(4);
  136. __noncachedata_init_end__ = .; /* create a global symbol at initialized ncache data end */
  137. } > m_data
  138. . = __noncachedata_init_end__;
  139. .ncache :
  140. {
  141. *(NonCacheable)
  142. . = ALIGN(4);
  143. __noncachedata_end__ = .; /* define a global symbol at ncache data end */
  144. } > m_data
  145. __DATA_END = __NDATA_ROM + (__noncachedata_init_end__ - __noncachedata_start__);
  146. text_end = ORIGIN(m_text) + LENGTH(m_text);
  147. ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
  148. /* Uninitialized data section */
  149. .bss :
  150. {
  151. /* This is used by the startup in order to initialize the .bss section */
  152. . = ALIGN(4);
  153. __START_BSS = .;
  154. __bss_start__ = .;
  155. *(.bss)
  156. *(.bss*)
  157. *(COMMON)
  158. . = ALIGN(4);
  159. __bss_end__ = .;
  160. __END_BSS = .;
  161. } > m_data
  162. .heap :
  163. {
  164. . = ALIGN(8);
  165. __end__ = .;
  166. PROVIDE(end = .);
  167. __HeapBase = .;
  168. . += HEAP_SIZE;
  169. __HeapLimit = .;
  170. __heap_limit = .; /* Add for _sbrk */
  171. } > m_data
  172. .stack :
  173. {
  174. . = ALIGN(8);
  175. . += STACK_SIZE;
  176. } > m_data
  177. /* Initializes stack on the end of block */
  178. __StackTop = ORIGIN(m_data) + LENGTH(m_data);
  179. __StackLimit = __StackTop - STACK_SIZE;
  180. PROVIDE(__stack = __StackTop);
  181. .ARM.attributes 0 : { *(.ARM.attributes) }
  182. ASSERT(__StackLimit >= __HeapLimit, "region m_data_2 overflowed with stack and heap")
  183. }