ddrinit.lds 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* Copyright (c) 2020 StarFiveTech, Inc */
  2. OUTPUT_ARCH( "riscv" )
  3. MEMORY
  4. {
  5. ram (rwx) : ORIGIN = 0x18080000, LENGTH = 192K
  6. }
  7. ENTRY( _start )
  8. PHDRS
  9. {
  10. text PT_LOAD;
  11. rodata PT_LOAD;
  12. data PT_LOAD;
  13. bss PT_LOAD;
  14. }
  15. SECTIONS
  16. {
  17. __stack_size = DEFINED(__stack_size) ? __stack_size : 4K;
  18. .init :
  19. {
  20. KEEP (*(SORT_NONE(.init)))
  21. } >ram AT>ram :text
  22. .text :
  23. {
  24. PROVIDE(_ftext = .);
  25. *(.text.unlikely .text.unlikely.*)
  26. *(.text.startup .text.startup.*)
  27. *(.text .text.*)
  28. *(.gnu.linkonce.t.*)
  29. PROVIDE (__etext = .);
  30. PROVIDE (_etext = .);
  31. PROVIDE (etext = .);
  32. }>ram AT>ram :text
  33. .rodata :
  34. {
  35. *(.rdata)
  36. *(.rodata .rodata.*)
  37. *(.gnu.linkonce.r.*)
  38. }>ram AT>ram :rodata
  39. .eh_frame :
  40. {
  41. *(.eh_frame)
  42. } >ram AT>ram :text
  43. .srodata :
  44. {
  45. *(.srodata.cst16)
  46. *(.srodata.cst8)
  47. *(.srodata.cst4)
  48. *(.srodata.cst2)
  49. *(.srodata.*)
  50. } >ram AT>ram :rodata
  51. .data :
  52. {
  53. *(.data .data.* .gnu.linkonce.d.*)
  54. . = ALIGN(8);
  55. PROVIDE( __global_pointer$ = . + 0x800 );
  56. *(.tohost) /* TODO: Support sections that aren't explicitly listed in this linker script */
  57. } >ram :data
  58. .sdata :
  59. {
  60. *(.sdata .sdata.* .gnu.linkonce.s.*)
  61. } >ram AT>ram :data
  62. PROVIDE(_data = ADDR(.data));
  63. PROVIDE(_data_lma = LOADADDR(.data));
  64. PROVIDE( _edata = . );
  65. . = ALIGN(8);
  66. PROVIDE( _bss_start = . );
  67. .bss :
  68. {
  69. *(.sbss*)
  70. *(.gnu.linkonce.sb.*)
  71. *(.bss .bss.*)
  72. *(.gnu.linkonce.b.*)
  73. *(COMMON)
  74. . = ALIGN(8);
  75. PROVIDE(_ebss = .);
  76. } >ram AT>ram :bss
  77. PROVIDE( _end = . );
  78. PROVIDE( _bss_end = . );
  79. /*
  80. * heap_stack_region_usable_end: (ORIGIN(ram) + LENGTH(ram))
  81. * heap_stack_min_size: 4096
  82. * heap_stack_max_size: 8292
  83. */
  84. PROVIDE(_sp = ALIGN(MIN((ORIGIN(ram) + LENGTH(ram)), _bss_end + 8292) - 7, 8));
  85. /*
  86. * Protect top of stack from heap, but this will not protect the heap from
  87. * stack overruns.
  88. */
  89. PROVIDE(_heap_end = _sp - 0x100);
  90. .stack :
  91. {
  92. ASSERT(_sp >= (_bss_end + 4096), "Error: No room left for the heap and stack");
  93. }
  94. }