link.lds 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * linker script for STM32F4xx with GNU ld
  3. * bernard.xiong 2009-10-14
  4. */
  5. /* Program Entry, set to mark it as "used" and avoid gc */
  6. MEMORY
  7. {
  8. ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
  9. DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
  10. FLASH (rx) : ORIGIN = 0x90000000, LENGTH = 1M
  11. RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K
  12. RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K
  13. RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K
  14. }
  15. ENTRY(Reset_Handler)
  16. _system_stack_size = 0x400;
  17. SECTIONS
  18. {
  19. .ram_d1(NOLOAD) : {
  20. . = ALIGN(4);
  21. *(.ram_d1)
  22. *(.ram_d1.*)
  23. . = ALIGN(4);
  24. } >RAM_D1
  25. .ram_d2(NOLOAD) : {
  26. . = ALIGN(4);
  27. *(.ram_d2)
  28. *(.ram_d2.*)
  29. . = ALIGN(4);
  30. } >RAM_D2
  31. .ram_d3(NOLOAD) : {
  32. . = ALIGN(4);
  33. *(.ram_d3)
  34. *(.ram_d3.*)
  35. . = ALIGN(4);
  36. } >RAM_D3
  37. _ramfunc_start_lma = LOADADDR(.ramfunc);
  38. .ramfunc : {
  39. . = ALIGN(4);
  40. _ramfunc_start_vma = .;
  41. *(.RamFunc) /* .RamFunc sections */
  42. *(.RamFunc*) /* .RamFunc* sections */
  43. . = ALIGN(4);
  44. _ramfunc_end = .; /* define a global symbol at data end */
  45. } >ITCMRAM AT>FLASH
  46. .text :
  47. {
  48. . = ALIGN(4);
  49. _stext = .;
  50. KEEP(*(.isr_vector)) /* Startup code */
  51. . = ALIGN(4);
  52. *(.text) /* remaining code */
  53. *(.text.*) /* remaining code */
  54. *(.rodata) /* read-only data (constants) */
  55. *(.rodata*)
  56. *(.glue_7)
  57. *(.glue_7t)
  58. *(.gnu.linkonce.t*)
  59. /* section information for finsh shell */
  60. . = ALIGN(4);
  61. __fsymtab_start = .;
  62. KEEP(*(FSymTab))
  63. __fsymtab_end = .;
  64. . = ALIGN(4);
  65. __vsymtab_start = .;
  66. KEEP(*(VSymTab))
  67. __vsymtab_end = .;
  68. /* section information for utest */
  69. . = ALIGN(4);
  70. __rt_utest_tc_tab_start = .;
  71. KEEP(*(UtestTcTab))
  72. __rt_utest_tc_tab_end = .;
  73. /* section information for at server */
  74. . = ALIGN(4);
  75. __rtatcmdtab_start = .;
  76. KEEP(*(RtAtCmdTab))
  77. __rtatcmdtab_end = .;
  78. . = ALIGN(4);
  79. /* section information for modules */
  80. . = ALIGN(4);
  81. __rtmsymtab_start = .;
  82. KEEP(*(RTMSymTab))
  83. __rtmsymtab_end = .;
  84. /* section information for initial. */
  85. . = ALIGN(4);
  86. __rt_init_start = .;
  87. KEEP(*(SORT(.rti_fn*)))
  88. __rt_init_end = .;
  89. . = ALIGN(4);
  90. PROVIDE(__ctors_start__ = .);
  91. KEEP (*(SORT(.init_array.*)))
  92. KEEP (*(.init_array))
  93. PROVIDE(__ctors_end__ = .);
  94. PROVIDE(__dtors_start__ = .);
  95. KEEP (*(SORT(.fini_array.*)))
  96. KEEP (*(.fini_array))
  97. KEEP(*(SORT(.dtors.*)))
  98. KEEP(*(.dtors))
  99. PROVIDE(__dtors_end__ = .);
  100. . = ALIGN(4);
  101. _etext = .;
  102. } >FLASH
  103. /* .ARM.exidx is sorted, so has to go in its own output section. */
  104. .ARM.exidx :
  105. {
  106. . = ALIGN(4);
  107. __exidx_start = .;
  108. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  109. *(.ARM.extab*)
  110. . = ALIGN(4);
  111. __exidx_end = .;
  112. } >FLASH
  113. /* .data section which is used for initialized data */
  114. _sidata = LOADADDR(.data);
  115. _data_start_lma = LOADADDR(.data);
  116. .data :
  117. {
  118. . = ALIGN(4);
  119. /* This is used by the startup in order to initialize the .data secion */
  120. _sdata = . ;
  121. _data_start_vma = .;
  122. *(.data)
  123. *(.data.*)
  124. *(.gnu.linkonce.d*)
  125. . = ALIGN(4);
  126. /* This is used by the startup in order to initialize the .data secion */
  127. _edata = . ;
  128. _data_end = .;
  129. } >DTCMRAM AT>FLASH
  130. __bss_start = .;
  131. .bss (NOLOAD):
  132. {
  133. . = ALIGN(4);
  134. /* This is used by the startup in order to initialize the .bss secion */
  135. _sbss = .;
  136. *(.bss)
  137. *(.bss.*)
  138. *(COMMON)
  139. . = ALIGN(4);
  140. /* This is used by the startup in order to initialize the .bss secion */
  141. _ebss = . ;
  142. *(.bss.init)
  143. } > DTCMRAM
  144. __bss_end = .;
  145. _heap_start = .;
  146. _end = .;
  147. _heap_end = ORIGIN(DTCMRAM) + LENGTH(DTCMRAM) - _system_stack_size;
  148. _sstack = _heap_end;
  149. _estack = _heap_end + _system_stack_size;
  150. /* Stabs debugging sections. */
  151. .stab 0 : { *(.stab) }
  152. .stabstr 0 : { *(.stabstr) }
  153. .stab.excl 0 : { *(.stab.excl) }
  154. .stab.exclstr 0 : { *(.stab.exclstr) }
  155. .stab.index 0 : { *(.stab.index) }
  156. .stab.indexstr 0 : { *(.stab.indexstr) }
  157. .comment 0 : { *(.comment) }
  158. /* DWARF debug sections.
  159. * Symbols in the DWARF debugging sections are relative to the beginning
  160. * of the section so we begin them at 0. */
  161. /* DWARF 1 */
  162. .debug 0 : { *(.debug) }
  163. .line 0 : { *(.line) }
  164. /* GNU DWARF 1 extensions */
  165. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  166. .debug_sfnames 0 : { *(.debug_sfnames) }
  167. /* DWARF 1.1 and DWARF 2 */
  168. .debug_aranges 0 : { *(.debug_aranges) }
  169. .debug_pubnames 0 : { *(.debug_pubnames) }
  170. /* DWARF 2 */
  171. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  172. .debug_abbrev 0 : { *(.debug_abbrev) }
  173. .debug_line 0 : { *(.debug_line) }
  174. .debug_frame 0 : { *(.debug_frame) }
  175. .debug_str 0 : { *(.debug_str) }
  176. .debug_loc 0 : { *(.debug_loc) }
  177. .debug_macinfo 0 : { *(.debug_macinfo) }
  178. /* SGI/MIPS DWARF 2 extensions */
  179. .debug_weaknames 0 : { *(.debug_weaknames) }
  180. .debug_funcnames 0 : { *(.debug_funcnames) }
  181. .debug_typenames 0 : { *(.debug_typenames) }
  182. .debug_varnames 0 : { *(.debug_varnames) }
  183. }