i386pe.xe 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /* Script for -z separate-code */
  2. /* Copyright (C) 2014-2020 Free Software Foundation, Inc.
  3. Copying and distribution of this script, with or without modification,
  4. are permitted in any medium without royalty provided the copyright
  5. notice and this notice are preserved. */
  6. OUTPUT_FORMAT(pei-i386)
  7. SEARCH_DIR("=/mnt/f/gnu/x64-linux/out/x86_64-pep/lib");
  8. SECTIONS
  9. {
  10. /* Make the virtual address and file offset synced if the alignment is
  11. lower than the target page size. */
  12. . = SIZEOF_HEADERS;
  13. . = ALIGN(__section_alignment__);
  14. .text __image_base__ + ( __section_alignment__ < 0x1000 ? . : __section_alignment__ ) :
  15. {
  16. KEEP (*(SORT_NONE(.init)))
  17. *(.text)
  18. *(SORT(.text$*))
  19. *(.text.*)
  20. *(.gnu.linkonce.t.*)
  21. *(.glue_7t)
  22. *(.glue_7)
  23. /* Note: we always define __CTOR_LIST__ and ___CTOR_LIST__ here,
  24. we do not PROVIDE them. This is because the ctors.o startup
  25. code in libgcc defines them as common symbols, with the
  26. expectation that they will be overridden by the definitions
  27. here. If we PROVIDE the symbols then they will not be
  28. overridden and global constructors will not be run.
  29. See PR 22762 for more details.
  30. This does mean that it is not possible for a user to define
  31. their own __CTOR_LIST__ and __DTOR_LIST__ symbols; if they do,
  32. the content from those variables are included but the symbols
  33. defined here silently take precedence. If they truly need to
  34. be redefined, a custom linker script will have to be used.
  35. (The custom script can just be a copy of this script with the
  36. PROVIDE() qualifiers added).
  37. In particular this means that ld -Ur does not work, because
  38. the proper __CTOR_LIST__ set by ld -Ur is overridden by a
  39. bogus __CTOR_LIST__ set by the final link. See PR 46. */
  40. ___CTOR_LIST__ = .;
  41. __CTOR_LIST__ = .;
  42. LONG (-1);
  43. KEEP(*(.ctors));
  44. KEEP(*(.ctor));
  45. KEEP(*(SORT_BY_NAME(.ctors.*)));
  46. LONG (0);
  47. /* See comment about __CTOR_LIST__ above. The same reasoning
  48. applies here too. */
  49. ___DTOR_LIST__ = .;
  50. __DTOR_LIST__ = .;
  51. LONG (-1);
  52. KEEP(*(.dtors));
  53. KEEP(*(.dtor));
  54. KEEP(*(SORT_BY_NAME(.dtors.*)));
  55. LONG (0);
  56. KEEP (*(SORT_NONE(.fini)))
  57. /* ??? Why is .gcc_exc here? */
  58. *(.gcc_exc)
  59. PROVIDE (etext = .);
  60. PROVIDE (_etext = .);
  61. KEEP (*(.gcc_except_table))
  62. }
  63. /* The Cygwin32 library uses a section to avoid copying certain data
  64. on fork. This used to be named ".data". The linker used
  65. to include this between __data_start__ and __data_end__, but that
  66. breaks building the cygwin32 dll. Instead, we name the section
  67. ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
  68. .data BLOCK(__section_alignment__) :
  69. {
  70. __data_start__ = . ;
  71. *(.data)
  72. *(.data2)
  73. *(SORT(.data$*))
  74. KEEP(*(.jcr))
  75. __data_end__ = . ;
  76. *(.data_cygwin_nocopy)
  77. }
  78. .rdata BLOCK(__section_alignment__) :
  79. {
  80. *(.rdata)
  81. *(SORT(.rdata$*))
  82. . = ALIGN(4);
  83. __rt_psrelocs_start = .;
  84. KEEP(*(.rdata_runtime_pseudo_reloc))
  85. __rt_psrelocs_end = .;
  86. }
  87. __rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;
  88. ___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
  89. __RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
  90. ___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;
  91. __RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;
  92. .eh_frame BLOCK(__section_alignment__) :
  93. {
  94. KEEP(*(.eh_frame*))
  95. }
  96. .pdata BLOCK(__section_alignment__) :
  97. {
  98. KEEP(*(.pdata*))
  99. }
  100. .bss BLOCK(__section_alignment__) :
  101. {
  102. __bss_start__ = . ;
  103. *(.bss)
  104. *(COMMON)
  105. __bss_end__ = . ;
  106. }
  107. .edata BLOCK(__section_alignment__) :
  108. {
  109. *(.edata)
  110. }
  111. /DISCARD/ :
  112. {
  113. *(.debug$S)
  114. *(.debug$T)
  115. *(.debug$F)
  116. *(.drectve)
  117. *(.note.GNU-stack)
  118. *(.gnu.lto_*)
  119. }
  120. .idata BLOCK(__section_alignment__) :
  121. {
  122. /* This cannot currently be handled with grouped sections.
  123. See pe.em:sort_sections. */
  124. KEEP (SORT(*)(.idata$2))
  125. KEEP (SORT(*)(.idata$3))
  126. /* These zeroes mark the end of the import list. */
  127. LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
  128. KEEP (SORT(*)(.idata$4))
  129. __IAT_start__ = .;
  130. KEEP (SORT(*)(.idata$5))
  131. __IAT_end__ = .;
  132. KEEP (SORT(*)(.idata$6))
  133. KEEP (SORT(*)(.idata$7))
  134. }
  135. .CRT BLOCK(__section_alignment__) :
  136. {
  137. ___crt_xc_start__ = . ;
  138. KEEP (*(SORT(.CRT$XC*))) /* C initialization */
  139. ___crt_xc_end__ = . ;
  140. ___crt_xi_start__ = . ;
  141. KEEP (*(SORT(.CRT$XI*))) /* C++ initialization */
  142. ___crt_xi_end__ = . ;
  143. ___crt_xl_start__ = . ;
  144. KEEP (*(SORT(.CRT$XL*))) /* TLS callbacks */
  145. /* ___crt_xl_end__ is defined in the TLS Directory support code */
  146. ___crt_xp_start__ = . ;
  147. KEEP (*(SORT(.CRT$XP*))) /* Pre-termination */
  148. ___crt_xp_end__ = . ;
  149. ___crt_xt_start__ = . ;
  150. KEEP (*(SORT(.CRT$XT*))) /* Termination */
  151. ___crt_xt_end__ = . ;
  152. }
  153. /* Windows TLS expects .tls$AAA to be at the start and .tls$ZZZ to be
  154. at the end of section. This is important because _tls_start MUST
  155. be at the beginning of the section to enable SECREL32 relocations with TLS
  156. data. */
  157. .tls BLOCK(__section_alignment__) :
  158. {
  159. ___tls_start__ = . ;
  160. KEEP (*(.tls$AAA))
  161. KEEP (*(.tls))
  162. KEEP (*(.tls$))
  163. KEEP (*(SORT(.tls$*)))
  164. KEEP (*(.tls$ZZZ))
  165. ___tls_end__ = . ;
  166. }
  167. .endjunk BLOCK(__section_alignment__) :
  168. {
  169. /* end is deprecated, don't use it */
  170. PROVIDE (end = .);
  171. PROVIDE ( _end = .);
  172. __end__ = .;
  173. }
  174. .rsrc BLOCK(__section_alignment__) : SUBALIGN(4)
  175. {
  176. KEEP (*(.rsrc))
  177. KEEP (*(.rsrc$*))
  178. }
  179. .reloc BLOCK(__section_alignment__) :
  180. {
  181. *(.reloc)
  182. }
  183. .stab BLOCK(__section_alignment__) (NOLOAD) :
  184. {
  185. *(.stab)
  186. }
  187. .stabstr BLOCK(__section_alignment__) (NOLOAD) :
  188. {
  189. *(.stabstr)
  190. }
  191. /* DWARF debug sections.
  192. Symbols in the DWARF debugging sections are relative to the beginning
  193. of the section. Unlike other targets that fake this by putting the
  194. section VMA at 0, the PE format will not allow it. */
  195. /* DWARF 1.1 and DWARF 2. */
  196. .debug_aranges BLOCK(__section_alignment__) (NOLOAD) :
  197. {
  198. *(.debug_aranges)
  199. }
  200. .zdebug_aranges BLOCK(__section_alignment__) (NOLOAD) :
  201. {
  202. *(.zdebug_aranges)
  203. }
  204. .debug_pubnames BLOCK(__section_alignment__) (NOLOAD) :
  205. {
  206. *(.debug_pubnames)
  207. }
  208. .zdebug_pubnames BLOCK(__section_alignment__) (NOLOAD) :
  209. {
  210. *(.zdebug_pubnames)
  211. }
  212. .debug_pubtypes BLOCK(__section_alignment__) (NOLOAD) :
  213. {
  214. *(.debug_pubtypes)
  215. }
  216. .zdebug_pubtypes BLOCK(__section_alignment__) (NOLOAD) :
  217. {
  218. *(.zdebug_pubtypes)
  219. }
  220. /* DWARF 2. */
  221. .debug_info BLOCK(__section_alignment__) (NOLOAD) :
  222. {
  223. *(.debug_info .gnu.linkonce.wi.*)
  224. }
  225. .zdebug_info BLOCK(__section_alignment__) (NOLOAD) :
  226. {
  227. *(.zdebug_info .zdebug.gnu.linkonce.wi.*)
  228. }
  229. .debug_abbrev BLOCK(__section_alignment__) (NOLOAD) :
  230. {
  231. *(.debug_abbrev)
  232. }
  233. .zdebug_abbrev BLOCK(__section_alignment__) (NOLOAD) :
  234. {
  235. *(.zdebug_abbrev)
  236. }
  237. .debug_line BLOCK(__section_alignment__) (NOLOAD) :
  238. {
  239. *(.debug_line)
  240. }
  241. .zdebug_line BLOCK(__section_alignment__) (NOLOAD) :
  242. {
  243. *(.zdebug_line)
  244. }
  245. .debug_frame BLOCK(__section_alignment__) (NOLOAD) :
  246. {
  247. *(.debug_frame*)
  248. }
  249. .zdebug_frame BLOCK(__section_alignment__) (NOLOAD) :
  250. {
  251. *(.zdebug_frame*)
  252. }
  253. .debug_str BLOCK(__section_alignment__) (NOLOAD) :
  254. {
  255. *(.debug_str)
  256. }
  257. .zdebug_str BLOCK(__section_alignment__) (NOLOAD) :
  258. {
  259. *(.zdebug_str)
  260. }
  261. .debug_loc BLOCK(__section_alignment__) (NOLOAD) :
  262. {
  263. *(.debug_loc)
  264. }
  265. .zdebug_loc BLOCK(__section_alignment__) (NOLOAD) :
  266. {
  267. *(.zdebug_loc)
  268. }
  269. .debug_macinfo BLOCK(__section_alignment__) (NOLOAD) :
  270. {
  271. *(.debug_macinfo)
  272. }
  273. .zdebug_macinfo BLOCK(__section_alignment__) (NOLOAD) :
  274. {
  275. *(.zdebug_macinfo)
  276. }
  277. /* SGI/MIPS DWARF 2 extensions. */
  278. .debug_weaknames BLOCK(__section_alignment__) (NOLOAD) :
  279. {
  280. *(.debug_weaknames)
  281. }
  282. .zdebug_weaknames BLOCK(__section_alignment__) (NOLOAD) :
  283. {
  284. *(.zdebug_weaknames)
  285. }
  286. .debug_funcnames BLOCK(__section_alignment__) (NOLOAD) :
  287. {
  288. *(.debug_funcnames)
  289. }
  290. .zdebug_funcnames BLOCK(__section_alignment__) (NOLOAD) :
  291. {
  292. *(.zdebug_funcnames)
  293. }
  294. .debug_typenames BLOCK(__section_alignment__) (NOLOAD) :
  295. {
  296. *(.debug_typenames)
  297. }
  298. .zdebug_typenames BLOCK(__section_alignment__) (NOLOAD) :
  299. {
  300. *(.zdebug_typenames)
  301. }
  302. .debug_varnames BLOCK(__section_alignment__) (NOLOAD) :
  303. {
  304. *(.debug_varnames)
  305. }
  306. .zdebug_varnames BLOCK(__section_alignment__) (NOLOAD) :
  307. {
  308. *(.zdebug_varnames)
  309. }
  310. .debug_macro BLOCK(__section_alignment__) (NOLOAD) :
  311. {
  312. *(.debug_macro)
  313. }
  314. .zdebug_macro BLOCK(__section_alignment__) (NOLOAD) :
  315. {
  316. *(.zdebug_macro)
  317. }
  318. /* DWARF 3. */
  319. .debug_ranges BLOCK(__section_alignment__) (NOLOAD) :
  320. {
  321. *(.debug_ranges)
  322. }
  323. .zdebug_ranges BLOCK(__section_alignment__) (NOLOAD) :
  324. {
  325. *(.zdebug_ranges)
  326. }
  327. /* DWARF 4. */
  328. .debug_types BLOCK(__section_alignment__) (NOLOAD) :
  329. {
  330. *(.debug_types .gnu.linkonce.wt.*)
  331. }
  332. .zdebug_types BLOCK(__section_alignment__) (NOLOAD) :
  333. {
  334. *(.zdebug_types .gnu.linkonce.wt.*)
  335. }
  336. /* For Go and Rust. */
  337. .debug_gdb_scripts BLOCK(__section_alignment__) (NOLOAD) :
  338. {
  339. *(.debug_gdb_scripts)
  340. }
  341. .zdebug_gdb_scripts BLOCK(__section_alignment__) (NOLOAD) :
  342. {
  343. *(.zdebug_gdb_scripts)
  344. }
  345. }