選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

standalone.ld 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. INPUT (./fat_fs.o)
  24. /*
  25. * TODO hard-coded.
  26. * Should take into account PICO_FLASH_BANK_STORAGE_OFFSET
  27. * and DISK_BLOCK_SIZE and DISK_BLOCK_COUNT from config.h
  28. */
  29. __PERSISTENT_STORAGE_LEN = (3 * 4k);
  30. __FLASH_CACHE_LEN = (48 * 4k);
  31. __ADDITIONAL_LEN = (__PERSISTENT_STORAGE_LEN + __FLASH_CACHE_LEN);
  32. /* Skip 364kB at the start of flash, that's where the bootloader is */
  33. __BOOTLOADER_LEN = 360k;
  34. __IMG_HDR_LEN = 4k;
  35. __BOOTLOADER_IMG_LEN = (__BOOTLOADER_LEN + __IMG_HDR_LEN);
  36. MEMORY
  37. {
  38. FLASH(rx) : ORIGIN = 0x10000000 + __BOOTLOADER_IMG_LEN, LENGTH = 2048k - __ADDITIONAL_LEN - __BOOTLOADER_IMG_LEN
  39. FLASH_CACHE(r) : ORIGIN = 0x10000000 + __BOOTLOADER_IMG_LEN + (2048k - __ADDITIONAL_LEN - __BOOTLOADER_IMG_LEN) , LENGTH = __FLASH_CACHE_LEN
  40. RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k
  41. SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
  42. SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
  43. }
  44. ENTRY(_entry_point)
  45. SECTIONS
  46. {
  47. .flash_begin : {
  48. __flash_binary_start = .;
  49. } > FLASH
  50. /* boot2 would normally go here, but we don't want it */
  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
  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
  84. .ARM.extab :
  85. {
  86. *(.ARM.extab* .gnu.linkonce.armextab.*)
  87. } > FLASH
  88. __exidx_start = .;
  89. .ARM.exidx :
  90. {
  91. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  92. } > FLASH
  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
  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
  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
  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
  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. .fat_fs_bin : {
  201. KEEP(./fat_fs.o (.fat_fs_bin))
  202. } > FLASH_CACHE
  203. .flash_end : {
  204. __flash_binary_end = .;
  205. } > FLASH
  206. /* stack limit is poorly named, but historically is maximum heap ptr */
  207. __StackLimit = ORIGIN(RAM) + LENGTH(RAM);
  208. __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
  209. __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y);
  210. __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
  211. __StackBottom = __StackTop - SIZEOF(.stack_dummy);
  212. PROVIDE(__stack = __StackTop);
  213. /* Check if data + heap + stack exceeds RAM limit */
  214. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
  215. ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary")
  216. /* todo assert on extra code */
  217. }