link.lds 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. __rtatcmdtab_start = .;
  76. KEEP(*(RtAtCmdTab))
  77. __rtatcmdtab_end = .;
  78. . = ALIGN(4);
  79. . = ALIGN(4);
  80. KEEP(*(.init))
  81. KEEP(*(.fini))
  82. /* .ctors */
  83. *crtbegin.o(.ctors)
  84. *crtbegin?.o(.ctors)
  85. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  86. *(SORT(.ctors.*))
  87. *(.ctors)
  88. /* .dtors */
  89. *crtbegin.o(.dtors)
  90. *crtbegin?.o(.dtors)
  91. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  92. *(SORT(.dtors.*))
  93. *(.dtors)
  94. *(.rodata*)
  95. KEEP(*(.eh_frame*))
  96. } > FLASH
  97. .ARM.extab :
  98. {
  99. *(.ARM.extab* .gnu.linkonce.armextab.*)
  100. } > FLASH
  101. __exidx_start = .;
  102. .ARM.exidx :
  103. {
  104. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  105. } > FLASH
  106. __exidx_end = .;
  107. __etext = .;
  108. .data : AT (__etext)
  109. {
  110. . = ALIGN(4);
  111. __data_start__ = .;
  112. *(vtable)
  113. *(.data*)
  114. . = ALIGN(4);
  115. /* preinit data */
  116. PROVIDE_HIDDEN (__preinit_array_start = .);
  117. KEEP(*(.preinit_array))
  118. PROVIDE_HIDDEN (__preinit_array_end = .);
  119. . = ALIGN(4);
  120. /* init data */
  121. PROVIDE_HIDDEN (__init_array_start = .);
  122. KEEP(*(SORT(.init_array.*)))
  123. KEEP(*(.init_array))
  124. PROVIDE_HIDDEN (__init_array_end = .);
  125. . = ALIGN(4);
  126. /* finit data */
  127. PROVIDE_HIDDEN (__fini_array_start = .);
  128. KEEP(*(SORT(.fini_array.*)))
  129. KEEP(*(.fini_array))
  130. PROVIDE_HIDDEN (__fini_array_end = .);
  131. KEEP(*(.jcr*))
  132. . = ALIGN(4);
  133. /* All data end */
  134. __data_end__ = .;
  135. } > RAM
  136. .stack_dummy (COPY):
  137. {
  138. . = ALIGN(8);
  139. __stack_start__ = .;
  140. *(.stack*)
  141. __stack_end__ = .;
  142. } > RAM
  143. ._bss :
  144. {
  145. . = ALIGN(8);
  146. __bss2_start__ = .;
  147. __bss2_end__ = .;
  148. } > RAM2
  149. .bss __stack_end__ :
  150. {
  151. . = ALIGN(4);
  152. __bss_start__ = .;
  153. *(.bss*)
  154. *(COMMON)
  155. . = ALIGN(4);
  156. __bss_end__ = .;
  157. } > RAM
  158. ASSERT(__StackTop <= 0x20028000, "stack address error")
  159. }