link.lds 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. ENTRY( _start )
  2. __stack_size = 1536;
  3. PROVIDE( _stack_size = __stack_size );
  4. MEMORY
  5. {
  6. FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 96K
  7. RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
  8. RAMX (xrw) : ORIGIN = 0x20020000, LENGTH = 32K
  9. }
  10. SECTIONS
  11. {
  12. .init :
  13. {
  14. _sinit = .;
  15. . = ALIGN(4);
  16. KEEP(*(SORT_NONE(.init)))
  17. . = ALIGN(4);
  18. _einit = .;
  19. } >FLASH AT>FLASH
  20. .vector :
  21. {
  22. *(.vector);
  23. . = ALIGN(64);
  24. } >FLASH AT>FLASH
  25. .text :
  26. {
  27. . = ALIGN(4);
  28. *(.text)
  29. *(.text.*)
  30. *(.rodata)
  31. *(.rodata*)
  32. *(.glue_7)
  33. *(.glue_7t)
  34. *(.gnu.linkonce.t.*)
  35. /* section information for finsh shell */
  36. . = ALIGN(4);
  37. __fsymtab_start = .;
  38. KEEP(*(FSymTab))
  39. __fsymtab_end = .;
  40. . = ALIGN(4);
  41. __vsymtab_start = .;
  42. KEEP(*(VSymTab))
  43. __vsymtab_end = .;
  44. . = ALIGN(4);
  45. /* section information for initial. */
  46. . = ALIGN(4);
  47. __rt_init_start = .;
  48. KEEP(*(SORT(.rti_fn*)))
  49. __rt_init_end = .;
  50. . = ALIGN(4);
  51. /* section information for modules */
  52. . = ALIGN(4);
  53. __rtmsymtab_start = .;
  54. KEEP(*(RTMSymTab))
  55. __rtmsymtab_end = .;
  56. . = ALIGN(4);
  57. } >FLASH AT>FLASH
  58. .fini :
  59. {
  60. KEEP(*(SORT_NONE(.fini)))
  61. . = ALIGN(4);
  62. } >FLASH AT>FLASH
  63. PROVIDE( _etext = . );
  64. PROVIDE( _eitcm = . );
  65. .preinit_array :
  66. {
  67. PROVIDE_HIDDEN (__preinit_array_start = .);
  68. KEEP (*(.preinit_array))
  69. PROVIDE_HIDDEN (__preinit_array_end = .);
  70. } >FLASH AT>FLASH
  71. .init_array :
  72. {
  73. PROVIDE_HIDDEN (__init_array_start = .);
  74. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  75. KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  76. PROVIDE_HIDDEN (__init_array_end = .);
  77. } >FLASH AT>FLASH
  78. .fini_array :
  79. {
  80. PROVIDE_HIDDEN (__fini_array_start = .);
  81. KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  82. KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  83. PROVIDE_HIDDEN (__fini_array_end = .);
  84. } >FLASH AT>FLASH
  85. .ctors :
  86. {
  87. /* gcc uses crtbegin.o to find the start of
  88. the constructors, so we make sure it is
  89. first. Because this is a wildcard, it
  90. doesn't matter if the user does not
  91. actually link against crtbegin.o; the
  92. linker won't look for a file to match a
  93. wildcard. The wildcard also means that it
  94. doesn't matter which directory crtbegin.o
  95. is in. */
  96. KEEP (*crtbegin.o(.ctors))
  97. KEEP (*crtbegin?.o(.ctors))
  98. /* We don't want to include the .ctor section from
  99. the crtend.o file until after the sorted ctors.
  100. The .ctor section from the crtend file contains the
  101. end of ctors marker and it must be last */
  102. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
  103. KEEP (*(SORT(.ctors.*)))
  104. KEEP (*(.ctors))
  105. } >FLASH AT>FLASH
  106. .dtors :
  107. {
  108. KEEP (*crtbegin.o(.dtors))
  109. KEEP (*crtbegin?.o(.dtors))
  110. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
  111. KEEP (*(SORT(.dtors.*)))
  112. KEEP (*(.dtors))
  113. } >FLASH AT>FLASH
  114. .dalign :
  115. {
  116. . = ALIGN(4);
  117. PROVIDE(_data_vma = .);
  118. } >RAM AT>FLASH
  119. .dlalign :
  120. {
  121. . = ALIGN(4);
  122. PROVIDE(_data_lma = .);
  123. } >FLASH AT>FLASH
  124. .data :
  125. {
  126. *(.gnu.linkonce.r.*)
  127. *(.data .data.*)
  128. *(.gnu.linkonce.d.*)
  129. . = ALIGN(8);
  130. PROVIDE( __global_pointer$ = . + 0x800 );
  131. *(.sdata .sdata.*)
  132. *(.sdata2.*)
  133. *(.gnu.linkonce.s.*)
  134. . = ALIGN(8);
  135. *(.srodata.cst16)
  136. *(.srodata.cst8)
  137. *(.srodata.cst4)
  138. *(.srodata.cst2)
  139. *(.srodata .srodata.*)
  140. . = ALIGN(4);
  141. PROVIDE( _edata = .);
  142. } >RAM AT>FLASH
  143. .bss :
  144. {
  145. . = ALIGN(4);
  146. PROVIDE( _sbss = .);
  147. *(.sbss*)
  148. *(.gnu.linkonce.sb.*)
  149. *(.bss*)
  150. *(.gnu.linkonce.b.*)
  151. *(COMMON*)
  152. . = ALIGN(4);
  153. PROVIDE( _ebss = .);
  154. } >RAM AT>FLASH
  155. PROVIDE( _end = _ebss);
  156. PROVIDE( end = . );
  157. .dmadata :
  158. {
  159. PROVIDE( _dmadata_start = .);
  160. /* first 8 bytes are reserved for USB ep0 SETUP */
  161. . = . + 8;
  162. . = ALIGN(16);
  163. *(.dmadata*)
  164. *(.dmadata.*)
  165. . = ALIGN(16);
  166. PROVIDE( _dmadata_end = .);
  167. } >RAMX AT>FLASH /**/
  168. .stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
  169. {
  170. PROVIDE( _heap_end = . );
  171. . = ALIGN(4);
  172. PROVIDE(_susrstack = . );
  173. . = . + __stack_size;
  174. PROVIDE( _eusrstack = .);
  175. } >RAM
  176. }