gcc_elf64.ld 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* Script for -z combreloc: combine and sort reloc sections */
  2. OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
  3. "elf64-x86-64")
  4. OUTPUT_ARCH(i386:x86-64)
  5. ENTRY(_start)
  6. SECTIONS
  7. {
  8. /* Read-only sections, merged into text segment: */
  9. PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x08048000)); . = SEGMENT_START("text-segment", 0x08048000) + SIZEOF_HEADERS;
  10. .interp : { *(.interp) }
  11. .note.gnu.build-id : { *(.note.gnu.build-id) }
  12. .hash : { *(.hash) }
  13. .gnu.hash : { *(.gnu.hash) }
  14. .dynsym : { *(.dynsym) }
  15. .dynstr : { *(.dynstr) }
  16. .gnu.version : { *(.gnu.version) }
  17. .gnu.version_d : { *(.gnu.version_d) }
  18. .gnu.version_r : { *(.gnu.version_r) }
  19. .rel.dyn :
  20. {
  21. *(.rel.init)
  22. *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
  23. *(.rel.fini)
  24. *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
  25. *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
  26. *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
  27. *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
  28. *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
  29. *(.rel.ctors)
  30. *(.rel.dtors)
  31. *(.rel.got)
  32. *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
  33. *(.rel.ifunc)
  34. }
  35. .rel.plt :
  36. {
  37. *(.rel.plt)
  38. PROVIDE_HIDDEN (__rel_iplt_start = .);
  39. *(.rel.iplt)
  40. PROVIDE_HIDDEN (__rel_iplt_end = .);
  41. }
  42. .init :
  43. {
  44. KEEP (*(.init))
  45. } =0x90909090
  46. .plt : { *(.plt) *(.iplt) }
  47. .text :
  48. {
  49. *(.text.unlikely .text.*_unlikely)
  50. *(.text.exit .text.exit.*)
  51. *(.text.startup .text.startup.*)
  52. *(.text.hot .text.hot.*)
  53. *(.text .stub .text.* .gnu.linkonce.t.*)
  54. /* .gnu.warning sections are handled specially by elf32.em. */
  55. *(.gnu.warning)
  56. } =0x90909090
  57. .fini :
  58. {
  59. KEEP (*(.fini))
  60. } =0x90909090
  61. PROVIDE (__etext = .);
  62. PROVIDE (_etext = .);
  63. PROVIDE (etext = .);
  64. .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
  65. .rodata1 : { *(.rodata1) }
  66. /* setction information for finsh shell begin */
  67. . = ALIGN(8);
  68. UtestTcTab : {
  69. __rt_utest_tc_tab_start = .;
  70. KEEP(*(UtestTcTab))
  71. __rt_utest_tc_tab_end = .;
  72. }
  73. . = ALIGN(8);
  74. FSymTab : {
  75. __fsymtab_start = .;
  76. KEEP(*(FSymTab))
  77. __fsymtab_end = .;
  78. }
  79. . = ALIGN(8);
  80. VSymTab : {
  81. __vsymtab_start = .;
  82. KEEP(*(VSymTab))
  83. __vsymtab_end = .;
  84. }
  85. . = ALIGN(8);
  86. rti_fn : {
  87. __rt_init_start = .;
  88. KEEP(*(SORT(.rti_fn*)))
  89. __rt_init_end = .;
  90. }
  91. . = ALIGN(8);
  92. /* setction information for finsh shell end */
  93. .eh_frame_hdr : { *(.eh_frame_hdr) }
  94. .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  95. .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
  96. .gcc_except_table.*) }
  97. /* These sections are generated by the Sun/Oracle C++ compiler. */
  98. .exception_ranges : ONLY_IF_RO { *(.exception_ranges
  99. .exception_ranges*) }
  100. /* Adjust the address for the data segment. We want to adjust up to
  101. the same address within the page on the next page up. */
  102. . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
  103. /* Exception handling */
  104. .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
  105. .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
  106. .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
  107. /* Thread Local Storage sections */
  108. .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
  109. .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  110. .preinit_array :
  111. {
  112. PROVIDE_HIDDEN (__preinit_array_start = .);
  113. KEEP (*(.preinit_array))
  114. PROVIDE_HIDDEN (__preinit_array_end = .);
  115. }
  116. .init_array :
  117. {
  118. PROVIDE_HIDDEN (__init_array_start = .);
  119. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  120. KEEP (*(.init_array))
  121. KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  122. PROVIDE_HIDDEN (__init_array_end = .);
  123. }
  124. .fini_array :
  125. {
  126. PROVIDE_HIDDEN (__fini_array_start = .);
  127. KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  128. KEEP (*(.fini_array))
  129. KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  130. PROVIDE_HIDDEN (__fini_array_end = .);
  131. }
  132. .ctors :
  133. {
  134. /* gcc uses crtbegin.o to find the start of
  135. the constructors, so we make sure it is
  136. first. Because this is a wildcard, it
  137. doesn't matter if the user does not
  138. actually link against crtbegin.o; the
  139. linker won't look for a file to match a
  140. wildcard. The wildcard also means that it
  141. doesn't matter which directory crtbegin.o
  142. is in. */
  143. KEEP (*crtbegin.o(.ctors))
  144. KEEP (*crtbegin?.o(.ctors))
  145. /* We don't want to include the .ctor section from
  146. the crtend.o file until after the sorted ctors.
  147. The .ctor section from the crtend file contains the
  148. end of ctors marker and it must be last */
  149. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
  150. KEEP (*(SORT(.ctors.*)))
  151. KEEP (*(.ctors))
  152. }
  153. .dtors :
  154. {
  155. KEEP (*crtbegin.o(.dtors))
  156. KEEP (*crtbegin?.o(.dtors))
  157. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
  158. KEEP (*(SORT(.dtors.*)))
  159. KEEP (*(.dtors))
  160. }
  161. .jcr : { KEEP (*(.jcr)) }
  162. .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
  163. .dynamic : { *(.dynamic) }
  164. .got : { *(.got) *(.igot) }
  165. . = DATA_SEGMENT_RELRO_END (12, .);
  166. .got.plt : { *(.got.plt) *(.igot.plt) }
  167. .data :
  168. {
  169. *(.data .data.* .gnu.linkonce.d.*)
  170. SORT(CONSTRUCTORS)
  171. }
  172. .data1 : { *(.data1) }
  173. _edata = .; PROVIDE (edata = .);
  174. __bss_start = .;
  175. .bss :
  176. {
  177. *(.dynbss)
  178. *(.bss .bss.* .gnu.linkonce.b.*)
  179. *(COMMON)
  180. /* Align here to ensure that the .bss section occupies space up to
  181. _end. Align after .bss to ensure correct alignment even if the
  182. .bss section disappears because there are no input sections.
  183. FIXME: Why do we need it? When there is no .bss section, we don't
  184. pad the .data section. */
  185. . = ALIGN(. != 0 ? 32 / 8 : 1);
  186. }
  187. . = ALIGN(32 / 8);
  188. . = ALIGN(32 / 8);
  189. _end = .; PROVIDE (end = .);
  190. . = DATA_SEGMENT_END (.);
  191. /* Stabs debugging sections. */
  192. .stab 0 : { *(.stab) }
  193. .stabstr 0 : { *(.stabstr) }
  194. .stab.excl 0 : { *(.stab.excl) }
  195. .stab.exclstr 0 : { *(.stab.exclstr) }
  196. .stab.index 0 : { *(.stab.index) }
  197. .stab.indexstr 0 : { *(.stab.indexstr) }
  198. .comment 0 : { *(.comment) }
  199. /* DWARF debug sections.
  200. Symbols in the DWARF debugging sections are relative to the beginning
  201. of the section so we begin them at 0. */
  202. /* DWARF 1 */
  203. .debug 0 : { *(.debug) }
  204. .line 0 : { *(.line) }
  205. /* GNU DWARF 1 extensions */
  206. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  207. .debug_sfnames 0 : { *(.debug_sfnames) }
  208. /* DWARF 1.1 and DWARF 2 */
  209. .debug_aranges 0 : { *(.debug_aranges) }
  210. .debug_pubnames 0 : { *(.debug_pubnames) }
  211. /* DWARF 2 */
  212. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  213. .debug_abbrev 0 : { *(.debug_abbrev) }
  214. .debug_line 0 : { *(.debug_line) }
  215. .debug_frame 0 : { *(.debug_frame) }
  216. .debug_str 0 : { *(.debug_str) }
  217. .debug_loc 0 : { *(.debug_loc) }
  218. .debug_macinfo 0 : { *(.debug_macinfo) }
  219. /* SGI/MIPS DWARF 2 extensions */
  220. .debug_weaknames 0 : { *(.debug_weaknames) }
  221. .debug_funcnames 0 : { *(.debug_funcnames) }
  222. .debug_typenames 0 : { *(.debug_typenames) }
  223. .debug_varnames 0 : { *(.debug_varnames) }
  224. /* DWARF 3 */
  225. .debug_pubtypes 0 : { *(.debug_pubtypes) }
  226. .debug_ranges 0 : { *(.debug_ranges) }
  227. .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  228. /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
  229. }