2
0

max80.ld 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /* -*- ld-script -*-
  2. *
  3. * Linker script for MAX80 firmware
  4. */
  5. #include "sys.h"
  6. OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv",
  7. "elf32-littleriscv")
  8. OUTPUT_ARCH(riscv)
  9. ENTRY(___reset)
  10. MEMORY
  11. {
  12. SRAM : org = SRAM_ADDR, len = SRAM_SIZE
  13. DRAM : org = SDRAM_ADDR, len = SDRAM_SIZE
  14. }
  15. SECTIONS
  16. {
  17. /*
  18. * Sections we do not need. This program cannot exit, so
  19. * fini/destructors are never needed. Exception handling
  20. * is not supported.
  21. */
  22. /DISCARD/ : {
  23. *(.note.GNU-stack)
  24. *(.gnu_debuglink)
  25. *(.gnu.lto_*)
  26. *(.discard)
  27. *(.discard.*)
  28. *(.dtors.*)
  29. *(.dtors)
  30. *(.fini_array)
  31. *(.fini_array.*)
  32. *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*)
  33. *(.eh_frame) *(.eh_frame.*)
  34. *(.gcc_except_table .gcc_except_table.*)
  35. *(.gnu_extab*)
  36. *(.exception_ranges*)
  37. *(.text.exit .text.exit.*)
  38. *crtbegin.o(*)
  39. *crt0.o(*)
  40. }
  41. PROVIDE (__executable_start = 0);
  42. /*
  43. * Make sure the output binary starts at address 0
  44. */
  45. .null 0 : {
  46. PROVIDE(___NULL = .);
  47. KEEP (*(SORT_NONE(.null)))
  48. }
  49. .init.reset _PC_RESET : ALIGN(4) {
  50. PROVIDE (___reset = .);
  51. KEEP (*(SORT_NONE(.init.reset)))
  52. }
  53. .init.irq _PC_IRQ : ALIGN(4) {
  54. PROVIDE (___irq = .);
  55. KEEP (*(SORT_NONE(.init.irq)))
  56. }
  57. /*
  58. * Put the short data sections in the zero page.
  59. * This means the initialized sections aren't contiguous, but
  60. * all memory is intialized during FPGA load anyway.
  61. */
  62. .sdata : ALIGN(4) {
  63. __SDATA_BEGIN__ = .;
  64. *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4)
  65. *(.srodata.cst2) *(.srodata .srodata.*)
  66. *(.sdata .sdata.* .gnu.linkonce.s.*)
  67. }
  68. .sdata2 : {
  69. *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
  70. }
  71. . = ALIGN(32);
  72. __BSS_START__ = .;
  73. PROVIDE (__bss_start = .);
  74. .sbss (NOLOAD) : ALIGN(4) {
  75. *(.dynsbss)
  76. *(.sbss .sbss.* .gnu.linkonce.sb.*)
  77. *(.scommon)
  78. }
  79. .sbss2 (NOLOAD) : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
  80. HIDDEN($assert_zero_page = ASSERT((. <= 2048), "zero page overflow"));
  81. .bss (NOLOAD) : {
  82. *(.dynbss)
  83. *(.bss .bss.* .gnu.linkonce.b.*)
  84. *(COMMON)
  85. }
  86. . = ALIGN(32);
  87. __BSS_END__ = .;
  88. __BSS_LEN__ = __BSS_END__ - __BSS_START__;
  89. . = ALIGN(4);
  90. __BSS_END__ = .;
  91. __BSS_LEN__ = __BSS_END__ - __BSS_START__;
  92. __global_pointer$ = 0;
  93. PROVIDE(___text = .);
  94. .init : ALIGN(4) {
  95. KEEP (*(SORT_NONE(.init)))
  96. }
  97. .text.hot : ALIGN(4) {
  98. *(.text.hot .text.hot.*)
  99. }
  100. .text : ALIGN(4) {
  101. *(.text.startup .text.startup.*)
  102. *(SORT(.text.sorted.*))
  103. *(.text .stub .text.* .gnu.linkonce.t.*)
  104. *(.text.unlikely .text.*_unlikely .text.unlikely.*)
  105. /* .gnu.warning sections are handled specially by elf.em. */
  106. *(.gnu.warning)
  107. }
  108. PROVIDE (__etext = .);
  109. PROVIDE (_etext = .);
  110. . = ALIGN(4);
  111. .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
  112. .rodata1 : { *(.rodata1) }
  113. /* Thread Local Storage sections */
  114. .tdata : {
  115. PROVIDE_HIDDEN (__tdata_start = .);
  116. *(.tdata .tdata.* .gnu.linkonce.td.*)
  117. }
  118. .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  119. .preinit_array : {
  120. PROVIDE_HIDDEN (__preinit_array_start = .);
  121. KEEP (*(.preinit_array))
  122. PROVIDE_HIDDEN (__preinit_array_end = .);
  123. }
  124. .init_array : {
  125. PROVIDE_HIDDEN (__init_array_start = .);
  126. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)
  127. SORT_BY_INIT_PRIORITY(.ctors.*)))
  128. KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  129. PROVIDE_HIDDEN (__init_array_end = .);
  130. }
  131. /* Are these necessary/supportable? */
  132. .jcr : { KEEP (*(.jcr)) }
  133. .data.rel.ro : {
  134. *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)
  135. }
  136. .data : {
  137. __DATA_BEGIN__ = .;
  138. *(.data .data.* .gnu.linkonce.d.*)
  139. SORT(CONSTRUCTORS)
  140. }
  141. .data1 : { *(.data1) }
  142. _edata = .;
  143. _end = .;
  144. .stack STACK_BOTTOM : {
  145. KEEP (*(.stack))
  146. }
  147. /* Sections in SDRAM */
  148. .dram.text : ALIGN(4) {
  149. *(.dram.text*)
  150. } >DRAM
  151. .dram.rodata : ALIGN(4) {
  152. *(.dram.rodata*)
  153. } >DRAM
  154. .dram.data : ALIGN(4) {
  155. *(.dram.data*)
  156. } >DRAM
  157. . = ALIGN(8);
  158. __dram_bss_start = .;
  159. .dram.bss (NOLOAD) : ALIGN(8) {
  160. *(.dram.bss*)
  161. } >DRAM
  162. . = ALIGN(8);
  163. __dram_bss_end = .;
  164. __dram_bss_len = __dram_bss_end - __dram_bss_start;
  165. /* Like BSS except no need to clear on boot */
  166. .dram.noinit (NOLOAD) : ALIGN(8) {
  167. *(.dram.noinit*)
  168. }
  169. /* No need to zero the heap */
  170. .heap (NOLOAD) : ALIGN(16) {
  171. *(.heap)
  172. } >DRAM
  173. __dram_end = .;
  174. }