link.ld 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /******************************************************************************
  2. * Copyright (C) 2022-2025, 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 HC32F334xA.ld */
  12. /* Abstract Linker script for HC32F334 Device with */
  13. /* 128KByte FLASH, 68KByte RAM */
  14. /* Version V1.0 */
  15. /* Date 2024-01-15 */
  16. /*****************************************************************************/
  17. /* OTP section(not flash multiplexed region) implementation.
  18. You need to pay attention to the size of the specified OTP block.
  19. Take two OTP blocks for example. */
  20. __OTP_DATA_BASE = 0x03000C00;
  21. __OTP_LOCK_BASE = 0x03000A80;
  22. /* OTP block 1 */
  23. __OTP_DATA_B1_START = 0x03000C00;
  24. __OTP_LOCK_B1_START = 0x03000AC0;
  25. __OTP_DATA_B1_OFFSET = __OTP_DATA_B1_START - __OTP_DATA_BASE;
  26. __OTP_LOCK_B1_OFFSET = __OTP_LOCK_B1_START - __OTP_LOCK_BASE;
  27. /* OTP block 2 */
  28. __OTP_DATA_B2_START = 0x03000C40;
  29. __OTP_LOCK_B2_START = 0x03000AC4;
  30. __OTP_DATA_B2_OFFSET = __OTP_DATA_B2_START - __OTP_DATA_BASE;
  31. __OTP_LOCK_B2_OFFSET = __OTP_LOCK_B2_START - __OTP_LOCK_BASE;
  32. /* Use contiguous memory regions for simple. */
  33. MEMORY
  34. {
  35. FLASH (rx): ORIGIN = 0x00000000, LENGTH = 128K
  36. OTP_DATA (rx): ORIGIN = 0x03000C00, LENGTH = 1K
  37. OTP_LOCK (rx): ORIGIN = 0x03000A80, LENGTH = 68
  38. RAM (rwx): ORIGIN = 0x1FFFC000, LENGTH = 32K
  39. RAMB (rwx): ORIGIN = 0x200F0000, LENGTH = 4K
  40. }
  41. ENTRY(Reset_Handler)
  42. SECTIONS
  43. {
  44. .vectors :
  45. {
  46. . = ALIGN(4);
  47. KEEP(*(.vectors))
  48. . = ALIGN(4);
  49. } >FLASH
  50. .icg_sec 0x00000400 :
  51. {
  52. KEEP(*(.icg_sec))
  53. } >FLASH
  54. .text :
  55. {
  56. . = ALIGN(4);
  57. _stext = .;
  58. KEEP(*(.isr_vector)) /* Startup code */
  59. . = ALIGN(4);
  60. *(.text) /* remaining code */
  61. *(.text.*) /* remaining code */
  62. *(.rodata) /* read-only data (constants) */
  63. *(.rodata*)
  64. *(.glue_7)
  65. *(.glue_7t)
  66. *(.gnu.linkonce.t*)
  67. /* section information for finsh shell */
  68. . = ALIGN(4);
  69. __fsymtab_start = .;
  70. KEEP(*(FSymTab))
  71. __fsymtab_end = .;
  72. . = ALIGN(4);
  73. __vsymtab_start = .;
  74. KEEP(*(VSymTab))
  75. __vsymtab_end = .;
  76. . = ALIGN(4);
  77. /* section information for initial. */
  78. . = ALIGN(4);
  79. __rt_init_start = .;
  80. KEEP(*(SORT(.rti_fn*)))
  81. __rt_init_end = .;
  82. . = ALIGN(4);
  83. . = ALIGN(4);
  84. _etext = .;
  85. } >FLASH
  86. .rodata :
  87. {
  88. . = ALIGN(4);
  89. *(.rodata)
  90. *(.rodata*)
  91. . = ALIGN(4);
  92. } >FLASH
  93. .ARM.extab :
  94. {
  95. *(.ARM.extab* .gnu.linkonce.armextab.*)
  96. } >FLASH
  97. __exidx_start = .;
  98. .ARM.exidx :
  99. {
  100. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  101. } >FLASH
  102. __exidx_end = .;
  103. .preinit_array :
  104. {
  105. . = ALIGN(4);
  106. /* preinit data */
  107. PROVIDE_HIDDEN (__preinit_array_start = .);
  108. KEEP(*(.preinit_array))
  109. PROVIDE_HIDDEN (__preinit_array_end = .);
  110. . = ALIGN(4);
  111. } >FLASH
  112. .init_array :
  113. {
  114. . = ALIGN(4);
  115. /* init data */
  116. PROVIDE_HIDDEN (__init_array_start = .);
  117. KEEP(*(SORT(.init_array.*)))
  118. KEEP(*(.init_array))
  119. PROVIDE_HIDDEN (__init_array_end = .);
  120. . = ALIGN(4);
  121. } >FLASH
  122. .fini_array :
  123. {
  124. . = ALIGN(4);
  125. /* finit data */
  126. PROVIDE_HIDDEN (__fini_array_start = .);
  127. KEEP(*(SORT(.fini_array.*)))
  128. KEEP(*(.fini_array))
  129. PROVIDE_HIDDEN (__fini_array_end = .);
  130. . = ALIGN(4);
  131. } >FLASH
  132. __etext = ALIGN(4);
  133. .otp_data :
  134. {
  135. . = ALIGN(4);
  136. . = ORIGIN(OTP_DATA) + __OTP_DATA_B1_OFFSET;
  137. KEEP(*(.otp_b1_data*))
  138. . = ORIGIN(OTP_DATA) + __OTP_DATA_B2_OFFSET;
  139. KEEP(*(.otp_b2_data*))
  140. . = ALIGN(4);
  141. } >OTP_DATA
  142. .otp_lock :
  143. {
  144. . = ALIGN(4);
  145. . = ORIGIN(OTP_LOCK) + __OTP_LOCK_B1_OFFSET;
  146. KEEP(*(.otp_b1_lock*))
  147. . = ORIGIN(OTP_LOCK) + __OTP_LOCK_B2_OFFSET;
  148. KEEP(*(.otp_b2_lock*))
  149. . = ALIGN(4);
  150. } >OTP_LOCK
  151. .data : AT (__etext)
  152. {
  153. . = ALIGN(4);
  154. __data_start__ = .;
  155. *(vtable)
  156. *(.data)
  157. *(.data*)
  158. *(.gnu.linkonce.d*)
  159. . = ALIGN(4);
  160. *(.ramfunc)
  161. *(.ramfunc*)
  162. . = ALIGN(4);
  163. __data_end__ = .;
  164. } >RAM
  165. .heap_stack (COPY) :
  166. {
  167. . = ALIGN(8);
  168. __end__ = .;
  169. PROVIDE(end = .);
  170. PROVIDE(_end = .);
  171. *(.heap*)
  172. . = ALIGN(8);
  173. __HeapLimit = .;
  174. __StackLimit = .;
  175. *(.stack*)
  176. . = ALIGN(8);
  177. __StackTop = .;
  178. } >RAM
  179. __etext_ramb = __etext + ALIGN (SIZEOF(.data), 4);
  180. .ramb_data : AT (__etext_ramb)
  181. {
  182. . = ALIGN(4);
  183. __data_start_ramb__ = .;
  184. *(.ramb_data)
  185. *(.ramb_data*)
  186. . = ALIGN(4);
  187. __data_end_ramb__ = .;
  188. } >RAMB
  189. __bss_start = .;
  190. .bss __StackTop (NOLOAD):
  191. {
  192. . = ALIGN(4);
  193. _sbss = .;
  194. __bss_start__ = _sbss;
  195. *(.bss)
  196. *(.bss*)
  197. *(COMMON)
  198. . = ALIGN(4);
  199. _ebss = .;
  200. __bss_end__ = _ebss;
  201. . = ALIGN(4);
  202. *(.noinit*)
  203. . = ALIGN(4);
  204. } >RAM
  205. __bss_end = .;
  206. .ramb_bss :
  207. {
  208. . = ALIGN(4);
  209. __bss_start_ramb__ = .;
  210. *(.ramb_bss)
  211. *(.ramb_bss*)
  212. . = ALIGN(4);
  213. __bss_end_ramb__ = .;
  214. } >RAMB
  215. /DISCARD/ :
  216. {
  217. libc.a (*)
  218. libm.a (*)
  219. libgcc.a (*)
  220. }
  221. .ARM.attributes 0 : { *(.ARM.attributes) }
  222. PROVIDE(_stack = __StackTop);
  223. PROVIDE(_Min_Heap_Size = __HeapLimit - __HeapBase);
  224. PROVIDE(_Min_Stack_Size = __StackTop - __StackLimit);
  225. __RamEnd = ORIGIN(RAM) + LENGTH(RAM);
  226. ASSERT(__StackTop <= __RamEnd, "region RAM overflowed with stack")
  227. /* Stabs debugging sections. */
  228. .stab 0 : { *(.stab) }
  229. .stabstr 0 : { *(.stabstr) }
  230. .stab.excl 0 : { *(.stab.excl) }
  231. .stab.exclstr 0 : { *(.stab.exclstr) }
  232. .stab.index 0 : { *(.stab.index) }
  233. .stab.indexstr 0 : { *(.stab.indexstr) }
  234. .comment 0 : { *(.comment) }
  235. /* DWARF debug sections.
  236. * Symbols in the DWARF debugging sections are relative to the beginning
  237. * of the section so we begin them at 0. */
  238. /* DWARF 1 */
  239. .debug 0 : { *(.debug) }
  240. .line 0 : { *(.line) }
  241. /* GNU DWARF 1 extensions */
  242. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  243. .debug_sfnames 0 : { *(.debug_sfnames) }
  244. /* DWARF 1.1 and DWARF 2 */
  245. .debug_aranges 0 : { *(.debug_aranges) }
  246. .debug_pubnames 0 : { *(.debug_pubnames) }
  247. /* DWARF 2 */
  248. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  249. .debug_abbrev 0 : { *(.debug_abbrev) }
  250. .debug_line 0 : { *(.debug_line) }
  251. .debug_frame 0 : { *(.debug_frame) }
  252. .debug_str 0 : { *(.debug_str) }
  253. .debug_loc 0 : { *(.debug_loc) }
  254. .debug_macinfo 0 : { *(.debug_macinfo) }
  255. /* SGI/MIPS DWARF 2 extensions */
  256. .debug_weaknames 0 : { *(.debug_weaknames) }
  257. .debug_funcnames 0 : { *(.debug_funcnames) }
  258. .debug_typenames 0 : { *(.debug_typenames) }
  259. .debug_varnames 0 : { *(.debug_varnames) }
  260. }