gcc.ld 7.9 KB

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