GD32VF103x6.lds 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. OUTPUT_ARCH( "riscv" )
  2. ENTRY( _start )
  3. MEMORY
  4. {
  5. /* Run in FLASH */
  6. flash (rxai!w) : ORIGIN = 0x08000000, LENGTH = 32k
  7. ram (wxa!ri) : ORIGIN = 0x20000000, LENGTH = 10k
  8. /* Run in RAM */
  9. /* flash (rxai!w) : ORIGIN = 0x20000000, LENGTH = 7k
  10. ram (wxa!ri) : ORIGIN = 0x20001C00, LENGTH = 3K
  11. */
  12. }
  13. SECTIONS
  14. {
  15. __stack_size = DEFINED(__stack_size) ? __stack_size : 1K;
  16. .init :
  17. {
  18. KEEP (*(SORT_NONE(.init)))
  19. } >flash AT>flash
  20. .ilalign :
  21. {
  22. . = ALIGN(4);
  23. PROVIDE( _ilm_lma = . );
  24. } >flash AT>flash
  25. .ialign :
  26. {
  27. PROVIDE( _ilm = . );
  28. } >flash AT>flash
  29. .text :
  30. {
  31. *(.rodata .rodata.*)
  32. *(.text.unlikely .text.unlikely.*)
  33. *(.text.startup .text.startup.*)
  34. *(.text .text.*)
  35. *(.gnu.linkonce.t.*)
  36. } >flash AT>flash
  37. .fini :
  38. {
  39. KEEP (*(SORT_NONE(.fini)))
  40. } >flash AT>flash
  41. . = ALIGN(4);
  42. PROVIDE (__etext = .);
  43. PROVIDE (_etext = .);/*0x80022c8*/
  44. PROVIDE (etext = .);/*0x80022c8*/
  45. PROVIDE( _eilm = . );
  46. .preinit_array :
  47. {
  48. PROVIDE_HIDDEN (__preinit_array_start = .);
  49. KEEP (*(.preinit_array))
  50. PROVIDE_HIDDEN (__preinit_array_end = .);
  51. } >flash AT>flash
  52. .init_array :
  53. {
  54. PROVIDE_HIDDEN (__init_array_start = .);
  55. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  56. KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  57. PROVIDE_HIDDEN (__init_array_end = .);
  58. } >flash AT>flash
  59. .fini_array :
  60. {
  61. PROVIDE_HIDDEN (__fini_array_start = .);
  62. KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  63. KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  64. PROVIDE_HIDDEN (__fini_array_end = .);
  65. } >flash AT>flash
  66. .ctors :
  67. {
  68. /* gcc uses crtbegin.o to find the start of
  69. the constructors, so we make sure it is
  70. first. Because this is a wildcard, it
  71. doesn't matter if the user does not
  72. actually link against crtbegin.o; the
  73. linker won't look for a file to match a
  74. wildcard. The wildcard also means that it
  75. doesn't matter which directory crtbegin.o
  76. is in. */
  77. KEEP (*crtbegin.o(.ctors))
  78. KEEP (*crtbegin?.o(.ctors))
  79. /* We don't want to include the .ctor section from
  80. the crtend.o file until after the sorted ctors.
  81. The .ctor section from the crtend file contains the
  82. end of ctors marker and it must be last */
  83. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
  84. KEEP (*(SORT(.ctors.*)))
  85. KEEP (*(.ctors))
  86. } >flash AT>flash
  87. .dtors :
  88. {
  89. KEEP (*crtbegin.o(.dtors))
  90. KEEP (*crtbegin?.o(.dtors))
  91. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
  92. KEEP (*(SORT(.dtors.*)))
  93. KEEP (*(.dtors))
  94. } >flash AT>flash
  95. . = ALIGN(4);
  96. PROVIDE( _eilm = . );
  97. .lalign :
  98. {
  99. . = ALIGN(4);
  100. PROVIDE( _data_lma = . );
  101. } >flash AT>flash
  102. .dalign :
  103. {
  104. . = ALIGN(4);
  105. PROVIDE( _data = . );
  106. } >ram AT>flash
  107. .data :
  108. {
  109. *(.rdata)
  110. *(.gnu.linkonce.r.*)
  111. *(.data .data.*)
  112. *(.gnu.linkonce.d.*)
  113. . = ALIGN(8);
  114. PROVIDE( __global_pointer$ = . + 0x800);
  115. *(.sdata .sdata.*)
  116. *(.gnu.linkonce.s.*)
  117. . = ALIGN(8);
  118. *(.srodata.cst16)
  119. *(.srodata.cst8)
  120. *(.srodata.cst4)
  121. *(.srodata.cst2)
  122. *(.srodata .srodata.*)
  123. } >ram AT>flash
  124. . = ALIGN(4);
  125. PROVIDE( _edata = . );
  126. PROVIDE( edata = . );
  127. PROVIDE( _fbss = . ); /*0X200052A0 0X200002A0*/
  128. PROVIDE( __bss_start = . );
  129. .bss :
  130. {
  131. *(.sbss*)
  132. *(.gnu.linkonce.sb.*)
  133. *(.bss .bss.*)
  134. *(.gnu.linkonce.b.*)
  135. *(COMMON)
  136. . = ALIGN(4);
  137. } >ram AT>ram
  138. . = ALIGN(8);
  139. PROVIDE( _end = . ); /*0X2000,0340*/
  140. PROVIDE( end = . );
  141. .stack ORIGIN(ram) + LENGTH(ram) - __stack_size :
  142. {
  143. PROVIDE( _heap_end = . );
  144. . = __stack_size;
  145. PROVIDE( _sp = . );
  146. } >ram AT>ram
  147. }