jtagupd.ld 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /* -*- ld-script -*-
  2. *
  3. * Linker script for MAX80 flash bootloader firmware
  4. * There is no flash available here; DRAM may be used for bss alone,
  5. * and the flash data buffer must come first.
  6. */
  7. #define __ASSEMBLY__
  8. #define __LDSCRIPT__
  9. #include "sys.h"
  10. #include "iodevs.h"
  11. #include "iodeva.h"
  12. OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv",
  13. "elf32-littleriscv")
  14. OUTPUT_ARCH(riscv)
  15. ENTRY(___reset)
  16. MEMORY
  17. {
  18. SRAM : org = SRAM_ADDR, len = SRAM_SIZE
  19. DRAM : org = SDRAM_ADDR, len = SDRAM_SIZE
  20. DRAM2 : org = SDRAM_ADDR+SDRAM_SIZE, len = SDRAM_SIZE
  21. }
  22. SECTIONS
  23. {
  24. /* Debugging sections */
  25. /* Stabs debugging sections. */
  26. .stab 0 : { *(.stab) }
  27. .stabstr 0 : { *(.stabstr) }
  28. .stab.excl 0 : { *(.stab.excl) }
  29. .stab.exclstr 0 : { *(.stab.exclstr) }
  30. .stab.index 0 : { *(.stab.index) }
  31. .stab.indexstr 0 : { *(.stab.indexstr) }
  32. .comment 0 : { *(.comment) }
  33. .gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
  34. /* DWARF debug sections.
  35. Symbols in the DWARF debugging sections are relative to the beginning
  36. of the section so we begin them at 0. */
  37. /* DWARF 1. */
  38. .debug 0 : { *(.debug) }
  39. .line 0 : { *(.line) }
  40. /* GNU DWARF 1 extensions. */
  41. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  42. .debug_sfnames 0 : { *(.debug_sfnames) }
  43. /* DWARF 1.1 and DWARF 2. */
  44. .debug_aranges 0 : { *(.debug_aranges) }
  45. .debug_pubnames 0 : { *(.debug_pubnames) }
  46. /* DWARF 2. */
  47. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  48. .debug_abbrev 0 : { *(.debug_abbrev) }
  49. .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) }
  50. .debug_frame 0 : { *(.debug_frame) }
  51. .debug_str 0 : { *(.debug_str) }
  52. .debug_loc 0 : { *(.debug_loc) }
  53. .debug_macinfo 0 : { *(.debug_macinfo) }
  54. /* SGI/MIPS DWARF 2 extensions. */
  55. .debug_weaknames 0 : { *(.debug_weaknames) }
  56. .debug_funcnames 0 : { *(.debug_funcnames) }
  57. .debug_typenames 0 : { *(.debug_typenames) }
  58. .debug_varnames 0 : { *(.debug_varnames) }
  59. /* DWARF 3. */
  60. .debug_pubtypes 0 : { *(.debug_pubtypes) }
  61. .debug_ranges 0 : { *(.debug_ranges) }
  62. /* DWARF 5. */
  63. .debug_addr 0 : { *(.debug_addr) }
  64. .debug_line_str 0 : { *(.debug_line_str) }
  65. .debug_loclists 0 : { *(.debug_loclists) }
  66. .debug_macro 0 : { *(.debug_macro) }
  67. .debug_names 0 : { *(.debug_names) }
  68. .debug_rnglists 0 : { *(.debug_rnglists) }
  69. .debug_str_offsets 0 : { *(.debug_str_offsets) }
  70. .debug_sup 0 : { *(.debug_sup) }
  71. .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  72. .riscv.attributes 0 : { KEEP(*(.riscv.attributes)) }
  73. /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
  74. /*
  75. * Sections we do not need. This program cannot exit, so
  76. * fini/destructors are never needed. Exception handling
  77. * is not supported.
  78. */
  79. /DISCARD/ : {
  80. *(.note.GNU-stack)
  81. *(.gnu_debuglink)
  82. *(.gnu.lto_*)
  83. *(.discard)
  84. *(.discard.*)
  85. *(.dtors.*)
  86. *(.dtors)
  87. *(.fini_array)
  88. *(.fini_array.*)
  89. *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*)
  90. *(.eh_frame) *(.eh_frame.*)
  91. *(.gcc_except_table .gcc_except_table.*)
  92. *(.gnu_extab*)
  93. *(.exception_ranges*)
  94. *(.text.exit .text.exit.*)
  95. *crtbegin.o(*)
  96. *crt0.o(*)
  97. }
  98. . = 0;
  99. PROVIDE (__executable_start = .);
  100. /*
  101. * Make sure the output binary starts at address 0
  102. */
  103. .null 0 : {
  104. PROVIDE(___NULL = .);
  105. KEEP (*(SORT_NONE(.null)))
  106. }
  107. .init.reset _PC_RESET : ALIGN(4) {
  108. PROVIDE (___reset = .);
  109. KEEP (*(SORT_NONE(.init.reset)))
  110. }
  111. .init.irq _PC_IRQ : ALIGN(4) {
  112. PROVIDE (___irq = .);
  113. KEEP (*(SORT_NONE(.init.irq)))
  114. }
  115. /* .rwtext is in the zero page */
  116. .rwtext : ALIGN(4) {
  117. PROVIDE (__rwtext_start = .);
  118. *(.rwtext*)
  119. PROVIDE (__rwtext_end = .);
  120. }
  121. /*
  122. * Put the short data sections in the zero page.
  123. * This means the initialized sections aren't contiguous, but
  124. * all memory is intialized during FPGA load anyway.
  125. */
  126. . = ALIGN(4);
  127. __SDATA_BEGIN__ = .;
  128. .srodata : {
  129. *(.srodata*)
  130. }
  131. .sdata : {
  132. *(.sdata .sdata.* .gnu.linkonce.s.*)
  133. }
  134. .sdata2 : {
  135. *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
  136. }
  137. . = ALIGN(32);
  138. __BSS_START__ = .;
  139. PROVIDE (__bss_start = .);
  140. .sbss (NOLOAD) : ALIGN(4) {
  141. *(.dynsbss)
  142. *(.sbss .sbss.* .gnu.linkonce.sb.*)
  143. *(.scommon)
  144. }
  145. .sbss2 (NOLOAD) : {
  146. *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
  147. }
  148. HIDDEN($assert_zero_page = ASSERT((. <= 2048), "zero page overflow"));
  149. .bss (NOLOAD) : {
  150. *(.dynbss)
  151. *(.bss.*hot* .gnu.linkonce.b.*)
  152. *(COMMON)
  153. }
  154. . = ALIGN(32);
  155. __BSS_END__ = .;
  156. __BSS_LEN__ = __BSS_END__ - __BSS_START__;
  157. . = ALIGN(4);
  158. __BSS_END__ = .;
  159. __BSS_LEN__ = __BSS_END__ - __BSS_START__;
  160. __global_pointer$ = 0;
  161. PROVIDE(___text = .);
  162. .init : ALIGN(4) {
  163. KEEP (*(SORT_NONE(.init)))
  164. }
  165. .text : ALIGN(4) {
  166. *(.text.startup .text.startup.*)
  167. *(.text.hot .text.hot.*)
  168. KEEP(sbrk.o(.text))
  169. *(.gnu.linkonce.t.*)
  170. *(SORT(.text.sorted.*))
  171. *(.text .stub .text.*)
  172. *(.text.*unlikely*)
  173. *(.dram.text*)
  174. }
  175. PROVIDE (__etext = .);
  176. PROVIDE (_etext = .);
  177. . = ALIGN(4);
  178. .str : ALIGN(4) {
  179. *(.rodata*.hot.str*)
  180. *(.rodata*.str* .dram.rodata*.str*)
  181. }
  182. .rodata : {
  183. *(.rodata*.hot* .gnu.linkonce.r.*)
  184. *(.rodata* .dram.rodata*)
  185. }
  186. .data : {
  187. *(.dram.data* .data*)
  188. }
  189. /* Thread Local Storage sections */
  190. .tdata : {
  191. PROVIDE_HIDDEN (__tdata_start = .);
  192. *(.tdata .tdata.* .gnu.linkonce.td.*)
  193. }
  194. .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  195. .preinit_array : ALIGN(4) {
  196. PROVIDE_HIDDEN (__preinit_array_start = .);
  197. KEEP (*(.preinit_array))
  198. PROVIDE_HIDDEN (__preinit_array_end = .);
  199. }
  200. .init_array : ALIGN(4) {
  201. PROVIDE_HIDDEN (__init_array_start = .);
  202. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)
  203. SORT_BY_INIT_PRIORITY(.ctors.*)))
  204. KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  205. PROVIDE_HIDDEN (__init_array_end = .);
  206. } >DRAM
  207. /* Are these necessary/supportable? */
  208. .jcr : { KEEP (*(.jcr)) }
  209. .data.rel.ro : {
  210. *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)
  211. }
  212. .data : {
  213. __DATA_BEGIN__ = .;
  214. *(.data .data.* .gnu.linkonce.d.*)
  215. SORT(CONSTRUCTORS)
  216. }
  217. .data1 : { *(.data1) }
  218. _edata = .;
  219. _end = .;
  220. /* Patched in during FPGA compile, must immediately follow _end */
  221. .datestamp (NOLOAD) : { KEEP(*(.datestamp)) }
  222. HIDDEN($sram_size_assert = ASSERT(. <= STACK_BOTTOM, "SRAM overflow"));
  223. . = STACK_BOTTOM;
  224. .stack (NOLOAD) : {
  225. KEEP (*(.stack))
  226. }
  227. /* Sections in SDRAM */
  228. . = SDRAM_ADDR;
  229. .jtag_flash_buffer (NOLOAD) : {
  230. *(.jtag_flash_buffer)
  231. } >DRAM
  232. __dram_bss_start = .;
  233. .dram.bss (NOLOAD) : ALIGN(8) {
  234. *(.dram.bss* .bss*)
  235. } >DRAM
  236. . = ALIGN(8);
  237. __dram_bss_end = .;
  238. __dram_bss_len = __dram_bss_end - __dram_bss_start;
  239. /* Like BSS except no need to clear on boot */
  240. .dram.noinit (NOLOAD) : ALIGN(8) {
  241. *(.dram.noinit*)
  242. } >DRAM
  243. /* No need to zero the heap */
  244. .heap (NOLOAD) : ALIGN(16) {
  245. *(.heap*)
  246. } >DRAM
  247. __dram_end = .;
  248. /* Dummy section containing I/O device symbols */
  249. . = XDEV_ADDR_BASE;
  250. .iodevs (NOLOAD) : {
  251. . = .; /* Force output */
  252. KEEP(*(.iodevs))
  253. }
  254. /* Catch missing sections */
  255. . = __dram_end;
  256. __junk_start = .;
  257. .junk : {
  258. *(*)
  259. }
  260. __junk_end = .;
  261. /* HIDDEN($assert_no_junk = ASSERT(__junk_end == __junk_start, "unknown sections present")); */
  262. }