jtagupd.ld 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. EXTERN(_NULL)
  17. EXTERN(_reset)
  18. EXTERN(_irq)
  19. MEMORY
  20. {
  21. SRAM : org = SRAM_ADDR, len = SRAM_SIZE
  22. DRAM : org = SDRAM_ADDR, len = SDRAM_SIZE
  23. DRAM2 : org = SDRAM_ADDR+SDRAM_SIZE, len = SDRAM_SIZE
  24. }
  25. SECTIONS
  26. {
  27. /* Debugging sections */
  28. /* Stabs debugging sections. */
  29. .stab 0 : { *(.stab) }
  30. .stabstr 0 : { *(.stabstr) }
  31. .stab.excl 0 : { *(.stab.excl) }
  32. .stab.exclstr 0 : { *(.stab.exclstr) }
  33. .stab.index 0 : { *(.stab.index) }
  34. .stab.indexstr 0 : { *(.stab.indexstr) }
  35. .comment 0 : { *(.comment) }
  36. .gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
  37. /* DWARF debug sections.
  38. Symbols in the DWARF debugging sections are relative to the beginning
  39. of the section so we begin them at 0. */
  40. /* DWARF 1. */
  41. .debug 0 : { *(.debug) }
  42. .line 0 : { *(.line) }
  43. /* GNU DWARF 1 extensions. */
  44. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  45. .debug_sfnames 0 : { *(.debug_sfnames) }
  46. /* DWARF 1.1 and DWARF 2. */
  47. .debug_aranges 0 : { *(.debug_aranges) }
  48. .debug_pubnames 0 : { *(.debug_pubnames) }
  49. /* DWARF 2. */
  50. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  51. .debug_abbrev 0 : { *(.debug_abbrev) }
  52. .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) }
  53. .debug_frame 0 : { *(.debug_frame) }
  54. .debug_str 0 : { *(.debug_str) }
  55. .debug_loc 0 : { *(.debug_loc) }
  56. .debug_macinfo 0 : { *(.debug_macinfo) }
  57. /* SGI/MIPS DWARF 2 extensions. */
  58. .debug_weaknames 0 : { *(.debug_weaknames) }
  59. .debug_funcnames 0 : { *(.debug_funcnames) }
  60. .debug_typenames 0 : { *(.debug_typenames) }
  61. .debug_varnames 0 : { *(.debug_varnames) }
  62. /* DWARF 3. */
  63. .debug_pubtypes 0 : { *(.debug_pubtypes) }
  64. .debug_ranges 0 : { *(.debug_ranges) }
  65. /* DWARF 5. */
  66. .debug_addr 0 : { *(.debug_addr) }
  67. .debug_line_str 0 : { *(.debug_line_str) }
  68. .debug_loclists 0 : { *(.debug_loclists) }
  69. .debug_macro 0 : { *(.debug_macro) }
  70. .debug_names 0 : { *(.debug_names) }
  71. .debug_rnglists 0 : { *(.debug_rnglists) }
  72. .debug_str_offsets 0 : { *(.debug_str_offsets) }
  73. .debug_sup 0 : { *(.debug_sup) }
  74. .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  75. .riscv.attributes 0 : { KEEP(*(.riscv.attributes)) }
  76. /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
  77. /*
  78. * Sections we do not need. This program cannot exit, so
  79. * fini/destructors are never needed. Exception handling
  80. * is not supported.
  81. */
  82. /DISCARD/ : {
  83. *(.note.GNU-stack)
  84. *(.gnu_debuglink)
  85. *(.gnu.lto_*)
  86. *(.discard)
  87. *(.discard.*)
  88. *(.dtors.*)
  89. *(.dtors)
  90. *(.fini_array)
  91. *(.fini_array.*)
  92. *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*)
  93. *(.eh_frame) *(.eh_frame.*)
  94. *(.gcc_except_table .gcc_except_table.*)
  95. *(.gnu_extab*)
  96. *(.exception_ranges*)
  97. *(.text.exit .text.exit.*)
  98. *crtbegin.o(*)
  99. *crt0.o(*)
  100. }
  101. . = 0;
  102. PROVIDE (__executable_start = .);
  103. /*
  104. * Make sure the output binary starts at address 0
  105. */
  106. .null 0 : {
  107. PROVIDE(___NULL = .);
  108. KEEP (*(SORT_NONE(.null)))
  109. }
  110. .init.reset _PC_RESET : ALIGN(4) {
  111. PROVIDE (___reset = .);
  112. KEEP (*(SORT_NONE(.init.reset)))
  113. }
  114. .init.irq _PC_IRQ : ALIGN(4) {
  115. PROVIDE (___irq = .);
  116. KEEP (*(SORT_NONE(.init.irq)))
  117. }
  118. /* .rwtext is in the zero page */
  119. .rwtext : ALIGN(4) {
  120. PROVIDE (__rwtext_start = .);
  121. *(.rwtext*)
  122. PROVIDE (__rwtext_end = .);
  123. }
  124. /*
  125. * Put the short data sections in the zero page.
  126. * This means the initialized sections aren't contiguous, but
  127. * all memory is intialized during FPGA load anyway.
  128. */
  129. . = ALIGN(4);
  130. __SDATA_BEGIN__ = .;
  131. .srodata : {
  132. *(.srodata*)
  133. }
  134. .sdata : {
  135. *(.sdata .sdata.* .gnu.linkonce.s.*)
  136. }
  137. .sdata2 : {
  138. *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
  139. }
  140. . = ALIGN(32);
  141. __BSS_START__ = .;
  142. PROVIDE (__bss_start = .);
  143. .sbss (NOLOAD) : ALIGN(4) {
  144. *(.dynsbss)
  145. *(.sbss .sbss.* .gnu.linkonce.sb.*)
  146. *(.scommon)
  147. }
  148. .sbss2 (NOLOAD) : {
  149. *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
  150. }
  151. HIDDEN($assert_zero_page = ASSERT((. <= 2048), "zero page overflow"));
  152. .bss (NOLOAD) : {
  153. *(.dynbss)
  154. *(.bss.*hot* .gnu.linkonce.b.*)
  155. *(COMMON)
  156. }
  157. . = ALIGN(32);
  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. /* This really should be pointed by .dram.esplink.head ... */
  230. .jtag_flash_buffer (NOLOAD) : {
  231. *(.jtag_flash_buffer)
  232. } >DRAM
  233. /* Always first in DRAM for remote DMA to find fixed addresses */
  234. . = ALIGN(4096);
  235. .dram.esplink (NOLOAD) : ALIGN(4096) {
  236. __esplink_start = .;
  237. KEEP(*(SORT_NONE(.dram.esplink.head)));
  238. *(.dram.esplink .dram.esplink.*);
  239. . = ALIGN(16);
  240. __esplink_end = .;
  241. } >DRAM
  242. /* There is no dram init ... there can't be! */
  243. . = ALIGN(8);
  244. __dram_init_start = .;
  245. __dram_init_end = .;
  246. __dram_init_len = 0;
  247. . = ALIGN(8);
  248. __dram_bss_start = .;
  249. .dram.bss (NOLOAD) : ALIGN(8) {
  250. *(.dram.bss* .bss*)
  251. } >DRAM
  252. . = ALIGN(8);
  253. __dram_bss_end = .;
  254. __dram_bss_len = __dram_bss_end - __dram_bss_start;
  255. /* Like BSS except no need to clear on boot */
  256. .dram.noinit (NOLOAD) : ALIGN(8) {
  257. *(.dram.noinit*)
  258. } >DRAM
  259. . = ALIGN(32);
  260. PROVIDE(__heap_start = .);
  261. . = SDRAM_ADDR + SDRAM_SIZE;
  262. PROVIDE(__heap_end = .);
  263. __dram_end = .;
  264. /* Catch missing sections */
  265. . = __dram_end;
  266. __junk_start = .;
  267. .junk : {
  268. *(*)
  269. }
  270. __junk_end = .;
  271. HIDDEN($assert_no_junk = ASSERT(__junk_end == __junk_start, "unknown sections present"));
  272. }