link.lds 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. }
  13. /* Linker script to place sections and symbol values. Should be used together
  14. * with other linker script that defines memory regions FLASH and RAM.
  15. * It references following symbols, which must be defined in code:
  16. * Reset_Handler : Entry of reset handler
  17. *
  18. * It defines following symbols, which code can use without definition:
  19. * __exidx_start
  20. * __exidx_end
  21. * __copy_table_start__
  22. * __copy_table_end__
  23. * __zero_table_start__
  24. * __zero_table_end__
  25. * __etext
  26. * __data_start__
  27. * __preinit_array_start
  28. * __preinit_array_end
  29. * __init_array_start
  30. * __init_array_end
  31. * __fini_array_start
  32. * __fini_array_end
  33. * __data_end__
  34. * __bss_start__
  35. * __bss_end__
  36. * __end__
  37. * end
  38. * __HeapLimit
  39. * __StackLimit
  40. * __StackTop
  41. * __stack
  42. */
  43. ENTRY(Reset_Handler)
  44. SECTIONS
  45. {
  46. .text :
  47. {
  48. . = ALIGN(4);
  49. _stext = .;
  50. KEEP(*(.isr_vector))
  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 initial. */
  69. . = ALIGN(4);
  70. __rt_init_start = .;
  71. KEEP(*(SORT(.rti_fn*)))
  72. __rt_init_end = .;
  73. . = ALIGN(4);
  74. __rtatcmdtab_start = .;
  75. KEEP(*(RtAtCmdTab))
  76. __rtatcmdtab_end = .;
  77. . = ALIGN(4);
  78. . = ALIGN(4);
  79. KEEP(*(.init))
  80. KEEP(*(.fini))
  81. /* .ctors */
  82. *crtbegin.o(.ctors)
  83. *crtbegin?.o(.ctors)
  84. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  85. *(SORT(.ctors.*))
  86. *(.ctors)
  87. /* .dtors */
  88. *crtbegin.o(.dtors)
  89. *crtbegin?.o(.dtors)
  90. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  91. *(SORT(.dtors.*))
  92. *(.dtors)
  93. *(.rodata*)
  94. KEEP(*(.eh_frame*))
  95. } > FLASH
  96. .ARM.extab :
  97. {
  98. *(.ARM.extab* .gnu.linkonce.armextab.*)
  99. } > FLASH
  100. __exidx_start = .;
  101. .ARM.exidx :
  102. {
  103. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  104. } > FLASH
  105. __exidx_end = .;
  106. __etext = .;
  107. .data : AT (__etext)
  108. {
  109. . = ALIGN(4);
  110. __data_start__ = .;
  111. *(vtable)
  112. *(.data*)
  113. . = ALIGN(4);
  114. /* preinit data */
  115. PROVIDE_HIDDEN (__preinit_array_start = .);
  116. KEEP(*(.preinit_array))
  117. PROVIDE_HIDDEN (__preinit_array_end = .);
  118. . = ALIGN(4);
  119. /* init data */
  120. PROVIDE_HIDDEN (__init_array_start = .);
  121. KEEP(*(SORT(.init_array.*)))
  122. KEEP(*(.init_array))
  123. PROVIDE_HIDDEN (__init_array_end = .);
  124. . = ALIGN(4);
  125. /* finit data */
  126. PROVIDE_HIDDEN (__fini_array_start = .);
  127. KEEP(*(SORT(.fini_array.*)))
  128. KEEP(*(.fini_array))
  129. PROVIDE_HIDDEN (__fini_array_end = .);
  130. KEEP(*(.jcr*))
  131. . = ALIGN(4);
  132. /* All data end */
  133. __data_end__ = .;
  134. } > RAM
  135. .stack_dummy (COPY):
  136. {
  137. . = ALIGN(8);
  138. __stack_start__ = .;
  139. *(.stack*)
  140. __stack_end__ = .;
  141. } > RAM
  142. .bss __stack_end__ :
  143. {
  144. . = ALIGN(4);
  145. __bss_start__ = .;
  146. *(.bss*)
  147. *(COMMON)
  148. . = ALIGN(4);
  149. __bss_end__ = .;
  150. } > RAM
  151. ASSERT(__StackTop <= 0x20028000, "stack address error")
  152. }