link.lds 4.9 KB

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