gcc.ld 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 : {
  70. __fsymtab_start = .;
  71. KEEP(*(FSymTab))
  72. __fsymtab_end = .;
  73. }
  74. . = ALIGN(4);
  75. VSymTab : {
  76. __vsymtab_start = .;
  77. KEEP(*(VSymTab))
  78. __vsymtab_end = .;
  79. }
  80. . = ALIGN(4);
  81. /* setction information for finsh shell end */
  82. .eh_frame_hdr : { *(.eh_frame_hdr) }
  83. .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  84. .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
  85. .gcc_except_table.*) }
  86. /* These sections are generated by the Sun/Oracle C++ compiler. */
  87. .exception_ranges : ONLY_IF_RO { *(.exception_ranges
  88. .exception_ranges*) }
  89. /* Adjust the address for the data segment. We want to adjust up to
  90. the same address within the page on the next page up. */
  91. . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
  92. /* Exception handling */
  93. .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
  94. .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
  95. .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
  96. /* Thread Local Storage sections */
  97. .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
  98. .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  99. .preinit_array :
  100. {
  101. PROVIDE_HIDDEN (__preinit_array_start = .);
  102. KEEP (*(.preinit_array))
  103. PROVIDE_HIDDEN (__preinit_array_end = .);
  104. }
  105. .init_array :
  106. {
  107. PROVIDE_HIDDEN (__init_array_start = .);
  108. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  109. KEEP (*(.init_array))
  110. KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  111. PROVIDE_HIDDEN (__init_array_end = .);
  112. }
  113. .fini_array :
  114. {
  115. PROVIDE_HIDDEN (__fini_array_start = .);
  116. KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  117. KEEP (*(.fini_array))
  118. KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  119. PROVIDE_HIDDEN (__fini_array_end = .);
  120. }
  121. .ctors :
  122. {
  123. /* gcc uses crtbegin.o to find the start of
  124. the constructors, so we make sure it is
  125. first. Because this is a wildcard, it
  126. doesn't matter if the user does not
  127. actually link against crtbegin.o; the
  128. linker won't look for a file to match a
  129. wildcard. The wildcard also means that it
  130. doesn't matter which directory crtbegin.o
  131. is in. */
  132. KEEP (*crtbegin.o(.ctors))
  133. KEEP (*crtbegin?.o(.ctors))
  134. /* We don't want to include the .ctor section from
  135. the crtend.o file until after the sorted ctors.
  136. The .ctor section from the crtend file contains the
  137. end of ctors marker and it must be last */
  138. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
  139. KEEP (*(SORT(.ctors.*)))
  140. KEEP (*(.ctors))
  141. }
  142. .dtors :
  143. {
  144. KEEP (*crtbegin.o(.dtors))
  145. KEEP (*crtbegin?.o(.dtors))
  146. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
  147. KEEP (*(SORT(.dtors.*)))
  148. KEEP (*(.dtors))
  149. }
  150. .jcr : { KEEP (*(.jcr)) }
  151. .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
  152. .dynamic : { *(.dynamic) }
  153. .got : { *(.got) *(.igot) }
  154. . = DATA_SEGMENT_RELRO_END (12, .);
  155. .got.plt : { *(.got.plt) *(.igot.plt) }
  156. .data :
  157. {
  158. *(.data .data.* .gnu.linkonce.d.*)
  159. SORT(CONSTRUCTORS)
  160. }
  161. .data1 : { *(.data1) }
  162. _edata = .; PROVIDE (edata = .);
  163. __bss_start = .;
  164. .bss :
  165. {
  166. *(.dynbss)
  167. *(.bss .bss.* .gnu.linkonce.b.*)
  168. *(COMMON)
  169. /* Align here to ensure that the .bss section occupies space up to
  170. _end. Align after .bss to ensure correct alignment even if the
  171. .bss section disappears because there are no input sections.
  172. FIXME: Why do we need it? When there is no .bss section, we don't
  173. pad the .data section. */
  174. . = ALIGN(. != 0 ? 32 / 8 : 1);
  175. }
  176. . = ALIGN(32 / 8);
  177. . = ALIGN(32 / 8);
  178. _end = .; PROVIDE (end = .);
  179. . = DATA_SEGMENT_END (.);
  180. /* Stabs debugging sections. */
  181. .stab 0 : { *(.stab) }
  182. .stabstr 0 : { *(.stabstr) }
  183. .stab.excl 0 : { *(.stab.excl) }
  184. .stab.exclstr 0 : { *(.stab.exclstr) }
  185. .stab.index 0 : { *(.stab.index) }
  186. .stab.indexstr 0 : { *(.stab.indexstr) }
  187. .comment 0 : { *(.comment) }
  188. /* DWARF debug sections.
  189. Symbols in the DWARF debugging sections are relative to the beginning
  190. of the section so we begin them at 0. */
  191. /* DWARF 1 */
  192. .debug 0 : { *(.debug) }
  193. .line 0 : { *(.line) }
  194. /* GNU DWARF 1 extensions */
  195. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  196. .debug_sfnames 0 : { *(.debug_sfnames) }
  197. /* DWARF 1.1 and DWARF 2 */
  198. .debug_aranges 0 : { *(.debug_aranges) }
  199. .debug_pubnames 0 : { *(.debug_pubnames) }
  200. /* DWARF 2 */
  201. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  202. .debug_abbrev 0 : { *(.debug_abbrev) }
  203. .debug_line 0 : { *(.debug_line) }
  204. .debug_frame 0 : { *(.debug_frame) }
  205. .debug_str 0 : { *(.debug_str) }
  206. .debug_loc 0 : { *(.debug_loc) }
  207. .debug_macinfo 0 : { *(.debug_macinfo) }
  208. /* SGI/MIPS DWARF 2 extensions */
  209. .debug_weaknames 0 : { *(.debug_weaknames) }
  210. .debug_funcnames 0 : { *(.debug_funcnames) }
  211. .debug_typenames 0 : { *(.debug_typenames) }
  212. .debug_varnames 0 : { *(.debug_varnames) }
  213. /* DWARF 3 */
  214. .debug_pubtypes 0 : { *(.debug_pubtypes) }
  215. .debug_ranges 0 : { *(.debug_ranges) }
  216. .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  217. /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
  218. }