link.ld 7.0 KB

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