Guest User

Untitled

a guest
Nov 29th, 2021
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.64 KB | None | 0 0
  1. /* GD32VF103C8 */
  2. MEMORY
  3. {
  4. FLASH : ORIGIN = 0x08000000, LENGTH = 64k
  5. RAM : ORIGIN = 0x20000000, LENGTH = 20k
  6. }
  7.  
  8. REGION_ALIAS("REGION_TEXT", FLASH);
  9. REGION_ALIAS("REGION_RODATA", FLASH);
  10. REGION_ALIAS("REGION_DATA", RAM);
  11. REGION_ALIAS("REGION_BSS", RAM);
  12. REGION_ALIAS("REGION_HEAP", RAM);
  13. REGION_ALIAS("REGION_STACK", RAM);
  14.  
  15. PROVIDE(_stext = ORIGIN(REGION_TEXT));
  16. PROVIDE(_stack_start = ORIGIN(REGION_STACK) + LENGTH(REGION_STACK));
  17. PROVIDE(_max_hart_id = 0);
  18. PROVIDE(_hart_stack_size = 2K);
  19. PROVIDE(_heap_size = 0);
  20.  
  21. PROVIDE(UserSoft = DefaultHandler);
  22. PROVIDE(SupervisorSoft = DefaultHandler);
  23. PROVIDE(MachineSoft = DefaultHandler);
  24. PROVIDE(UserTimer = DefaultHandler);
  25. PROVIDE(SupervisorTimer = DefaultHandler);
  26. PROVIDE(MachineTimer = DefaultHandler);
  27. PROVIDE(UserExternal = DefaultHandler);
  28. PROVIDE(SupervisorExternal = DefaultHandler);
  29. PROVIDE(MachineExternal = DefaultHandler);
  30.  
  31. PROVIDE(DefaultHandler = DefaultInterruptHandler);
  32. PROVIDE(ExceptionHandler = DefaultExceptionHandler);
  33.  
  34. /* # Pre-initialization function */
  35. /* If the user overrides this using the `#[pre_init]` attribute or by creating a `__pre_init` function,
  36. then the function this points to will be called before the RAM is initialized. */
  37. PROVIDE(__pre_init = default_pre_init);
  38.  
  39. /* A PAC/HAL defined routine that should initialize custom interrupt controller if needed. */
  40. PROVIDE(_setup_interrupts = default_setup_interrupts);
  41.  
  42. /* # Multi-processing hook function
  43. fn _mp_hook() -> bool;
  44.  
  45. This function is called from all the harts and must return true only for one hart,
  46. which will perform memory initialization. For other harts it must return false
  47. and implement wake-up in platform-dependent way (e.g. after waiting for a user interrupt).
  48. */
  49. PROVIDE(_mp_hook = default_mp_hook);
  50.  
  51. /* # Start trap function override
  52. By default uses the riscv crates default trap handler
  53. but by providing the `_start_trap` symbol external crates can override.
  54. */
  55. PROVIDE(_start_trap = default_start_trap);
  56.  
  57. ENTRY(_start)
  58.  
  59. SECTIONS
  60. {
  61. . = ABSOLUTE(_stext);
  62. .text _stext :
  63. {
  64. /* Put reset handler first in .text section so it ends up as the entry */
  65. /* point of the program. */
  66. KEEP(*(.init));
  67. KEEP(*(.init.rust));
  68. . = ALIGN(4);
  69. *(.trap);
  70. *(.trap.rust);
  71.  
  72. *(.text)
  73. *(.text.*)
  74. } > REGION_TEXT
  75.  
  76. .rodata : ALIGN(4)
  77. {
  78. *(.srodata .srodata.*);
  79. *(.rodata .rodata.*);
  80.  
  81. /* 4-byte align the end (VMA) of this section.
  82. This is required by LLD to ensure the LMA of the following .data
  83. section will have the correct alignment. */
  84. . = ALIGN(4);
  85. } > REGION_RODATA
  86.  
  87. .data : ALIGN(4)
  88. {
  89. _sidata = LOADADDR(.data);
  90. _sdata = .;
  91. /* Must be called __global_pointer$ for linker relaxations to work. */
  92. PROVIDE(__global_pointer$ = . + 0x800);
  93. *(.sdata .sdata.* .sdata2 .sdata2.*);
  94. *(.data .data.*);
  95. . = ALIGN(4);
  96. _edata = .;
  97. } > REGION_DATA AT > REGION_RODATA
  98.  
  99. .bss (NOLOAD) :
  100. {
  101. _sbss = .;
  102. *(.sbss .sbss.* .bss .bss.*);
  103. . = ALIGN(4);
  104. _ebss = .;
  105. } > REGION_BSS
  106.  
  107. /* fictitious region that represents the memory available for the heap */
  108. .heap (NOLOAD) :
  109. {
  110. _sheap = .;
  111. . += _heap_size;
  112. . = ALIGN(4);
  113. _eheap = .;
  114. } > REGION_HEAP
  115.  
  116. /* fictitious region that represents the memory available for the stack */
  117. .stack (NOLOAD) :
  118. {
  119. _estack = .;
  120. . = ABSOLUTE(_stack_start);
  121. _sstack = .;
  122. } > REGION_STACK
  123.  
  124. /* fake output .got section */
  125. /* Dynamic relocations are unsupported. This section is only used to detect
  126. relocatable code in the input files and raise an error if relocatable code
  127. is found */
  128. .got (INFO) :
  129. {
  130. KEEP(*(.got .got.*));
  131. }
  132.  
  133. .eh_frame (INFO) : { KEEP(*(.eh_frame)) }
  134. .eh_frame_hdr (INFO) : { *(.eh_frame_hdr) }
  135.  
  136. /* here was some _end related magic */
  137.  
  138. /* Stabs debugging sections. */
  139. .stab 0 : { *(.stab) }
  140. .stabstr 0 : { *(.stabstr) }
  141. .stab.excl 0 : { *(.stab.excl) }
  142. .stab.exclstr 0 : { *(.stab.exclstr) }
  143. .stab.index 0 : { *(.stab.index) }
  144. .stab.indexstr 0 : { *(.stab.indexstr) }
  145. .comment 0 : { *(.comment) }
  146. /* DWARF debug sections.
  147. Symbols in the DWARF debugging sections are relative to the beginning
  148. of the section so we begin them at 0. */
  149. /* DWARF 1 */
  150. .debug 0 : { *(.debug) }
  151. .line 0 : { *(.line) }
  152. /* GNU DWARF 1 extensions */
  153. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  154. .debug_sfnames 0 : { *(.debug_sfnames) }
  155. /* DWARF 1.1 and DWARF 2 */
  156. .debug_aranges 0 : { *(.debug_aranges) }
  157. .debug_pubnames 0 : { *(.debug_pubnames) }
  158. /* DWARF 2 */
  159. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  160. .debug_abbrev 0 : { *(.debug_abbrev) }
  161. .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
  162. .debug_frame 0 : { *(.debug_frame) }
  163. .debug_str 0 : { *(.debug_str) }
  164. .debug_loc 0 : { *(.debug_loc) }
  165. .debug_macinfo 0 : { *(.debug_macinfo) }
  166. /* SGI/MIPS DWARF 2 extensions */
  167. .debug_weaknames 0 : { *(.debug_weaknames) }
  168. .debug_funcnames 0 : { *(.debug_funcnames) }
  169. .debug_typenames 0 : { *(.debug_typenames) }
  170. .debug_varnames 0 : { *(.debug_varnames) }
  171. /* DWARF 3 */
  172. .debug_pubtypes 0 : { *(.debug_pubtypes) }
  173. .debug_ranges 0 : { *(.debug_ranges) }
  174. /* DWARF Extension. */
  175. .debug_macro 0 : { *(.debug_macro) }
  176. .debug_addr 0 : { *(.debug_addr) }
  177. .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  178. /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
  179. }
  180.  
  181. /* Do not exceed this mark in the error messages above | */
  182. ASSERT(ORIGIN(REGION_TEXT) % 4 == 0, "
  183. ERROR(riscv-rt): the start of the REGION_TEXT must be 4-byte aligned");
  184.  
  185. ASSERT(ORIGIN(REGION_RODATA) % 4 == 0, "
  186. ERROR(riscv-rt): the start of the REGION_RODATA must be 4-byte aligned");
  187.  
  188. ASSERT(ORIGIN(REGION_DATA) % 4 == 0, "
  189. ERROR(riscv-rt): the start of the REGION_DATA must be 4-byte aligned");
  190.  
  191. ASSERT(ORIGIN(REGION_HEAP) % 4 == 0, "
  192. ERROR(riscv-rt): the start of the REGION_HEAP must be 4-byte aligned");
  193.  
  194. ASSERT(ORIGIN(REGION_TEXT) % 4 == 0, "
  195. ERROR(riscv-rt): the start of the REGION_TEXT must be 4-byte aligned");
  196.  
  197. ASSERT(ORIGIN(REGION_STACK) % 4 == 0, "
  198. ERROR(riscv-rt): the start of the REGION_STACK must be 4-byte aligned");
  199.  
  200. ASSERT(_stext % 4 == 0, "
  201. ERROR(riscv-rt): `_stext` must be 4-byte aligned");
  202.  
  203. ASSERT(_sdata % 4 == 0 && _edata % 4 == 0, "
  204. BUG(riscv-rt): .data is not 4-byte aligned");
  205.  
  206. ASSERT(_sidata % 4 == 0, "
  207. BUG(riscv-rt): the LMA of .data is not 4-byte aligned");
  208.  
  209. ASSERT(_sbss % 4 == 0 && _ebss % 4 == 0, "
  210. BUG(riscv-rt): .bss is not 4-byte aligned");
  211.  
  212. ASSERT(_sheap % 4 == 0, "
  213. BUG(riscv-rt): start of .heap is not 4-byte aligned");
  214.  
  215. ASSERT(_stext + SIZEOF(.text) < ORIGIN(REGION_TEXT) + LENGTH(REGION_TEXT), "
  216. ERROR(riscv-rt): The .text section must be placed inside the REGION_TEXT region.
  217. Set _stext to an address smaller than 'ORIGIN(REGION_TEXT) + LENGTH(REGION_TEXT)'");
  218.  
  219. ASSERT(SIZEOF(.stack) > (_max_hart_id + 1) * _hart_stack_size, "
  220. ERROR(riscv-rt): .stack section is too small for allocating stacks for all the harts.
  221. Consider changing `_max_hart_id` or `_hart_stack_size`.");
  222.  
  223. /*
  224. ASSERT(SIZEOF(.got) == 0, "
  225. .got section detected in the input files. Dynamic relocations are not
  226. supported. If you are linking to C code compiled using the `gcc` crate
  227. then modify your build script to compile the C code _without_ the
  228. -fPIC flag. See the documentation of the `gcc::Config.fpic` method for
  229. details.");
  230. */
  231.  
  232. /* Do not exceed this mark in the error messages above | */
  233.  
  234.  
Advertisement
Add Comment
Please, Sign In to add comment