user_linker.ld 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. * SPDX-License-Identifier: BSD-3-Clause
  4. */
  5. ENTRY(_start)
  6. STACK_SIZE = _stack_size;
  7. HEAP_SIZE = _heap_size;
  8. MEMORY
  9. {
  10. XPI0 (rx) : ORIGIN = 0x80000000, LENGTH = _flash_size
  11. ILM (wx) : ORIGIN = 0x00000000, LENGTH = 256K
  12. DLM (w) : ORIGIN = 0x00080000, LENGTH = 256K
  13. AXI_SRAM (wx) : ORIGIN = 0x01080000, LENGTH = 768K /* AXI SRAM */
  14. SHARE_RAM (w) : ORIGIN = 0x0117C000, LENGTH = 16K
  15. AHB_SRAM (w) : ORIGIN = 0xF0300000, LENGTH = 32k
  16. APB_SRAM (w): ORIGIN = 0xF40F0000, LENGTH = 8k
  17. SDRAM (wx) : ORIGIN = 0x40000000, LENGTH = (_extram_size - 4M)
  18. NONCACHEABLE_RAM (wx) : ORIGIN = 0x40000000 + (_extram_size - 4M), LENGTH = 4M
  19. }
  20. __nor_cfg_option_load_addr__ = ORIGIN(XPI0) + 0x400;
  21. __boot_header_load_addr__ = ORIGIN(XPI0) + 0x1000;
  22. __app_load_addr__ = ORIGIN(XPI0) + 0x3000;
  23. __boot_header_length__ = __boot_header_end__ - __boot_header_start__;
  24. __app_offset__ = __app_load_addr__ - __boot_header_load_addr__;
  25. SECTIONS
  26. {
  27. .nor_cfg_option __nor_cfg_option_load_addr__ : {
  28. KEEP(*(.nor_cfg_option))
  29. } > XPI0
  30. .boot_header __boot_header_load_addr__ : {
  31. __boot_header_start__ = .;
  32. KEEP(*(.boot_header))
  33. KEEP(*(.fw_info_table))
  34. KEEP(*(.dc_info))
  35. __boot_header_end__ = .;
  36. } > XPI0
  37. .start __app_load_addr__ : {
  38. . = ALIGN(8);
  39. KEEP(*(.start))
  40. } > XPI0
  41. __vector_load_addr__ = ADDR(.start) + SIZEOF(.start);
  42. .vectors ORIGIN(ILM) : AT(__vector_load_addr__) {
  43. . = ALIGN(8);
  44. __vector_ram_start__ = .;
  45. KEEP(*(.vector_table))
  46. KEEP(*(.isr_vector))
  47. KEEP(*(.isr_vector.*))
  48. . = ALIGN(8);
  49. __vector_ram_end__ = .;
  50. } > ILM
  51. .text (__vector_load_addr__ + SIZEOF(.vectors)) : {
  52. . = ALIGN(8);
  53. *(EXCLUDE_FILE (nx*.o*) .text)
  54. *(EXCLUDE_FILE (nx*.o*) .text*)
  55. *(EXCLUDE_FILE (nx*.o*) .rodata)
  56. *(EXCLUDE_FILE (nx*.o*) .rodata*)
  57. *(EXCLUDE_FILE (nx*.o*) .srodata)
  58. *(EXCLUDE_FILE (nx*.o*) .srodata*)
  59. *(.hash)
  60. *(.dyn*)
  61. *(.gnu*)
  62. *(.pl*)
  63. KEEP (*(.init))
  64. KEEP (*(.fini))
  65. /* section information for usbh class */
  66. . = ALIGN(8);
  67. __usbh_class_info_start__ = .;
  68. KEEP(*(.usbh_class_info))
  69. __usbh_class_info_end__ = .;
  70. /* RT-Thread related sections - Start */
  71. /* section information for finsh shell */
  72. . = ALIGN(4);
  73. __fsymtab_start = .;
  74. KEEP(*(FSymTab))
  75. __fsymtab_end = .;
  76. . = ALIGN(4);
  77. __vsymtab_start = .;
  78. KEEP(*(VSymTab))
  79. __vsymtab_end = .;
  80. . = ALIGN(4);
  81. . = ALIGN(4);
  82. __rt_init_start = .;
  83. KEEP(*(SORT(.rti_fn*)))
  84. __rt_init_end = .;
  85. . = ALIGN(4);
  86. /* section information for modules */
  87. . = ALIGN(4);
  88. __rtmsymtab_start = .;
  89. KEEP(*(RTMSymTab))
  90. __rtmsymtab_end = .;
  91. /* RT-Thread related sections - end */
  92. . = ALIGN(8);
  93. } > XPI0
  94. .eh_frame :
  95. {
  96. __eh_frame_start = .;
  97. KEEP(*(.eh_frame))
  98. __eh_frame_end = .;
  99. } > XPI0
  100. .eh_frame_hdr :
  101. {
  102. KEEP(*(.eh_frame_hdr))
  103. } > XPI0
  104. __eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0;
  105. __eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0;
  106. .rel : {
  107. KEEP(*(.rel*))
  108. } > XPI0
  109. PROVIDE (__etext = .);
  110. PROVIDE (_etext = .);
  111. PROVIDE (etext = .);
  112. __data_load_addr__ = etext;
  113. .data : AT(__data_load_addr__) {
  114. . = ALIGN(8);
  115. __data_start__ = .;
  116. __global_pointer$ = . + 0x800;
  117. *(.data)
  118. *(.data*)
  119. *(.sdata)
  120. *(.sdata*)
  121. KEEP(*(.jcr))
  122. KEEP(*(.dynamic))
  123. KEEP(*(.got*))
  124. KEEP(*(.got))
  125. KEEP(*(.gcc_except_table))
  126. KEEP(*(.gcc_except_table.*))
  127. . = ALIGN(8);
  128. PROVIDE(__preinit_array_start = .);
  129. KEEP(*(.preinit_array))
  130. PROVIDE(__preinit_array_end = .);
  131. . = ALIGN(8);
  132. PROVIDE(__init_array_start = .);
  133. KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)))
  134. KEEP(*(.init_array))
  135. PROVIDE(__init_array_end = .);
  136. . = ALIGN(8);
  137. PROVIDE(__finit_array_start = .);
  138. KEEP(*(SORT_BY_INIT_PRIORITY(.finit_array.*)))
  139. KEEP(*(.finit_array))
  140. PROVIDE(__finit_array_end = .);
  141. . = ALIGN(8);
  142. KEEP(*crtbegin*.o(.ctors))
  143. KEEP(*(EXCLUDE_FILE (*crtend*.o) .ctors))
  144. KEEP(*(SORT(.ctors.*)))
  145. KEEP(*(.ctors))
  146. . = ALIGN(8);
  147. KEEP(*crtbegin*.o(.dtors))
  148. KEEP(*(EXCLUDE_FILE (*crtend*.o) .dtors))
  149. KEEP(*(SORT(.dtors.*)))
  150. KEEP(*(.dtors))
  151. . = ALIGN(8);
  152. __data_end__ = .;
  153. PROVIDE (__edata = .);
  154. PROVIDE (_edata = .);
  155. PROVIDE (edata = .);
  156. } > SDRAM
  157. __fast_load_addr__ = etext + SIZEOF(.data);
  158. .fast : AT(__fast_load_addr__) {
  159. . = ALIGN(8);
  160. PROVIDE(__ramfunc_start__ = .);
  161. *(.fast)
  162. *(.fast.*)
  163. nx*.o*(.text)
  164. nx*.o*(.text*)
  165. nx*.o*(.rodata)
  166. nx*.o*(.rodata*)
  167. nx*.o*(.srodata)
  168. nx*.o*(.srodata*)
  169. . = ALIGN(8);
  170. PROVIDE(__ramfunc_end__ = .);
  171. } > ILM
  172. __tdata_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast);
  173. .tdata : AT(__tdata_load_addr__) {
  174. . = ALIGN(8);
  175. PROVIDE(__tdata_start__ = .);
  176. *(.tdata)
  177. *(.tdata.*)
  178. *(.gnu.linkonce.td.*)
  179. . = ALIGN(8);
  180. PROVIDE(__tdata_end__ = .);
  181. } > SDRAM
  182. .tbss (NOLOAD) : {
  183. . = ALIGN(8);
  184. PROVIDE(__tbss_start__ = .);
  185. __thread_pointer$ = .;
  186. *(.tbss)
  187. *(.tbss.*)
  188. *(.gnu.linkonce.tb.*)
  189. *(.tcommon)
  190. . = ALIGN(8);
  191. PROVIDE(__tbss_end__ = .);
  192. } > SDRAM
  193. __noncacheable_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata);
  194. .noncacheable.init : AT(__noncacheable_init_load_addr__) {
  195. . = ALIGN(8);
  196. __noncacheable_init_start__ = .;
  197. KEEP(*(.noncacheable.init))
  198. KEEP(*(.noncacheable.init.*))
  199. __noncacheable_init_end__ = .;
  200. . = ALIGN(8);
  201. } > NONCACHEABLE_RAM
  202. __fast_ram_init_load_addr__ = etext + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata) + SIZEOF(.noncacheable.init);
  203. .fast_ram.init : AT(__fast_ram_init_load_addr__) {
  204. . = ALIGN(8);
  205. __fast_ram_init_start__ = .;
  206. KEEP(*(.fast_ram.init))
  207. KEEP(*(.fast_ram.init.*))
  208. __fast_ram_init_end__ = .;
  209. . = ALIGN(8);
  210. } > DLM
  211. .bss (NOLOAD) : {
  212. . = ALIGN(8);
  213. __bss_start__ = .;
  214. *(.bss)
  215. *(.bss*)
  216. *(.sbss*)
  217. *(.scommon)
  218. *(.scommon*)
  219. *(.dynsbss*)
  220. *(COMMON)
  221. . = ALIGN(8);
  222. _end = .;
  223. __bss_end__ = .;
  224. } > SDRAM
  225. .framebuffer (NOLOAD) : {
  226. . = ALIGN(8);
  227. KEEP(*(.framebuffer))
  228. KEEP(*(.framebuffer.*))
  229. . = ALIGN(8);
  230. } > SDRAM
  231. .heap (NOLOAD) : {
  232. . = ALIGN(8);
  233. __heap_start__ = .;
  234. . += HEAP_SIZE;
  235. __heap_end__ = .;
  236. } > SDRAM
  237. .noncacheable (NOLOAD) : {
  238. . = ALIGN(8);
  239. KEEP(*(.noncacheable)) /* Legacy sections, kept for backwards compatibility */
  240. KEEP(*(.noncacheable.non_init))
  241. KEEP(*(.noncacheable.non_init.*))
  242. __noncacheable_bss_start__ = .;
  243. KEEP(*(.noncacheable.bss))
  244. KEEP(*(.noncacheable.bss.*))
  245. __noncacheable_bss_end__ = .;
  246. . = ALIGN(8);
  247. } > NONCACHEABLE_RAM
  248. .sh_mem (NOLOAD) : {
  249. KEEP(*(.sh_mem))
  250. KEEP(*(.sh_mem.*))
  251. } > SHARE_RAM
  252. .ahb_sram (NOLOAD) : {
  253. KEEP(*(.ahb_sram))
  254. KEEP(*(.ahb_sram.*))
  255. } > AHB_SRAM
  256. .apb_sram (NOLOAD) : {
  257. KEEP(*(.backup_sram))
  258. KEEP(*(.backup_sram.*))
  259. } > APB_SRAM
  260. .fast_ram (NOLOAD) : {
  261. . = ALIGN(8);
  262. KEEP(*(.fast_ram)) /* Legacy sections, kept for backwards compatibility */
  263. KEEP(*(.fast_ram.non_init))
  264. KEEP(*(.fast_ram.non_init.*))
  265. __fast_ram_bss_start__ = .;
  266. KEEP(*(.fast_ram.bss))
  267. KEEP(*(.fast_ram.bss.*))
  268. __fast_ram_bss_end__ = .;
  269. . = ALIGN(8);
  270. } > DLM
  271. .stack (NOLOAD) : {
  272. . = ALIGN(16);
  273. __stack_base__ = .;
  274. . += STACK_SIZE;
  275. . = ALIGN(16);
  276. PROVIDE (_stack = .);
  277. PROVIDE (_stack_safe = .);
  278. } > DLM
  279. __noncacheable_start__ = ORIGIN(NONCACHEABLE_RAM);
  280. __noncacheable_end__ = ORIGIN(NONCACHEABLE_RAM) + LENGTH(NONCACHEABLE_RAM);
  281. __share_mem_start__ = ORIGIN(SHARE_RAM);
  282. __share_mem_end__ = ORIGIN(SHARE_RAM) + LENGTH(SHARE_RAM);
  283. __fw_size__ = SIZEOF(.start) + SIZEOF(.vectors) + SIZEOF(.rel) + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.fast) + SIZEOF(.tdata) + SIZEOF(.noncacheable.init) + SIZEOF(.fast_ram.init);
  284. __last_addr__ = __fast_ram_init_load_addr__ + SIZEOF(.fast_ram.init);
  285. ASSERT(((__fw_size__ <= LENGTH(XPI0)) && (__last_addr__ <= (ORIGIN(XPI0) + LENGTH(XPI0)))), "****** FAILED! XPI0 has not enough space! ******")
  286. }