You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

standalone.ld 6.0KB

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