link.ld 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /******************************************************************************
  2. * Copyright (C) 2022-2023, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by XHSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. *
  9. */
  10. /*****************************************************************************/
  11. /* File HC32F472xE.ld */
  12. /* Abstract Linker script for HC32F472 Device with */
  13. /* 512KByte FLASH, 68KByte RAM */
  14. /* Version V1.0 */
  15. /* Date 2022-06-30 */
  16. /*****************************************************************************/
  17. /* Custom defines, according to section 7.7 of the user manual.
  18. Take OTP sector 16 for example. */
  19. __OTP_DATA_START = 0x03000000;
  20. __OTP_DATA_SIZE = 2048;
  21. __OTP_LOCK_START = 0x03001800;
  22. __OTP_LOCK_SIZE = 728;
  23. /* Use contiguous memory regions for simple. */
  24. MEMORY
  25. {
  26. FLASH (rx): ORIGIN = 0x00000000, LENGTH = 512K
  27. OTP_DATA (rx): ORIGIN = __OTP_DATA_START, LENGTH = __OTP_DATA_SIZE
  28. OTP_LOCK (rx): ORIGIN = __OTP_LOCK_START, LENGTH = __OTP_LOCK_SIZE
  29. RAM (rwx): ORIGIN = 0x1FFF8000, LENGTH = 64K
  30. RAMB (rwx): ORIGIN = 0x200F0000, LENGTH = 4K
  31. QSPI_ROM (rx): ORIGIN = 0x98000000, LENGTH = 8M
  32. }
  33. ENTRY(Reset_Handler)
  34. SECTIONS
  35. {
  36. .vectors :
  37. {
  38. . = ALIGN(4);
  39. KEEP(*(.vectors))
  40. . = ALIGN(4);
  41. } >FLASH
  42. .icg_sec 0x00000400 :
  43. {
  44. KEEP(*(.icg_sec))
  45. } >FLASH
  46. .ex_rom :
  47. {
  48. . = ALIGN(4);
  49. KEEP(*(.ex_rom))
  50. . = ALIGN(4);
  51. } >QSPI_ROM
  52. .text :
  53. {
  54. . = ALIGN(4);
  55. _stext = .;
  56. KEEP(*(.isr_vector)) /* Startup code */
  57. . = ALIGN(4);
  58. *(.text) /* remaining code */
  59. *(.text.*) /* remaining code */
  60. *(.rodata) /* read-only data (constants) */
  61. *(.rodata*)
  62. *(.glue_7)
  63. *(.glue_7t)
  64. *(.gnu.linkonce.t*)
  65. /* section information for finsh shell */
  66. . = ALIGN(4);
  67. __fsymtab_start = .;
  68. KEEP(*(FSymTab))
  69. __fsymtab_end = .;
  70. . = ALIGN(4);
  71. __vsymtab_start = .;
  72. KEEP(*(VSymTab))
  73. __vsymtab_end = .;
  74. . = ALIGN(4);
  75. /* section information for initial. */
  76. . = ALIGN(4);
  77. __rt_init_start = .;
  78. KEEP(*(SORT(.rti_fn*)))
  79. __rt_init_end = .;
  80. . = ALIGN(4);
  81. /* section for CherryUSB. */
  82. . = ALIGN(4);
  83. __usbh_class_info_start__ = .;
  84. KEEP(*(.usbh_class_info))
  85. __usbh_class_info_end__ = .;
  86. . = ALIGN(4);
  87. _etext = .;
  88. } >FLASH
  89. .rodata :
  90. {
  91. . = ALIGN(4);
  92. *(.rodata)
  93. *(.rodata*)
  94. . = ALIGN(4);
  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. .preinit_array :
  107. {
  108. . = ALIGN(4);
  109. /* preinit data */
  110. PROVIDE_HIDDEN (__preinit_array_start = .);
  111. KEEP(*(.preinit_array))
  112. PROVIDE_HIDDEN (__preinit_array_end = .);
  113. . = ALIGN(4);
  114. } >FLASH
  115. .init_array :
  116. {
  117. . = ALIGN(4);
  118. /* init data */
  119. PROVIDE_HIDDEN (__init_array_start = .);
  120. KEEP(*(SORT(.init_array.*)))
  121. KEEP(*(.init_array))
  122. PROVIDE_HIDDEN (__init_array_end = .);
  123. . = ALIGN(4);
  124. } >FLASH
  125. .fini_array :
  126. {
  127. . = ALIGN(4);
  128. /* finit data */
  129. PROVIDE_HIDDEN (__fini_array_start = .);
  130. KEEP(*(SORT(.fini_array.*)))
  131. KEEP(*(.fini_array))
  132. PROVIDE_HIDDEN (__fini_array_end = .);
  133. . = ALIGN(4);
  134. } >FLASH
  135. __etext = ALIGN(4);
  136. .otp_data_sec :
  137. {
  138. KEEP(*(.otp_data_sec))
  139. } >OTP_DATA
  140. .otp_lock_sec :
  141. {
  142. KEEP(*(.otp_lock_sec))
  143. } >OTP_LOCK
  144. .data : AT (__etext)
  145. {
  146. . = ALIGN(4);
  147. __data_start__ = .;
  148. *(vtable)
  149. *(.data)
  150. *(.data*)
  151. *(.gnu.linkonce.d*)
  152. . = ALIGN(4);
  153. *(.ramfunc)
  154. *(.ramfunc*)
  155. . = ALIGN(4);
  156. __data_end__ = .;
  157. } >RAM
  158. .heap_stack (COPY) :
  159. {
  160. . = ALIGN(8);
  161. __end__ = .;
  162. PROVIDE(end = .);
  163. PROVIDE(_end = .);
  164. *(.heap*)
  165. . = ALIGN(8);
  166. __HeapLimit = .;
  167. __StackLimit = .;
  168. *(.stack*)
  169. . = ALIGN(8);
  170. __StackTop = .;
  171. } >RAM
  172. __etext_ramb = __etext + ALIGN (SIZEOF(.data), 4);
  173. .ramb_data : AT (__etext_ramb)
  174. {
  175. . = ALIGN(4);
  176. __data_start_ramb__ = .;
  177. *(.ramb_data)
  178. *(.ramb_data*)
  179. . = ALIGN(4);
  180. __data_end_ramb__ = .;
  181. } >RAMB
  182. __bss_start = .;
  183. .bss __StackTop (NOLOAD):
  184. {
  185. . = ALIGN(4);
  186. _sbss = .;
  187. __bss_start__ = _sbss;
  188. *(.bss)
  189. *(.bss*)
  190. *(COMMON)
  191. . = ALIGN(4);
  192. _ebss = .;
  193. __bss_end__ = _ebss;
  194. . = ALIGN(4);
  195. *(.noinit*)
  196. . = ALIGN(4);
  197. } >RAM
  198. __bss_end = .;
  199. .ramb_bss :
  200. {
  201. . = ALIGN(4);
  202. __bss_start_ramb__ = .;
  203. *(.ramb_bss)
  204. *(.ramb_bss*)
  205. . = ALIGN(4);
  206. __bss_end_ramb__ = .;
  207. } >RAMB
  208. /DISCARD/ :
  209. {
  210. libc.a (*)
  211. libm.a (*)
  212. libgcc.a (*)
  213. }
  214. .ARM.attributes 0 : { *(.ARM.attributes) }
  215. PROVIDE(_stack = __StackTop);
  216. PROVIDE(_Min_Heap_Size = __HeapLimit - __HeapBase);
  217. PROVIDE(_Min_Stack_Size = __StackTop - __StackLimit);
  218. __RamEnd = ORIGIN(RAM) + LENGTH(RAM);
  219. ASSERT(__StackTop <= __RamEnd, "region RAM overflowed with stack")
  220. /* Stabs debugging sections. */
  221. .stab 0 : { *(.stab) }
  222. .stabstr 0 : { *(.stabstr) }
  223. .stab.excl 0 : { *(.stab.excl) }
  224. .stab.exclstr 0 : { *(.stab.exclstr) }
  225. .stab.index 0 : { *(.stab.index) }
  226. .stab.indexstr 0 : { *(.stab.indexstr) }
  227. .comment 0 : { *(.comment) }
  228. /* DWARF debug sections.
  229. * Symbols in the DWARF debugging sections are relative to the beginning
  230. * of the section so we begin them at 0. */
  231. /* DWARF 1 */
  232. .debug 0 : { *(.debug) }
  233. .line 0 : { *(.line) }
  234. /* GNU DWARF 1 extensions */
  235. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  236. .debug_sfnames 0 : { *(.debug_sfnames) }
  237. /* DWARF 1.1 and DWARF 2 */
  238. .debug_aranges 0 : { *(.debug_aranges) }
  239. .debug_pubnames 0 : { *(.debug_pubnames) }
  240. /* DWARF 2 */
  241. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  242. .debug_abbrev 0 : { *(.debug_abbrev) }
  243. .debug_line 0 : { *(.debug_line) }
  244. .debug_frame 0 : { *(.debug_frame) }
  245. .debug_str 0 : { *(.debug_str) }
  246. .debug_loc 0 : { *(.debug_loc) }
  247. .debug_macinfo 0 : { *(.debug_macinfo) }
  248. /* SGI/MIPS DWARF 2 extensions */
  249. .debug_weaknames 0 : { *(.debug_weaknames) }
  250. .debug_funcnames 0 : { *(.debug_funcnames) }
  251. .debug_typenames 0 : { *(.debug_typenames) }
  252. .debug_varnames 0 : { *(.debug_varnames) }
  253. }