gcc.ld 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* Linker script to configure memory regions.
  2. * Need modifying for a specific board.
  3. * FLASH.ORIGIN: starting address of flash
  4. * FLASH.LENGTH: length of flash
  5. * RAM.ORIGIN: starting address of RAM bank 0
  6. * RAM.LENGTH: length of RAM bank 0
  7. */
  8. MEMORY
  9. {
  10. FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 /* 512K */
  11. RAM (rwx) : ORIGIN = 0x10010500, LENGTH = 0x3b00 /* 64K */
  12. }
  13. /* Linker script to place sections and symbol values. Should be used together
  14. * with other linker script that defines memory regions FLASH and RAM.
  15. * It references following symbols, which must be defined in code:
  16. * Reset_Handler : Entry of reset handler
  17. *
  18. * It defines following symbols, which code can use without definition:
  19. * __exidx_start
  20. * __exidx_end
  21. * __copy_table_start__
  22. * __copy_table_end__
  23. * __zero_table_start__
  24. * __zero_table_end__
  25. * __etext
  26. * __data_start__
  27. * __preinit_array_start
  28. * __preinit_array_end
  29. * __init_array_start
  30. * __init_array_end
  31. * __fini_array_start
  32. * __fini_array_end
  33. * __data_end__
  34. * __bss_start__
  35. * __bss_end__
  36. * __end__
  37. * end
  38. * __HeapLimit
  39. * __StackLimit
  40. * __StackTop
  41. * __stack
  42. */
  43. ENTRY(Reset_Handler)
  44. SECTIONS
  45. {
  46. .text :
  47. {
  48. KEEP(*(.isr_vector))
  49. *(.text*)
  50. KEEP(*(.init))
  51. KEEP(*(.fini))
  52. /* .ctors */
  53. *crtbegin.o(.ctors)
  54. *crtbegin?.o(.ctors)
  55. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  56. *(SORT(.ctors.*))
  57. *(.ctors)
  58. /* .dtors */
  59. *crtbegin.o(.dtors)
  60. *crtbegin?.o(.dtors)
  61. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  62. *(SORT(.dtors.*))
  63. *(.dtors)
  64. *(.rodata*)
  65. KEEP(*(.eh_frame*))
  66. } > FLASH
  67. .ARM.extab :
  68. {
  69. *(.ARM.extab* .gnu.linkonce.armextab.*)
  70. } > FLASH
  71. __exidx_start = .;
  72. .ARM.exidx :
  73. {
  74. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  75. } > FLASH
  76. __exidx_end = .;
  77. __etext = .;
  78. .data : AT (__etext)
  79. {
  80. __data_start__ = .;
  81. *(vtable)
  82. *(.data*)
  83. . = ALIGN(4);
  84. /* preinit data */
  85. PROVIDE_HIDDEN (__preinit_array_start = .);
  86. KEEP(*(.preinit_array))
  87. PROVIDE_HIDDEN (__preinit_array_end = .);
  88. . = ALIGN(4);
  89. /* init data */
  90. PROVIDE_HIDDEN (__init_array_start = .);
  91. KEEP(*(SORT(.init_array.*)))
  92. KEEP(*(.init_array))
  93. PROVIDE_HIDDEN (__init_array_end = .);
  94. . = ALIGN(4);
  95. /* finit data */
  96. PROVIDE_HIDDEN (__fini_array_start = .);
  97. KEEP(*(SORT(.fini_array.*)))
  98. KEEP(*(.fini_array))
  99. PROVIDE_HIDDEN (__fini_array_end = .);
  100. KEEP(*(.jcr*))
  101. . = ALIGN(4);
  102. /* All data end */
  103. __data_end__ = .;
  104. } > RAM
  105. .bss :
  106. {
  107. . = ALIGN(4);
  108. __bss_start__ = .;
  109. *(.bss*)
  110. *(COMMON)
  111. . = ALIGN(4);
  112. __bss_end__ = .;
  113. } > RAM
  114. .heap (COPY):
  115. {
  116. __end__ = .;
  117. PROVIDE(end = .);
  118. *(.heap*)
  119. __HeapLimit = .;
  120. } > RAM
  121. /* .stack_dummy section doesn't contains any symbols. It is only
  122. * used for linker to calculate size of stack sections, and assign
  123. * values to stack symbols later */
  124. .stack_dummy (COPY):
  125. {
  126. *(.stack*)
  127. } > RAM
  128. /* Set stack top to end of RAM, and stack limit move down by
  129. * size of stack_dummy section */
  130. __StackTop = ORIGIN(RAM) + LENGTH(RAM);
  131. __StackLimit = __StackTop - SIZEOF(.stack_dummy);
  132. PROVIDE(__stack = __StackTop);
  133. /* Check if data + heap + stack exceeds RAM limit */
  134. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  135. }