link.lds 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * linker script for STM32F101RE with GNU ld
  3. */
  4. /* Program Entry, set to mark it as "used" and avoid gc */
  5. MEMORY
  6. {
  7. ROM (rx) : ORIGIN =0x8032000,LENGTH =312k
  8. RAM (rw) : ORIGIN =0x20000000,LENGTH =128k
  9. }
  10. ENTRY(Reset_Handler)
  11. /* 系统栈(MSP):所有中断、以及"栈溢出/硬件异常"诊断打印(rt_kprintf + list_thread)
  12. * 都在该栈上运行。原值 0x200(512B) 过小:诊断输出会溢出并向下覆盖 .data,
  13. * 且自身触发 HardFault 导致故障现场丢失。这里放大到 2KB。 */
  14. _system_stack_size = 0x800;
  15. SECTIONS
  16. {
  17. .text :
  18. {
  19. . = ALIGN(4);
  20. _stext = .;
  21. KEEP(*(.isr_vector)) /* Startup code */
  22. . = ALIGN(4);
  23. *(.text) /* remaining code */
  24. *(.text.*) /* remaining code */
  25. *(.rodata) /* read-only data (constants) */
  26. *(.rodata*)
  27. *(.glue_7)
  28. *(.glue_7t)
  29. *(.gnu.linkonce.t*)
  30. /* section information for finsh shell */
  31. . = ALIGN(4);
  32. __fsymtab_start = .;
  33. KEEP(*(FSymTab))
  34. __fsymtab_end = .;
  35. . = ALIGN(4);
  36. __vsymtab_start = .;
  37. KEEP(*(VSymTab))
  38. __vsymtab_end = .;
  39. /* section information for utest */
  40. . = ALIGN(4);
  41. __rt_utest_tc_tab_start = .;
  42. KEEP(*(UtestTcTab))
  43. __rt_utest_tc_tab_end = .;
  44. /* section information for at server */
  45. . = ALIGN(4);
  46. __rtatcmdtab_start = .;
  47. KEEP(*(RtAtCmdTab))
  48. __rtatcmdtab_end = .;
  49. . = ALIGN(4);
  50. /* section information for initial. */
  51. . = ALIGN(4);
  52. __rt_init_start = .;
  53. KEEP(*(SORT(.rti_fn*)))
  54. __rt_init_end = .;
  55. . = ALIGN(4);
  56. PROVIDE(__ctors_start__ = .);
  57. KEEP (*(SORT(.init_array.*)))
  58. KEEP (*(.init_array))
  59. PROVIDE(__ctors_end__ = .);
  60. . = ALIGN(4);
  61. _etext = .;
  62. } > ROM = 0
  63. /* .ARM.exidx is sorted, so has to go in its own output section. */
  64. __exidx_start = .;
  65. .ARM.exidx :
  66. {
  67. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  68. /* This is used by the startup in order to initialize the .data secion */
  69. _sidata = .;
  70. } > ROM
  71. __exidx_end = .;
  72. /* .data section which is used for initialized data */
  73. .data : AT (_sidata)
  74. {
  75. . = ALIGN(4);
  76. /* This is used by the startup in order to initialize the .data secion */
  77. _sdata = . ;
  78. *(.data)
  79. *(.data.*)
  80. *(.gnu.linkonce.d*)
  81. PROVIDE(__dtors_start__ = .);
  82. KEEP(*(SORT(.dtors.*)))
  83. KEEP(*(.dtors))
  84. PROVIDE(__dtors_end__ = .);
  85. . = ALIGN(4);
  86. /* This is used by the startup in order to initialize the .data secion */
  87. _edata = . ;
  88. } >RAM
  89. .stack :
  90. {
  91. . = ALIGN(4);
  92. _sstack = .;
  93. . = . + _system_stack_size;
  94. . = ALIGN(4);
  95. _estack = .;
  96. } >RAM
  97. __bss_start = .;
  98. .bss :
  99. {
  100. . = ALIGN(4);
  101. /* This is used by the startup in order to initialize the .bss secion */
  102. _sbss = .;
  103. *(.bss)
  104. *(.bss.*)
  105. *(COMMON)
  106. . = ALIGN(4);
  107. /* This is used by the startup in order to initialize the .bss secion */
  108. _ebss = . ;
  109. *(.bss.init)
  110. } > RAM
  111. __bss_end = .;
  112. _end = .;
  113. /* Stabs debugging sections. */
  114. .stab 0 : { *(.stab) }
  115. .stabstr 0 : { *(.stabstr) }
  116. .stab.excl 0 : { *(.stab.excl) }
  117. .stab.exclstr 0 : { *(.stab.exclstr) }
  118. .stab.index 0 : { *(.stab.index) }
  119. .stab.indexstr 0 : { *(.stab.indexstr) }
  120. .comment 0 : { *(.comment) }
  121. /* DWARF debug sections.
  122. * Symbols in the DWARF debugging sections are relative to the beginning
  123. * of the section so we begin them at 0. */
  124. /* DWARF 1 */
  125. .debug 0 : { *(.debug) }
  126. .line 0 : { *(.line) }
  127. /* GNU DWARF 1 extensions */
  128. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  129. .debug_sfnames 0 : { *(.debug_sfnames) }
  130. /* DWARF 1.1 and DWARF 2 */
  131. .debug_aranges 0 : { *(.debug_aranges) }
  132. .debug_pubnames 0 : { *(.debug_pubnames) }
  133. /* DWARF 2 */
  134. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  135. .debug_abbrev 0 : { *(.debug_abbrev) }
  136. .debug_line 0 : { *(.debug_line) }
  137. .debug_frame 0 : { *(.debug_frame) }
  138. .debug_str 0 : { *(.debug_str) }
  139. .debug_loc 0 : { *(.debug_loc) }
  140. .debug_macinfo 0 : { *(.debug_macinfo) }
  141. /* SGI/MIPS DWARF 2 extensions */
  142. .debug_weaknames 0 : { *(.debug_weaknames) }
  143. .debug_funcnames 0 : { *(.debug_funcnames) }
  144. .debug_typenames 0 : { *(.debug_typenames) }
  145. .debug_varnames 0 : { *(.debug_varnames) }
  146. }