您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

combined.ld 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /* Based on GCC ARM embedded samples.
  2. Defines the following symbols for use by code:
  3. __exidx_start
  4. __exidx_end
  5. __etext
  6. __data_start__
  7. __preinit_array_start
  8. __preinit_array_end
  9. __init_array_start
  10. __init_array_end
  11. __fini_array_start
  12. __fini_array_end
  13. __data_end__
  14. __bss_start__
  15. __bss_end__
  16. __end__
  17. end
  18. __HeapLimit
  19. __StackLimit
  20. __StackTop
  21. __stack (== StackTop)
  22. */
  23. MEMORY
  24. {
  25. FLASH_BL(rx) : ORIGIN = 0x10000000, LENGTH = 360k
  26. FLASH_IMGHDR(rx) : ORIGIN = 0x10000000 + 360k, LENGTH = 4k
  27. FLASH_APP(rx) : ORIGIN = 0x10000000 + 364k, LENGTH = 2048k - 364k
  28. RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k
  29. SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
  30. SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
  31. }
  32. ENTRY(_entry_point)
  33. SECTIONS
  34. {
  35. .flash_begin : {
  36. __flash_binary_start = .;
  37. } > FLASH_APP
  38. /* Insert boot3, which is the combined boot2 + boot3 */
  39. .boot3 : {
  40. KEEP (*(.boot3))
  41. } > FLASH_BL
  42. /*
  43. * Name a section for the image header.
  44. * The contents will get replaced post-build
  45. */
  46. .app_hdr : {
  47. LONG(0xdeaddead)
  48. LONG(0)
  49. LONG(0xdeaddead)
  50. } > FLASH_IMGHDR
  51. .text : {
  52. __logical_binary_start = .;
  53. KEEP (*(.vectors))
  54. KEEP (*(.binary_info_header))
  55. __binary_info_header_end = .;
  56. KEEP (*(.reset))
  57. /* TODO revisit this now memset/memcpy/float in ROM */
  58. /* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from
  59. * FLASH ... we will include any thing excluded here in .data below by default */
  60. *(.init)
  61. *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .text*)
  62. *(.fini)
  63. /* Pull all c'tors into .text */
  64. *crtbegin.o(.ctors)
  65. *crtbegin?.o(.ctors)
  66. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  67. *(SORT(.ctors.*))
  68. *(.ctors)
  69. /* Followed by destructors */
  70. *crtbegin.o(.dtors)
  71. *crtbegin?.o(.dtors)
  72. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  73. *(SORT(.dtors.*))
  74. *(.dtors)
  75. *(.eh_frame*)
  76. . = ALIGN(4);
  77. } > FLASH_APP
  78. .rodata : {
  79. *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*)
  80. . = ALIGN(4);
  81. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
  82. . = ALIGN(4);
  83. } > FLASH_APP
  84. .ARM.extab :
  85. {
  86. *(.ARM.extab* .gnu.linkonce.armextab.*)
  87. } > FLASH_APP
  88. __exidx_start = .;
  89. .ARM.exidx :
  90. {
  91. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  92. } > FLASH_APP
  93. __exidx_end = .;
  94. /* Machine inspectable binary information */
  95. . = ALIGN(4);
  96. __binary_info_start = .;
  97. .binary_info :
  98. {
  99. KEEP(*(.binary_info.keep.*))
  100. *(.binary_info.*)
  101. } > FLASH_APP
  102. __binary_info_end = .;
  103. . = ALIGN(4);
  104. /* End of .text-like segments */
  105. __etext = .;
  106. .ram_vector_table (COPY): {
  107. *(.ram_vector_table)
  108. } > RAM
  109. .data : {
  110. __data_start__ = .;
  111. *(vtable)
  112. *(.time_critical*)
  113. /* remaining .text and .rodata; i.e. stuff we exclude above because we want it in RAM */
  114. *(.text*)
  115. . = ALIGN(4);
  116. *(.rodata*)
  117. . = ALIGN(4);
  118. *(.data*)
  119. . = ALIGN(4);
  120. *(.after_data.*)
  121. . = ALIGN(4);
  122. /* preinit data */
  123. PROVIDE_HIDDEN (__mutex_array_start = .);
  124. KEEP(*(SORT(.mutex_array.*)))
  125. KEEP(*(.mutex_array))
  126. PROVIDE_HIDDEN (__mutex_array_end = .);
  127. . = ALIGN(4);
  128. /* preinit data */
  129. PROVIDE_HIDDEN (__preinit_array_start = .);
  130. KEEP(*(SORT(.preinit_array.*)))
  131. KEEP(*(.preinit_array))
  132. PROVIDE_HIDDEN (__preinit_array_end = .);
  133. . = ALIGN(4);
  134. /* init data */
  135. PROVIDE_HIDDEN (__init_array_start = .);
  136. KEEP(*(SORT(.init_array.*)))
  137. KEEP(*(.init_array))
  138. PROVIDE_HIDDEN (__init_array_end = .);
  139. . = ALIGN(4);
  140. /* finit data */
  141. PROVIDE_HIDDEN (__fini_array_start = .);
  142. *(SORT(.fini_array.*))
  143. *(.fini_array)
  144. PROVIDE_HIDDEN (__fini_array_end = .);
  145. *(.jcr)
  146. . = ALIGN(4);
  147. /* All data end */
  148. __data_end__ = .;
  149. } > RAM AT> FLASH_APP
  150. .uninitialized_data (COPY): {
  151. . = ALIGN(4);
  152. *(.uninitialized_data*)
  153. } > RAM
  154. /* Start and end symbols must be word-aligned */
  155. .scratch_x : {
  156. __scratch_x_start__ = .;
  157. *(.scratch_x.*)
  158. . = ALIGN(4);
  159. __scratch_x_end__ = .;
  160. } > SCRATCH_X AT > FLASH_APP
  161. __scratch_x_source__ = LOADADDR(.scratch_x);
  162. .scratch_y : {
  163. __scratch_y_start__ = .;
  164. *(.scratch_y.*)
  165. . = ALIGN(4);
  166. __scratch_y_end__ = .;
  167. } > SCRATCH_Y AT > FLASH_APP
  168. __scratch_y_source__ = LOADADDR(.scratch_y);
  169. .bss : {
  170. . = ALIGN(4);
  171. __bss_start__ = .;
  172. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
  173. *(COMMON)
  174. . = ALIGN(4);
  175. __bss_end__ = .;
  176. } > RAM
  177. .heap (COPY):
  178. {
  179. __end__ = .;
  180. end = __end__;
  181. *(.heap*)
  182. __HeapLimit = .;
  183. } > RAM
  184. /* .stack*_dummy section doesn't contains any symbols. It is only
  185. * used for linker to calculate size of stack sections, and assign
  186. * values to stack symbols later
  187. *
  188. * stack1 section may be empty/missing if platform_launch_core1 is not used */
  189. /* by default we put core 0 stack at the end of scratch Y, so that if core 1
  190. * stack is not used then all of SCRATCH_X is free.
  191. */
  192. .stack1_dummy (COPY):
  193. {
  194. *(.stack1*)
  195. } > SCRATCH_X
  196. .stack_dummy (COPY):
  197. {
  198. *(.stack*)
  199. } > SCRATCH_Y
  200. .flash_end : {
  201. __flash_binary_end = .;
  202. } > FLASH_APP
  203. /* stack limit is poorly named, but historically is maximum heap ptr */
  204. __StackLimit = ORIGIN(RAM) + LENGTH(RAM);
  205. __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
  206. __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y);
  207. __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
  208. __StackBottom = __StackTop - SIZEOF(.stack_dummy);
  209. PROVIDE(__stack = __StackTop);
  210. /* Check if data + heap + stack exceeds RAM limit */
  211. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
  212. ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary")
  213. /* todo assert on extra code */
  214. }