link.lds 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /* Linker script to configure memory regions.
  2. * Need modifying for a specific board.
  3. * FLASH.ORIGIN: starting address of flash
  4. * FLASH.LENGTH: length of flash
  5. * RAM.ORIGIN: starting address of RAM bank 0
  6. * RAM.LENGTH: length of RAM bank 0
  7. */
  8. MEMORY
  9. {
  10. FLASH (rx) : ORIGIN = 0x8010100, LENGTH = 959K /* 960K-256B */
  11. RAM (rw) : ORIGIN = 0x20000000, LENGTH = 0x28000 /* 160K */
  12. RAM2 (rw) : ORIGIN = 0x20028000, LENGTH = 0x14000 /* 80K */
  13. }
  14. /* Linker script to place sections and symbol values. Should be used together
  15. * with other linker script that defines memory regions FLASH and RAM.
  16. * It references following symbols, which must be defined in code:
  17. * Reset_Handler : Entry of reset handler
  18. *
  19. * It defines following symbols, which code can use without definition:
  20. * __exidx_start
  21. * __exidx_end
  22. * __copy_table_start__
  23. * __copy_table_end__
  24. * __zero_table_start__
  25. * __zero_table_end__
  26. * __etext
  27. * __data_start__
  28. * __preinit_array_start
  29. * __preinit_array_end
  30. * __init_array_start
  31. * __init_array_end
  32. * __fini_array_start
  33. * __fini_array_end
  34. * __data_end__
  35. * __bss_start__
  36. * __bss_end__
  37. * __end__
  38. * end
  39. * __HeapLimit
  40. * __StackLimit
  41. * __StackTop
  42. * __stack
  43. */
  44. ENTRY(Reset_Handler)
  45. SECTIONS
  46. {
  47. .text :
  48. {
  49. . = ALIGN(4);
  50. _stext = .;
  51. KEEP(*(.isr_vector))
  52. . = ALIGN(4);
  53. *(.text) /* remaining code */
  54. *(.text.*) /* remaining code */
  55. *(.rodata) /* read-only data (constants) */
  56. *(.rodata*)
  57. *(.glue_7)
  58. *(.glue_7t)
  59. *(.gnu.linkonce.t*)
  60. /* section information for finsh shell */
  61. . = ALIGN(4);
  62. __fsymtab_start = .;
  63. KEEP(*(FSymTab))
  64. __fsymtab_end = .;
  65. . = ALIGN(4);
  66. __vsymtab_start = .;
  67. KEEP(*(VSymTab))
  68. __vsymtab_end = .;
  69. /* section information for initial. */
  70. . = ALIGN(4);
  71. __rt_init_start = .;
  72. KEEP(*(SORT(.rti_fn*)))
  73. __rt_init_end = .;
  74. . = ALIGN(4);
  75. PROVIDE(__ctors_start__ = .);
  76. KEEP (*(SORT(.init_array.*)))
  77. KEEP (*(.init_array))
  78. PROVIDE(__ctors_end__ = .);
  79. . = ALIGN(4);
  80. __rtatcmdtab_start = .;
  81. KEEP(*(RtAtCmdTab))
  82. __rtatcmdtab_end = .;
  83. . = ALIGN(4);
  84. . = ALIGN(4);
  85. KEEP(*(.init))
  86. KEEP(*(.fini))
  87. /* .ctors */
  88. *crtbegin.o(.ctors)
  89. *crtbegin?.o(.ctors)
  90. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  91. *(SORT(.ctors.*))
  92. *(.ctors)
  93. /* .dtors */
  94. *crtbegin.o(.dtors)
  95. *crtbegin?.o(.dtors)
  96. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  97. *(SORT(.dtors.*))
  98. *(.dtors)
  99. *(.rodata*)
  100. KEEP(*(.eh_frame*))
  101. } > FLASH
  102. .ARM.extab :
  103. {
  104. *(.ARM.extab* .gnu.linkonce.armextab.*)
  105. } > FLASH
  106. __exidx_start = .;
  107. .ARM.exidx :
  108. {
  109. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  110. } > FLASH
  111. __exidx_end = .;
  112. __etext = .;
  113. .data : AT (__etext)
  114. {
  115. . = ALIGN(4);
  116. __data_start__ = .;
  117. *(vtable)
  118. *(.data*)
  119. . = ALIGN(4);
  120. /* preinit data */
  121. PROVIDE_HIDDEN (__preinit_array_start = .);
  122. KEEP(*(.preinit_array))
  123. PROVIDE_HIDDEN (__preinit_array_end = .);
  124. . = ALIGN(4);
  125. /* init data */
  126. PROVIDE_HIDDEN (__init_array_start = .);
  127. KEEP(*(SORT(.init_array.*)))
  128. KEEP(*(.init_array))
  129. PROVIDE_HIDDEN (__init_array_end = .);
  130. . = ALIGN(4);
  131. /* finit data */
  132. PROVIDE_HIDDEN (__fini_array_start = .);
  133. KEEP(*(SORT(.fini_array.*)))
  134. KEEP(*(.fini_array))
  135. PROVIDE_HIDDEN (__fini_array_end = .);
  136. KEEP(*(.jcr*))
  137. . = ALIGN(4);
  138. /* All data end */
  139. __data_end__ = .;
  140. } > RAM
  141. .stack_dummy (COPY):
  142. {
  143. . = ALIGN(8);
  144. __stack_start__ = .;
  145. *(.stack*)
  146. __stack_end__ = .;
  147. } > RAM
  148. ._bss :
  149. {
  150. . = ALIGN(8);
  151. __bss2_start__ = .;
  152. __bss2_end__ = .;
  153. } > RAM2
  154. .bss __stack_end__ :
  155. {
  156. . = ALIGN(4);
  157. __bss_start__ = .;
  158. *(.bss*)
  159. *(COMMON)
  160. . = ALIGN(4);
  161. __bss_end__ = .;
  162. } > RAM
  163. ASSERT(__StackTop <= 0x20028000, "stack address error")
  164. }