common.ld 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /*
  14. this file is included by the board specific ldscript.ld which is
  15. generated from hwdef.dat
  16. */
  17. /* RAM region to be used for Main stack. This stack accommodates the processing
  18. of all exceptions and interrupts*/
  19. REGION_ALIAS("MAIN_STACK_RAM", ram0);
  20. /* RAM region to be used for the process stack. This is the stack used by
  21. the main() function.*/
  22. REGION_ALIAS("PROCESS_STACK_RAM", ram0);
  23. /* RAM region to be used for data segment.*/
  24. REGION_ALIAS("DATA_RAM", ram0);
  25. /* RAM region to be used for BSS segment.*/
  26. REGION_ALIAS("BSS_RAM", ram0);
  27. /* RAM region to be used for the default heap.*/
  28. REGION_ALIAS("HEAP_RAM", ram0);
  29. __ram0_start__ = ORIGIN(ram0);
  30. __ram0_size__ = LENGTH(ram0);
  31. __ram0_end__ = __ram0_start__ + __ram0_size__;
  32. ENTRY(Reset_Handler)
  33. SECTIONS
  34. {
  35. . = 0;
  36. _text = .;
  37. startup : ALIGN(16) SUBALIGN(16)
  38. {
  39. KEEP(*(.vectors))
  40. } > flash
  41. constructors : ALIGN(4) SUBALIGN(4)
  42. {
  43. __init_array_start = .;
  44. KEEP(*(SORT(.init_array.*)))
  45. KEEP(*(.init_array))
  46. __init_array_end = .;
  47. } > flash
  48. destructors : ALIGN(4) SUBALIGN(4)
  49. {
  50. __fini_array_start = .;
  51. KEEP(*(.fini_array))
  52. KEEP(*(SORT(.fini_array.*)))
  53. __fini_array_end = .;
  54. } > flash
  55. .text : ALIGN(4) SUBALIGN(4)
  56. {
  57. *(.text)
  58. *(.text.*)
  59. *(.rodata)
  60. *(.rodata.*)
  61. *(.glue_7t)
  62. *(.glue_7)
  63. *(.gcc*)
  64. } > flash
  65. .ARM.extab :
  66. {
  67. *(.ARM.extab* .gnu.linkonce.armextab.*)
  68. } > flash
  69. .ARM.exidx : {
  70. __exidx_start = .;
  71. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  72. __exidx_end = .;
  73. } > flash
  74. .eh_frame_hdr :
  75. {
  76. *(.eh_frame_hdr)
  77. } > flash
  78. .eh_frame : ONLY_IF_RO
  79. {
  80. *(.eh_frame)
  81. } > flash
  82. .textalign : ONLY_IF_RO
  83. {
  84. . = ALIGN(8);
  85. } > flash
  86. /* Legacy symbol, not used anywhere.*/
  87. . = ALIGN(4);
  88. PROVIDE(_etext = .);
  89. /* Special section for exceptions stack.*/
  90. .mstack :
  91. {
  92. . = ALIGN(8);
  93. __main_stack_base__ = .;
  94. . += __main_stack_size__;
  95. . = ALIGN(8);
  96. __main_stack_end__ = .;
  97. } > MAIN_STACK_RAM
  98. /* Special section for process stack.*/
  99. .pstack :
  100. {
  101. __process_stack_base__ = .;
  102. __main_thread_stack_base__ = .;
  103. . += __process_stack_size__;
  104. . = ALIGN(8);
  105. __process_stack_end__ = .;
  106. __main_thread_stack_end__ = .;
  107. } > PROCESS_STACK_RAM
  108. .data : ALIGN(4)
  109. {
  110. . = ALIGN(4);
  111. PROVIDE(_textdata = LOADADDR(.data));
  112. PROVIDE(_data = .);
  113. _textdata_start = LOADADDR(.data);
  114. _data_start = .;
  115. *(.data)
  116. *(.data.*)
  117. *(.ramtext)
  118. . = ALIGN(4);
  119. PROVIDE(_edata = .);
  120. _data_end = .;
  121. } > DATA_RAM AT > flash
  122. .bss (NOLOAD) : ALIGN(4)
  123. {
  124. . = ALIGN(4);
  125. _bss_start = .;
  126. *(.bss)
  127. *(.bss.*)
  128. *(COMMON)
  129. . = ALIGN(4);
  130. _bss_end = .;
  131. PROVIDE(end = .);
  132. } > BSS_RAM
  133. .ram0_init : ALIGN(4)
  134. {
  135. . = ALIGN(4);
  136. __ram0_init_text__ = LOADADDR(.ram0_init);
  137. __ram0_init__ = .;
  138. *(.ram0_init)
  139. *(.ram0_init.*)
  140. . = ALIGN(4);
  141. } > ram0 AT > flash
  142. .ram0 (NOLOAD) : ALIGN(4)
  143. {
  144. . = ALIGN(4);
  145. __ram0_clear__ = .;
  146. *(.ram0_clear)
  147. *(.ram0_clear.*)
  148. . = ALIGN(4);
  149. __ram0_noinit__ = .;
  150. *(.ram0)
  151. *(.ram0.*)
  152. . = ALIGN(4);
  153. __ram0_free__ = .;
  154. } > ram0
  155. /* The default heap uses the (statically) unused part of a RAM section.*/
  156. .heap (NOLOAD) :
  157. {
  158. . = ALIGN(8);
  159. __heap_base__ = .;
  160. . = ORIGIN(HEAP_RAM) + LENGTH(HEAP_RAM);
  161. __heap_end__ = .;
  162. } > HEAP_RAM
  163. }