link.lds 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /**
  2. *******************************************************************************
  3. * @file hc32f4a0_flash.lds
  4. * @brief Linker script for HC32F4A0 Device with 2MByte FLASH, 512KByte RAM.
  5. @verbatim
  6. Change Logs:
  7. Date Author Notes
  8. 2020-09-15 Chengy First version
  9. @endverbatim
  10. *******************************************************************************
  11. * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
  12. *
  13. * This software component is licensed by HDSC under BSD 3-Clause license
  14. * (the "License"); You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. *******************************************************************************
  19. */
  20. /* Use contiguous memory regions for simple. */
  21. MEMORY
  22. {
  23. FLASH (rx): ORIGIN = 0x00000000, LENGTH = 2M
  24. OTP (rx): ORIGIN = 0x03000000, LENGTH = 6876
  25. RAM (rwx): ORIGIN = 0x1FFE0000, LENGTH = 512K
  26. RAMB (rwx): ORIGIN = 0x200F0000, LENGTH = 4K
  27. }
  28. ENTRY(Reset_Handler)
  29. SECTIONS
  30. {
  31. .vectors :
  32. {
  33. . = ALIGN(4);
  34. KEEP(*(.vectors))
  35. . = ALIGN(4);
  36. } >FLASH
  37. .icg_sec 0x00000400 :
  38. {
  39. KEEP(*(.icg_sec))
  40. } >FLASH
  41. .text :
  42. {
  43. . = ALIGN(4);
  44. *(.text)
  45. *(.text*)
  46. *(.glue_7)
  47. *(.glue_7t)
  48. *(.eh_frame)
  49. KEEP(*(.init))
  50. KEEP(*(.fini))
  51. . = ALIGN(4);
  52. } >FLASH
  53. .rodata :
  54. {
  55. . = ALIGN(4);
  56. *(.rodata)
  57. *(.rodata*)
  58. . = ALIGN(4);
  59. } >FLASH
  60. .ARM.extab :
  61. {
  62. *(.ARM.extab* .gnu.linkonce.armextab.*)
  63. } >FLASH
  64. __exidx_start = .;
  65. .ARM.exidx :
  66. {
  67. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  68. } >FLASH
  69. __exidx_end = .;
  70. .preinit_array :
  71. {
  72. . = ALIGN(4);
  73. /* preinit data */
  74. PROVIDE_HIDDEN (__preinit_array_start = .);
  75. KEEP(*(.preinit_array))
  76. PROVIDE_HIDDEN (__preinit_array_end = .);
  77. . = ALIGN(4);
  78. } >FLASH
  79. .init_array :
  80. {
  81. . = ALIGN(4);
  82. /* init data */
  83. PROVIDE_HIDDEN (__init_array_start = .);
  84. KEEP(*(SORT(.init_array.*)))
  85. KEEP(*(.init_array))
  86. PROVIDE_HIDDEN (__init_array_end = .);
  87. . = ALIGN(4);
  88. } >FLASH
  89. .fini_array :
  90. {
  91. . = ALIGN(4);
  92. /* finit data */
  93. PROVIDE_HIDDEN (__fini_array_start = .);
  94. KEEP(*(SORT(.fini_array.*)))
  95. KEEP(*(.fini_array))
  96. PROVIDE_HIDDEN (__fini_array_end = .);
  97. . = ALIGN(4);
  98. } >FLASH
  99. __etext = ALIGN(4);
  100. .otp_sec :
  101. {
  102. KEEP(*(.otp_sec))
  103. } >OTP
  104. .otp_lock_sec 0x03001800 :
  105. {
  106. KEEP(*(.otp_lock_sec))
  107. } >OTP
  108. .data : AT (__etext)
  109. {
  110. . = ALIGN(4);
  111. __data_start__ = .;
  112. *(vtable)
  113. *(.data)
  114. *(.data*)
  115. . = ALIGN(4);
  116. *(.ramfunc)
  117. *(.ramfunc*)
  118. . = ALIGN(4);
  119. __data_end__ = .;
  120. } >RAM
  121. __etext_ramb = __etext + ALIGN (SIZEOF(.data), 4);
  122. .ramb_data : AT (__etext_ramb)
  123. {
  124. . = ALIGN(4);
  125. __data_start_ramb__ = .;
  126. *(.ramb_data)
  127. *(.ramb_data*)
  128. . = ALIGN(4);
  129. __data_end_ramb__ = .;
  130. } >RAMB
  131. .bss :
  132. {
  133. . = ALIGN(4);
  134. _sbss = .;
  135. __bss_start__ = _sbss;
  136. *(.bss)
  137. *(.bss*)
  138. *(COMMON)
  139. . = ALIGN(4);
  140. _ebss = .;
  141. __bss_end__ = _ebss;
  142. } >RAM
  143. .ramb_bss :
  144. {
  145. . = ALIGN(4);
  146. __bss_start_ramb__ = .;
  147. *(.ramb_bss)
  148. *(.ramb_bss*)
  149. . = ALIGN(4);
  150. __bss_end_ramb__ = .;
  151. } >RAMB
  152. .heap_stack (COPY) :
  153. {
  154. . = ALIGN(8);
  155. __end__ = .;
  156. PROVIDE(end = .);
  157. PROVIDE(_end = .);
  158. *(.heap*)
  159. . = ALIGN(8);
  160. __HeapLimit = .;
  161. __StackLimit = .;
  162. *(.stack*)
  163. . = ALIGN(8);
  164. __StackTop = .;
  165. } >RAM
  166. /DISCARD/ :
  167. {
  168. libc.a (*)
  169. libm.a (*)
  170. libgcc.a (*)
  171. }
  172. .ARM.attributes 0 : { *(.ARM.attributes) }
  173. PROVIDE(_stack = __StackTop);
  174. PROVIDE(_Min_Heap_Size = __HeapLimit - __HeapBase);
  175. PROVIDE(_Min_Stack_Size = __StackTop - __StackLimit);
  176. __RamEnd = ORIGIN(RAM) + LENGTH(RAM);
  177. ASSERT(__StackTop <= __RamEnd, "region RAM overflowed with stack")
  178. }