link.lds.S 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. PROVIDE(__text_end = .);
  70. }
  71. .eh_frame_hdr :
  72. {
  73. *(.eh_frame_hdr)
  74. *(.eh_frame_entry)
  75. }
  76. .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  77. . = ALIGN(8);
  78. .data :
  79. {
  80. *(.data)
  81. *(.data.*)
  82. *(.data1)
  83. *(.data1.*)
  84. . = ALIGN(16);
  85. _gp = ABSOLUTE(.); /* Base of small data */
  86. *(.sdata)
  87. *(.sdata.*)
  88. *(.rel.local)
  89. }
  90. . = ALIGN(8);
  91. .ctors :
  92. {
  93. PROVIDE(__ctors_start__ = .);
  94. /* new GCC version uses .init_array */
  95. KEEP(*(SORT(.init_array.*)))
  96. KEEP(*(.init_array))
  97. PROVIDE(__ctors_end__ = .);
  98. }
  99. .dtors :
  100. {
  101. PROVIDE(__dtors_start__ = .);
  102. KEEP(*(SORT(.dtors.*)))
  103. KEEP(*(.dtors))
  104. PROVIDE(__dtors_end__ = .);
  105. }
  106. . = ALIGN(16);
  107. .bss :
  108. {
  109. /*
  110. * We need some free space to page or cpu stack, move .bss.noclean.*
  111. * to optimize size.
  112. */
  113. PROVIDE(__bss_noclean_start = .);
  114. *(.bss.noclean.*)
  115. PROVIDE(__bss_noclean_end = .);
  116. . = ALIGN(8);
  117. PROVIDE(__bss_start = .);
  118. *(.bss)
  119. *(.bss.*)
  120. *(.dynbss)
  121. *(COMMON)
  122. . = ALIGN(8);
  123. PROVIDE(__bss_end = .);
  124. }
  125. /*
  126. * We should make the bootloader know the size of memory we need,
  127. * so we MUST calc the image's size with section '.bss'.
  128. */
  129. _end = .;
  130. /* Stabs debugging sections. */
  131. .stab 0 : { *(.stab) }
  132. .stabstr 0 : { *(.stabstr) }
  133. .stab.excl 0 : { *(.stab.excl) }
  134. .stab.exclstr 0 : { *(.stab.exclstr) }
  135. .stab.index 0 : { *(.stab.index) }
  136. .stab.indexstr 0 : { *(.stab.indexstr) }
  137. .comment 0 : { *(.comment) }
  138. /* DWARF debug sections.
  139. * Symbols in the DWARF debugging sections are relative to the beginning
  140. * of the section so we begin them at 0. */
  141. /* DWARF 1 */
  142. .debug 0 : { *(.debug) }
  143. .line 0 : { *(.line) }
  144. /* GNU DWARF 1 extensions */
  145. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  146. .debug_sfnames 0 : { *(.debug_sfnames) }
  147. /* DWARF 1.1 and DWARF 2 */
  148. .debug_aranges 0 : { *(.debug_aranges) }
  149. .debug_pubnames 0 : { *(.debug_pubnames) }
  150. /* DWARF 2 */
  151. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  152. .debug_abbrev 0 : { *(.debug_abbrev) }
  153. .debug_line 0 : { *(.debug_line) }
  154. .debug_frame 0 : { *(.debug_frame) }
  155. .debug_str 0 : { *(.debug_str) }
  156. .debug_loc 0 : { *(.debug_loc) }
  157. .debug_macinfo 0 : { *(.debug_macinfo) }
  158. /* SGI/MIPS DWARF 2 extensions */
  159. .debug_weaknames 0 : { *(.debug_weaknames) }
  160. .debug_funcnames 0 : { *(.debug_funcnames) }
  161. .debug_typenames 0 : { *(.debug_typenames) }
  162. .debug_varnames 0 : { *(.debug_varnames) }
  163. __data_size = SIZEOF(.data);
  164. __bss_size = SIZEOF(.bss);
  165. }