link.lds 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. ENTRY( _start )
  2. __stack_size = 2048;
  3. PROVIDE( _stack_size = __stack_size );
  4. MEMORY
  5. {
  6. FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
  7. RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
  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. } >FLASH AT>FLASH
  57. .fini :
  58. {
  59. KEEP(*(SORT_NONE(.fini)))
  60. . = ALIGN(4);
  61. } >FLASH AT>FLASH
  62. PROVIDE( _etext = . );
  63. PROVIDE( _eitcm = . );
  64. .preinit_array :
  65. {
  66. PROVIDE_HIDDEN (__preinit_array_start = .);
  67. KEEP (*(.preinit_array))
  68. PROVIDE_HIDDEN (__preinit_array_end = .);
  69. } >FLASH AT>FLASH
  70. .init_array :
  71. {
  72. PROVIDE_HIDDEN (__init_array_start = .);
  73. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  74. KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  75. PROVIDE_HIDDEN (__init_array_end = .);
  76. } >FLASH AT>FLASH
  77. .fini_array :
  78. {
  79. PROVIDE_HIDDEN (__fini_array_start = .);
  80. KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  81. KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  82. PROVIDE_HIDDEN (__fini_array_end = .);
  83. } >FLASH AT>FLASH
  84. .ctors :
  85. {
  86. /* gcc uses crtbegin.o to find the start of
  87. the constructors, so we make sure it is
  88. first. Because this is a wildcard, it
  89. doesn't matter if the user does not
  90. actually link against crtbegin.o; the
  91. linker won't look for a file to match a
  92. wildcard. The wildcard also means that it
  93. doesn't matter which directory crtbegin.o
  94. is in. */
  95. KEEP (*crtbegin.o(.ctors))
  96. KEEP (*crtbegin?.o(.ctors))
  97. /* We don't want to include the .ctor section from
  98. the crtend.o file until after the sorted ctors.
  99. The .ctor section from the crtend file contains the
  100. end of ctors marker and it must be last */
  101. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
  102. KEEP (*(SORT(.ctors.*)))
  103. KEEP (*(.ctors))
  104. } >FLASH AT>FLASH
  105. .dtors :
  106. {
  107. KEEP (*crtbegin.o(.dtors))
  108. KEEP (*crtbegin?.o(.dtors))
  109. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
  110. KEEP (*(SORT(.dtors.*)))
  111. KEEP (*(.dtors))
  112. } >FLASH AT>FLASH
  113. .dalign :
  114. {
  115. . = ALIGN(4);
  116. PROVIDE(_data_vma = .);
  117. } >RAM AT>FLASH
  118. .dlalign :
  119. {
  120. . = ALIGN(4);
  121. PROVIDE(_data_lma = .);
  122. } >FLASH AT>FLASH
  123. .data :
  124. {
  125. *(.gnu.linkonce.r.*)
  126. *(.data .data.*)
  127. *(.gnu.linkonce.d.*)
  128. . = ALIGN(8);
  129. PROVIDE( __global_pointer$ = . + 0x800 );
  130. *(.sdata .sdata.*)
  131. *(.sdata2.*)
  132. *(.gnu.linkonce.s.*)
  133. . = ALIGN(8);
  134. *(.srodata.cst16)
  135. *(.srodata.cst8)
  136. *(.srodata.cst4)
  137. *(.srodata.cst2)
  138. *(.srodata .srodata.*)
  139. . = ALIGN(4);
  140. PROVIDE( _edata = .);
  141. } >RAM AT>FLASH
  142. .bss :
  143. {
  144. . = ALIGN(4);
  145. PROVIDE( _sbss = .);
  146. *(.sbss*)
  147. *(.gnu.linkonce.sb.*)
  148. *(.bss*)
  149. *(.gnu.linkonce.b.*)
  150. *(COMMON*)
  151. . = ALIGN(4);
  152. PROVIDE( _ebss = .);
  153. } >RAM AT>FLASH
  154. PROVIDE( _end = _ebss);
  155. PROVIDE( end = . );
  156. .stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
  157. {
  158. PROVIDE( _heap_end = . );
  159. . = ALIGN(4);
  160. PROVIDE(_susrstack = . );
  161. . = . + __stack_size;
  162. PROVIDE( _eusrstack = .);
  163. PROVIDE( __rt_rvstack = .);
  164. } >RAM
  165. }