max80.ld 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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(_start)
  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. *crtbegin.o(*)
  38. *crt0.o(*)
  39. }
  40. PROVIDE (__executable_start = _PC_RESET);
  41. .init.reset _PC_RESET : ALIGN(4) {
  42. PROVIDE (___reset = .);
  43. KEEP (*(SORT_NONE(.init.reset)))
  44. } >SRAM
  45. .init.irq _PC_IRQ : ALIGN(4) {
  46. PROVIDE (___irq = .);
  47. KEEP (*(SORT_NONE(.init.irq)))
  48. }
  49. /*
  50. * Put the short data sections in the zero page.
  51. * This means the initialized sections aren't contiguous, but
  52. * all memory is intialized during FPGA load anyway.
  53. */
  54. .sdata : ALIGN(4) {
  55. __SDATA_BEGIN__ = .;
  56. *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4)
  57. *(.srodata.cst2) *(.srodata .srodata.*)
  58. *(.sdata .sdata.* .gnu.linkonce.s.*)
  59. }
  60. .sdata2 : {
  61. *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
  62. }
  63. . = ALIGN(32);
  64. __BSS_START__ = .;
  65. PROVIDE (__bss_start = .);
  66. .sbss : ALIGN(4) {
  67. *(.dynsbss)
  68. *(.sbss .sbss.* .gnu.linkonce.sb.*)
  69. *(.scommon)
  70. }
  71. .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
  72. HIDDEN($assert_zero_page = ASSERT((. <= 2048), "zero page overflow"));
  73. .bss : {
  74. *(.dynbss)
  75. *(.bss .bss.* .gnu.linkonce.b.*)
  76. *(COMMON)
  77. }
  78. . = ALIGN(32);
  79. __BSS_END__ = .;
  80. __BSS_LEN__ = __BSS_END__ - __BSS_START__;
  81. . = ALIGN(4);
  82. __BSS_END__ = .;
  83. __BSS_LEN__ = __BSS_END__ - __BSS_START__;
  84. __global_pointer$ = 0;
  85. .text : ALIGN(4) {
  86. PROVIDE(___text = .);
  87. KEEP (*(SORT_NONE(.init)))
  88. *(.text.unlikely .text.*_unlikely .text.unlikely.*)
  89. *(.text.exit .text.exit.*)
  90. *(.text.startup .text.startup.*)
  91. *(.text.hot .text.hot.*)
  92. *(SORT(.text.sorted.*))
  93. *(.text .stub .text.* .gnu.linkonce.t.*)
  94. /* .gnu.warning sections are handled specially by elf.em. */
  95. *(.gnu.warning)
  96. }
  97. PROVIDE (__etext = .);
  98. PROVIDE (_etext = .);
  99. . = ALIGN(4);
  100. .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
  101. .rodata1 : { *(.rodata1) }
  102. /* Thread Local Storage sections */
  103. .tdata : {
  104. PROVIDE_HIDDEN (__tdata_start = .);
  105. *(.tdata .tdata.* .gnu.linkonce.td.*)
  106. }
  107. .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  108. .preinit_array : {
  109. PROVIDE_HIDDEN (__preinit_array_start = .);
  110. KEEP (*(.preinit_array))
  111. PROVIDE_HIDDEN (__preinit_array_end = .);
  112. }
  113. .init_array : {
  114. PROVIDE_HIDDEN (__init_array_start = .);
  115. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)
  116. SORT_BY_INIT_PRIORITY(.ctors.*)))
  117. KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  118. PROVIDE_HIDDEN (__init_array_end = .);
  119. }
  120. /* Are these necessary/supportable? */
  121. .jcr : { KEEP (*(.jcr)) }
  122. .data.rel.ro : {
  123. *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)
  124. }
  125. .data : {
  126. __DATA_BEGIN__ = .;
  127. *(.data .data.* .gnu.linkonce.d.*)
  128. SORT(CONSTRUCTORS)
  129. }
  130. .data1 : { *(.data1) }
  131. _edata = .;
  132. _end = .;
  133. .stack STACK_BOTTOM : {
  134. KEEP (*(.stack))
  135. }
  136. /* Sections in SDRAM */
  137. .dram.text : ALIGN(4) {
  138. *(.dram.text*)
  139. } >DRAM
  140. .dram.rodata : ALIGN(4) {
  141. *(.dram.rodata*)
  142. } >DRAM
  143. .dram.data : ALIGN(4) {
  144. *(.dram.data*)
  145. } >DRAM
  146. . = ALIGN(8);
  147. __dram_bss_start = .;
  148. .dram.bss (NOLOAD) : ALIGN(8) {
  149. *(.dram.bss*)
  150. } >DRAM
  151. . = ALIGN(8);
  152. __dram_bss_end = .;
  153. __dram_bss_len = __dram_bss_end - __dram_bss_start;
  154. /* No need to zero the heap */
  155. .heap (NOLOAD) : ALIGN(8) {
  156. *(.heap)
  157. } >DRAM
  158. __dram_end = .;
  159. }