flash.lds 4.1 KB

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