pep.sc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. # Linker script for PE.
  2. #
  3. # Copyright (C) 2014-2015 Free Software Foundation, Inc.
  4. #
  5. # Copying and distribution of this file, with or without modification,
  6. # are permitted in any medium without royalty provided the copyright
  7. # notice and this notice are preserved.
  8. if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
  9. RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  10. fi
  11. # We can't easily and portably get an unquoted $ in a shell
  12. # substitution, so we do this instead.
  13. # Sorting of the .foo$* sections is required by the definition of
  14. # grouped sections in PE.
  15. # Sorting of the file names in R_IDATA is required by the
  16. # current implementation of dlltool (this could probably be changed to
  17. # use grouped sections instead).
  18. if test "${RELOCATING}"; then
  19. R_TEXT='*(SORT(.text$*))'
  20. if test "x$LD_FLAG" = "xauto_import" ; then
  21. R_DATA='*(SORT(.data$*))
  22. *(.rdata)
  23. *(SORT(.rdata$*))'
  24. R_RDATA=''
  25. else
  26. R_DATA='*(SORT(.data$*))'
  27. R_RDATA='*(.rdata)
  28. *(SORT(.rdata$*))'
  29. fi
  30. R_IDATA234='
  31. KEEP (SORT(*)(.idata$2))
  32. KEEP (SORT(*)(.idata$3))
  33. /* These zeroes mark the end of the import list. */
  34. LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
  35. KEEP (SORT(*)(.idata$4))'
  36. R_IDATA5='SORT(*)(.idata$5)'
  37. R_IDATA67='
  38. KEEP (SORT(*)(.idata$6))
  39. KEEP (SORT(*)(.idata$7))'
  40. R_CRT_XC='KEEP (*(SORT(.CRT$XC*))) /* C initialization */'
  41. R_CRT_XI='KEEP (*(SORT(.CRT$XI*))) /* C++ initialization */'
  42. R_CRT_XL='KEEP (*(SORT(.CRT$XL*))) /* TLS callbacks */'
  43. R_CRT_XP='KEEP (*(SORT(.CRT$XP*))) /* Pre-termination */'
  44. R_CRT_XT='KEEP (*(SORT(.CRT$XT*))) /* Termination */'
  45. R_TLS='
  46. KEEP (*(.tls$AAA))
  47. KEEP (*(.tls))
  48. KEEP (*(.tls$))
  49. KEEP (*(SORT(.tls$*)))
  50. KEEP (*(.tls$ZZZ))'
  51. R_RSRC='
  52. KEEP (*(.rsrc))
  53. KEEP (*(.rsrc$*))'
  54. else
  55. R_TEXT=
  56. R_DATA=
  57. R_RDATA='*(.rdata)'
  58. R_IDATA234=
  59. R_IDATA5=
  60. R_IDATA67=
  61. R_CRT=
  62. R_RSRC='*(.rsrc)'
  63. fi
  64. cat <<EOF
  65. /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
  66. Copying and distribution of this script, with or without modification,
  67. are permitted in any medium without royalty provided the copyright
  68. notice and this notice are preserved. */
  69. ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
  70. ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
  71. ${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})}
  72. ${LIB_SEARCH_DIRS}
  73. SECTIONS
  74. {
  75. ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is}
  76. ${RELOCATING+ lower than the target page size. */}
  77. ${RELOCATING+. = SIZEOF_HEADERS;}
  78. ${RELOCATING+. = ALIGN(__section_alignment__);}
  79. .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
  80. {
  81. ${RELOCATING+ KEEP(*(.init))}
  82. *(.text)
  83. ${R_TEXT}
  84. ${RELOCATING+ *(.text.*)}
  85. ${RELOCATING+ *(.gnu.linkonce.t.*)}
  86. *(.glue_7t)
  87. *(.glue_7)
  88. ${CONSTRUCTING+. = ALIGN(8);}
  89. ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
  90. LONG (-1); LONG (-1);
  91. KEEP (*(.ctors));
  92. KEEP (*(.ctor));
  93. KEEP (*(SORT(.ctors.*)));
  94. LONG (0); LONG (0); }
  95. ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
  96. LONG (-1); LONG (-1);
  97. KEEP (*(.dtors));
  98. KEEP (*(.dtor));
  99. KEEP (*(SORT(.dtors.*)));
  100. LONG (0); LONG (0); }
  101. ${RELOCATING+ KEEP (*(.fini))}
  102. /* ??? Why is .gcc_exc here? */
  103. ${RELOCATING+ *(.gcc_exc)}
  104. ${RELOCATING+PROVIDE (etext = .);}
  105. ${RELOCATING+ KEEP (*(.gcc_except_table))}
  106. }
  107. /* The Cygwin32 library uses a section to avoid copying certain data
  108. on fork. This used to be named ".data$nocopy". The linker used
  109. to include this between __data_start__ and __data_end__, but that
  110. breaks building the cygwin32 dll. Instead, we name the section
  111. ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
  112. .data ${RELOCATING+BLOCK(__section_alignment__)} :
  113. {
  114. ${RELOCATING+__data_start__ = . ;}
  115. *(.data)
  116. *(.data2)
  117. ${R_DATA}
  118. KEEP(*(.jcr))
  119. ${RELOCATING+__data_end__ = . ;}
  120. ${RELOCATING+*(.data_cygwin_nocopy)}
  121. }
  122. .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
  123. {
  124. ${R_RDATA}
  125. ${RELOCATING+__rt_psrelocs_start = .;}
  126. *(.rdata_runtime_pseudo_reloc)
  127. ${RELOCATING+__rt_psrelocs_end = .;}
  128. }
  129. ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;}
  130. ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
  131. ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
  132. ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
  133. ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
  134. .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} :
  135. {
  136. KEEP (*(.eh_frame*))
  137. }
  138. .pdata ${RELOCATING+BLOCK(__section_alignment__)} :
  139. {
  140. KEEP(*(.pdata*))
  141. }
  142. .xdata ${RELOCATING+BLOCK(__section_alignment__)} :
  143. {
  144. KEEP(*(.xdata*))
  145. }
  146. .bss ${RELOCATING+BLOCK(__section_alignment__)} :
  147. {
  148. ${RELOCATING+__bss_start__ = . ;}
  149. *(.bss)
  150. *(COMMON)
  151. ${RELOCATING+__bss_end__ = . ;}
  152. }
  153. .edata ${RELOCATING+BLOCK(__section_alignment__)} :
  154. {
  155. *(.edata)
  156. }
  157. /DISCARD/ :
  158. {
  159. *(.debug\$S)
  160. *(.debug\$T)
  161. *(.debug\$F)
  162. *(.drectve)
  163. ${RELOCATING+ *(.note.GNU-stack)}
  164. ${RELOCATING+ *(.gnu.lto_*)}
  165. }
  166. .idata ${RELOCATING+BLOCK(__section_alignment__)} :
  167. {
  168. /* This cannot currently be handled with grouped sections.
  169. See pep.em:sort_sections. */
  170. ${R_IDATA234}
  171. ${RELOCATING+__IAT_start__ = .;}
  172. ${R_IDATA5}
  173. ${RELOCATING+__IAT_end__ = .;}
  174. ${R_IDATA67}
  175. }
  176. .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
  177. {
  178. ${RELOCATING+___crt_xc_start__ = . ;}
  179. ${R_CRT_XC}
  180. ${RELOCATING+___crt_xc_end__ = . ;}
  181. ${RELOCATING+___crt_xi_start__ = . ;}
  182. ${R_CRT_XI}
  183. ${RELOCATING+___crt_xi_end__ = . ;}
  184. ${RELOCATING+___crt_xl_start__ = . ;}
  185. ${R_CRT_XL}
  186. /* ___crt_xl_end__ is defined in the TLS Directory support code */
  187. ${RELOCATING+___crt_xp_start__ = . ;}
  188. ${R_CRT_XP}
  189. ${RELOCATING+___crt_xp_end__ = . ;}
  190. ${RELOCATING+___crt_xt_start__ = . ;}
  191. ${R_CRT_XT}
  192. ${RELOCATING+___crt_xt_end__ = . ;}
  193. }
  194. /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be
  195. at the end of the .tls section. This is important because _tls_start MUST
  196. be at the beginning of the section to enable SECREL32 relocations with TLS
  197. data. */
  198. .tls ${RELOCATING+BLOCK(__section_alignment__)} :
  199. {
  200. ${RELOCATING+___tls_start__ = . ;}
  201. ${R_TLS}
  202. ${RELOCATING+___tls_end__ = . ;}
  203. }
  204. .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
  205. {
  206. /* end is deprecated, don't use it */
  207. ${RELOCATING+PROVIDE (end = .);}
  208. ${RELOCATING+PROVIDE ( _end = .);}
  209. ${RELOCATING+ __end__ = .;}
  210. }
  211. .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : SUBALIGN(4)
  212. {
  213. ${R_RSRC}
  214. }
  215. .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
  216. {
  217. *(.reloc)
  218. }
  219. .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  220. {
  221. *(.stab)
  222. }
  223. .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  224. {
  225. *(.stabstr)
  226. }
  227. /* DWARF debug sections.
  228. Symbols in the DWARF debugging sections are relative to the beginning
  229. of the section. Unlike other targets that fake this by putting the
  230. section VMA at 0, the PE format will not allow it. */
  231. /* DWARF 1.1 and DWARF 2. */
  232. .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  233. {
  234. *(.debug_aranges)
  235. }
  236. .zdebug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  237. {
  238. *(.zdebug_aranges)
  239. }
  240. .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  241. {
  242. *(.debug_pubnames)
  243. }
  244. .zdebug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  245. {
  246. *(.zdebug_pubnames)
  247. }
  248. .debug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  249. {
  250. *(.debug_pubtypes)
  251. }
  252. .zdebug_pubtypes ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  253. {
  254. *(.zdebug_pubtypes)
  255. }
  256. /* DWARF 2. */
  257. .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  258. {
  259. *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*})
  260. }
  261. .zdebug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  262. {
  263. *(.zdebug_info${RELOCATING+ .zdebug.gnu.linkonce.wi.*})
  264. }
  265. .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  266. {
  267. *(.debug_abbrev)
  268. }
  269. .zdebug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  270. {
  271. *(.zdebug_abbrev)
  272. }
  273. .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  274. {
  275. *(.debug_line)
  276. }
  277. .zdebug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  278. {
  279. *(.zdebug_line)
  280. }
  281. .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  282. {
  283. *(.debug_frame)
  284. }
  285. .zdebug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  286. {
  287. *(.zdebug_frame)
  288. }
  289. .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  290. {
  291. *(.debug_str)
  292. }
  293. .zdebug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  294. {
  295. *(.zdebug_str)
  296. }
  297. .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  298. {
  299. *(.debug_loc)
  300. }
  301. .zdebug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  302. {
  303. *(.zdebug_loc)
  304. }
  305. .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  306. {
  307. *(.debug_macinfo)
  308. }
  309. .zdebug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  310. {
  311. *(.zdebug_macinfo)
  312. }
  313. /* SGI/MIPS DWARF 2 extensions. */
  314. .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  315. {
  316. *(.debug_weaknames)
  317. }
  318. .zdebug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  319. {
  320. *(.zdebug_weaknames)
  321. }
  322. .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  323. {
  324. *(.debug_funcnames)
  325. }
  326. .zdebug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  327. {
  328. *(.zdebug_funcnames)
  329. }
  330. .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  331. {
  332. *(.debug_typenames)
  333. }
  334. .zdebug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  335. {
  336. *(.zdebug_typenames)
  337. }
  338. .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  339. {
  340. *(.debug_varnames)
  341. }
  342. .zdebug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  343. {
  344. *(.zdebug_varnames)
  345. }
  346. .debug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  347. {
  348. *(.debug_macro)
  349. }
  350. .zdebug_macro ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  351. {
  352. *(.zdebug_macro)
  353. }
  354. /* DWARF 3. */
  355. .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  356. {
  357. *(.debug_ranges)
  358. }
  359. .zdebug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  360. {
  361. *(.zdebug_ranges)
  362. }
  363. /* DWARF 4. */
  364. .debug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  365. {
  366. *(.debug_types${RELOCATING+ .gnu.linkonce.wt.*})
  367. }
  368. .zdebug_types ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  369. {
  370. *(.zdebug_types${RELOCATING+ .zdebug.gnu.linkonce.wt.*})
  371. }
  372. }
  373. EOF