link.lds.S 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Date Author Notes
  7. * 2017-5-30 bernard first version
  8. */
  9. #include "rtconfig.h"
  10. OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
  11. OUTPUT_ARCH(aarch64)
  12. #ifndef ARCH_TEXT_OFFSET
  13. #define ARCH_TEXT_OFFSET 0x200000 /* We always boot in address where is 2MB aligned */
  14. #endif
  15. #ifndef ARCH_RAM_OFFSET
  16. #define ARCH_RAM_OFFSET 0
  17. #endif
  18. SECTIONS
  19. {
  20. _text_offset = ARCH_TEXT_OFFSET;
  21. #ifdef RT_USING_SMART
  22. . = KERNEL_VADDR_START + _text_offset;
  23. #else
  24. . = ARCH_RAM_OFFSET + _text_offset;
  25. #endif
  26. .text :
  27. {
  28. PROVIDE(__text_start = .);
  29. KEEP(*(.text.entrypoint)) /* The entry point */
  30. *(.vectors)
  31. *(.text) /* remaining code */
  32. *(.text.*) /* remaining code */
  33. *(.rodata) /* read-only data (constants) */
  34. *(.rodata*)
  35. *(.glue_7)
  36. *(.glue_7t)
  37. *(.gnu.linkonce.t*)
  38. /* section information for utest */
  39. . = ALIGN(8);
  40. PROVIDE(__rt_utest_tc_tab_start = .);
  41. KEEP(*(UtestTcTab))
  42. PROVIDE(__rt_utest_tc_tab_end = .);
  43. /* section information for finsh shell */
  44. . = ALIGN(8);
  45. PROVIDE(__fsymtab_start = .);
  46. KEEP(*(FSymTab))
  47. PROVIDE(__fsymtab_end = .);
  48. . = ALIGN(8);
  49. PROVIDE(__vsymtab_start = .);
  50. KEEP(*(VSymTab))
  51. PROVIDE(__vsymtab_end = .);
  52. . = ALIGN(8);
  53. /* section information for modules */
  54. . = ALIGN(8);
  55. PROVIDE(__rtmsymtab_start = .);
  56. KEEP(*(RTMSymTab))
  57. PROVIDE(__rtmsymtab_end = .);
  58. /* section information for initialization */
  59. . = ALIGN(8);
  60. PROVIDE(__rt_init_start = .);
  61. KEEP(*(SORT(.rti_fn*)))
  62. PROVIDE(__rt_init_end = .);
  63. /* section information for rt_ofw. */
  64. . = ALIGN(16);
  65. PROVIDE(__rt_ofw_data_start = .);
  66. KEEP(*(SORT(.rt_ofw_data.*)))
  67. PROVIDE(__rt_ofw_data_end = .);
  68. . = ALIGN(16);
  69. /* section information for usb usbh_class_info */
  70. . = ALIGN(4);
  71. __usbh_class_info_start__ = .;
  72. KEEP(*(.usbh_class_info))
  73. . = ALIGN(4);
  74. __usbh_class_info_end__ = .;
  75. PROVIDE(__text_end = .);
  76. }
  77. .eh_frame_hdr :
  78. {
  79. *(.eh_frame_hdr)
  80. *(.eh_frame_entry)
  81. }
  82. .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  83. . = ALIGN(8);
  84. .data :
  85. {
  86. *(.data)
  87. *(.data.*)
  88. *(.data1)
  89. *(.data1.*)
  90. . = ALIGN(16);
  91. _gp = ABSOLUTE(.); /* Base of small data */
  92. *(.sdata)
  93. *(.sdata.*)
  94. *(.rel.local)
  95. }
  96. . = ALIGN(8);
  97. .ctors :
  98. {
  99. PROVIDE(__ctors_start__ = .);
  100. /* new GCC version uses .init_array */
  101. KEEP(*(SORT(.init_array.*)))
  102. KEEP(*(.init_array))
  103. PROVIDE(__ctors_end__ = .);
  104. }
  105. .dtors :
  106. {
  107. PROVIDE(__dtors_start__ = .);
  108. KEEP(*(SORT(.dtors.*)))
  109. KEEP(*(.dtors))
  110. PROVIDE(__dtors_end__ = .);
  111. }
  112. . = ALIGN(16);
  113. .bss :
  114. {
  115. /*
  116. * We need some free space to page or cpu stack, move .bss.noclean.*
  117. * to optimize size.
  118. */
  119. PROVIDE(__bss_noclean_start = .);
  120. *(.bss.noclean.*)
  121. PROVIDE(__bss_noclean_end = .);
  122. . = ALIGN(8);
  123. PROVIDE(__bss_start = .);
  124. *(.bss)
  125. *(.bss.*)
  126. *(.dynbss)
  127. *(COMMON)
  128. . = ALIGN(8);
  129. PROVIDE(__bss_end = .);
  130. }
  131. /*
  132. * We should make the bootloader know the size of memory we need,
  133. * so we MUST calc the image's size with section '.bss'.
  134. */
  135. _end = .;
  136. /* Stabs debugging sections. */
  137. .stab 0 : { *(.stab) }
  138. .stabstr 0 : { *(.stabstr) }
  139. .stab.excl 0 : { *(.stab.excl) }
  140. .stab.exclstr 0 : { *(.stab.exclstr) }
  141. .stab.index 0 : { *(.stab.index) }
  142. .stab.indexstr 0 : { *(.stab.indexstr) }
  143. .comment 0 : { *(.comment) }
  144. /* DWARF debug sections.
  145. * Symbols in the DWARF debugging sections are relative to the beginning
  146. * of the section so we begin them at 0. */
  147. /* DWARF 1 */
  148. .debug 0 : { *(.debug) }
  149. .line 0 : { *(.line) }
  150. /* GNU DWARF 1 extensions */
  151. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  152. .debug_sfnames 0 : { *(.debug_sfnames) }
  153. /* DWARF 1.1 and DWARF 2 */
  154. .debug_aranges 0 : { *(.debug_aranges) }
  155. .debug_pubnames 0 : { *(.debug_pubnames) }
  156. /* DWARF 2 */
  157. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  158. .debug_abbrev 0 : { *(.debug_abbrev) }
  159. .debug_line 0 : { *(.debug_line) }
  160. .debug_frame 0 : { *(.debug_frame) }
  161. .debug_str 0 : { *(.debug_str) }
  162. .debug_loc 0 : { *(.debug_loc) }
  163. .debug_macinfo 0 : { *(.debug_macinfo) }
  164. /* SGI/MIPS DWARF 2 extensions */
  165. .debug_weaknames 0 : { *(.debug_weaknames) }
  166. .debug_funcnames 0 : { *(.debug_funcnames) }
  167. .debug_typenames 0 : { *(.debug_typenames) }
  168. .debug_varnames 0 : { *(.debug_varnames) }
  169. __data_size = SIZEOF(.data);
  170. __bss_size = SIZEOF(.bss);
  171. }