fomu.ld 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. OUTPUT_FORMAT("elf32-littleriscv")
  2. ENTRY(_start)
  3. __DYNAMIC = 0;
  4. MEMORY {
  5. csr : ORIGIN = 0x60000000, LENGTH = 0x01000000
  6. vexriscv_debug : ORIGIN = 0xf00f0000, LENGTH = 0x00000100
  7. ram : ORIGIN = 0x10000000, LENGTH = 0x00020000
  8. rom : ORIGIN = 0x20040000, LENGTH = 0x00200000 - 0x40000
  9. }
  10. /* The stack size used by the application. NOTE: you need to adjust according to your application. */
  11. STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
  12. /* Section Definitions */
  13. SECTIONS
  14. {
  15. .text :
  16. {
  17. . = ALIGN(4);
  18. _ftext = .;
  19. *(.text.start)
  20. *(.text .text.* .gnu.linkonce.t.*)
  21. *(.glue_7t) *(.glue_7)
  22. *(.rodata .rodata* .gnu.linkonce.r.*)
  23. /* Support C constructors, and C destructors in both user code
  24. and the C library. This also provides support for C++ code. */
  25. . = ALIGN(4);
  26. KEEP(*(.init))
  27. . = ALIGN(4);
  28. __preinit_array_start = .;
  29. KEEP (*(.preinit_array))
  30. __preinit_array_end = .;
  31. . = ALIGN(4);
  32. __init_array_start = .;
  33. KEEP (*(SORT(.init_array.*)))
  34. KEEP (*(.init_array))
  35. __init_array_end = .;
  36. . = ALIGN(4);
  37. KEEP (*crtbegin.o(.ctors))
  38. KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
  39. KEEP (*(SORT(.ctors.*)))
  40. KEEP (*crtend.o(.ctors))
  41. . = ALIGN(4);
  42. KEEP(*(.fini))
  43. . = ALIGN(4);
  44. __fini_array_start = .;
  45. KEEP (*(.fini_array))
  46. KEEP (*(SORT(.fini_array.*)))
  47. __fini_array_end = .;
  48. KEEP (*crtbegin.o(.dtors))
  49. KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
  50. KEEP (*(SORT(.dtors.*)))
  51. KEEP (*crtend.o(.dtors))
  52. } > rom
  53. . = ALIGN(4);
  54. _etext = .; /* End of text section */
  55. .relocate : AT (_etext)
  56. {
  57. . = ALIGN(4);
  58. _srelocate = .;
  59. *(.ramfunc .ramfunc.*);
  60. *(.data .data.*);
  61. . = ALIGN(4);
  62. _erelocate = .;
  63. } > ram
  64. /* .bss section which is used for uninitialized data */
  65. .bss (NOLOAD) :
  66. {
  67. . = ALIGN(4);
  68. _sbss = . ;
  69. _szero = .;
  70. *(.bss .bss.*)
  71. *(.sbss .sbss.*)
  72. *(COMMON)
  73. . = ALIGN(4);
  74. _ebss = . ;
  75. _ezero = .;
  76. end = .;
  77. } > ram
  78. /* stack section */
  79. .stack (NOLOAD):
  80. {
  81. . = ALIGN(8);
  82. _sstack = .;
  83. . = . + STACK_SIZE;
  84. . = ALIGN(8);
  85. _estack = .;
  86. } > ram
  87. . = ALIGN(4);
  88. _end = . ;
  89. }