link.lds 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* Entry Point */
  2. OUTPUT_ARCH( "riscv" )
  3. STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x1000;
  4. /* Specify the memory areas */
  5. MEMORY
  6. {
  7. m_vector (RX) : ORIGIN = 0x000FFF00, LENGTH = 0x00000100
  8. m_text (RX) : ORIGIN = 0x00000000, LENGTH = 0x000FFF00
  9. m_data (RW) : ORIGIN = 0x20000000, LENGTH = 0x00030000 - 0x1800
  10. }
  11. /* Define output sections */
  12. SECTIONS
  13. {
  14. .vectors : ALIGN(4)
  15. {
  16. __VECTOR_TABLE = .;
  17. KEEP(*(.vectors))
  18. } > m_vector
  19. /* The program code and other data goes into internal flash */
  20. .text :
  21. {
  22. . = ALIGN(4);
  23. KEEP(*(.startup))
  24. . = ALIGN(4);
  25. __user_vector = .;
  26. KEEP(*(user_vectors))
  27. *(.text) /* .text sections (code) */
  28. *(.text*) /* .text* sections (code) */
  29. *(.rodata) /* .rodata sections (constants, strings, etc.) */
  30. *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
  31. *(.eh_frame)
  32. *(.init)
  33. *(.fini)
  34. /* section information for finsh shell */
  35. . = ALIGN(4);
  36. __fsymtab_start = .;
  37. KEEP(*(FSymTab))
  38. __fsymtab_end = .;
  39. . = ALIGN(4);
  40. __vsymtab_start = .;
  41. KEEP(*(VSymTab))
  42. __vsymtab_end = .;
  43. . = ALIGN(4);
  44. /* section information for initial. */
  45. . = ALIGN(4);
  46. __rt_init_start = .;
  47. KEEP(*(SORT(.rti_fn*)))
  48. __rt_init_end = .;
  49. . = ALIGN(4);
  50. } > m_text
  51. .preinit_array :
  52. {
  53. PROVIDE_HIDDEN (__preinit_array_start = .);
  54. KEEP (*(.preinit_array*))
  55. PROVIDE_HIDDEN (__preinit_array_end = .);
  56. } > m_text
  57. .init_array :
  58. {
  59. PROVIDE_HIDDEN (__init_array_start = .);
  60. KEEP (*(SORT(.init_array.*)))
  61. KEEP (*(.init_array*))
  62. PROVIDE_HIDDEN (__init_array_end = .);
  63. } > m_text
  64. .fini_array :
  65. {
  66. PROVIDE_HIDDEN (__fini_array_start = .);
  67. KEEP (*(SORT(.fini_array.*)))
  68. KEEP (*(.fini_array*))
  69. PROVIDE_HIDDEN (__fini_array_end = .);
  70. } > m_text
  71. __etext = .; /* define a global symbol at end of code */
  72. __global_pointer = .; /* define a global symbol at end of code */
  73. __DATA_ROM = .; /* Symbol is used by startup for data initialization */
  74. .data : AT(__DATA_ROM)
  75. {
  76. . = ALIGN(4);
  77. __DATA_RAM = .;
  78. __data_start__ = .; /* create a global symbol at data start */
  79. *(.data) /* .data sections */
  80. *(.data*) /* .data* sections */
  81. *(.sdata .sdata.*)
  82. *(.heapsram*) /* This is only for the pulpino official test code. */
  83. __noncachedata_start__ = .; /* create a global symbol at ncache data start */
  84. *(NonCacheable)
  85. __noncachedata_end__ = .; /* define a global symbol at ncache data end */
  86. KEEP(*(.jcr*))
  87. . = ALIGN(4);
  88. __data_end__ = .; /* define a global symbol at data end */
  89. } > m_data
  90. __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
  91. text_end = ORIGIN(m_text) + LENGTH(m_text);
  92. ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
  93. _edata = .;
  94. .stack :
  95. {
  96. . = ALIGN(8);
  97. __StackLimit = .;
  98. . += STACK_SIZE;
  99. __StackTop = .;
  100. } > m_data
  101. /* Initializes stack on the end of block */
  102. PROVIDE(__stack = __StackTop);
  103. PROVIDE( __rt_rvstack = .);
  104. /* Uninitialized data section */
  105. .bss :
  106. {
  107. /* This is used by the startup in order to initialize the .bss section */
  108. . = ALIGN(4);
  109. __START_BSS = .;
  110. __bss_start__ = .;
  111. *(.bss)
  112. *(.bss*)
  113. *(.sbss)
  114. *(.sbss*)
  115. *(COMMON)
  116. . = ALIGN(4);
  117. __bss_end__ = .;
  118. __END_BSS = .;
  119. } > m_data
  120. /* End of uninitalized data segement */
  121. _end = .;
  122. PROVIDE(end = .);
  123. }