epocpe.sc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. R_DATA='*(SORT(.data$*))'
  21. R_RDATA='*(SORT(.rdata$*))'
  22. R_IDATA='
  23. SORT(*)(.idata$2)
  24. SORT(*)(.idata$3)
  25. /* These zeroes mark the end of the import list. */
  26. LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
  27. SORT(*)(.idata$4)
  28. SORT(*)(.idata$5)
  29. SORT(*)(.idata$6)
  30. SORT(*)(.idata$7)'
  31. R_CRT='*(SORT(.CRT$*))'
  32. R_RSRC='*(SORT(.rsrc$*))'
  33. else
  34. R_TEXT=
  35. R_DATA=
  36. R_RDATA=
  37. R_IDATA=
  38. R_CRT=
  39. R_RSRC=
  40. fi
  41. cat <<EOF
  42. /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
  43. Copying and distribution of this script, with or without modification,
  44. are permitted in any medium without royalty provided the copyright
  45. notice and this notice are preserved. */
  46. ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
  47. ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
  48. ${LIB_SEARCH_DIRS}
  49. ${RELOCATING+ENTRY (_mainCRTStartup)}
  50. SECTIONS
  51. {
  52. .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
  53. {
  54. ${RELOCATING+ *(.init)}
  55. *(.text)
  56. ${R_TEXT}
  57. *(.glue_7t)
  58. *(.glue_7)
  59. ${RELOCATING+ *(.text.*)}
  60. ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
  61. LONG (-1); *(.ctors); *(.ctor); LONG (0); }
  62. ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
  63. LONG (-1); *(.dtors); *(.dtor); LONG (0); }
  64. ${RELOCATING+ *(.fini)}
  65. /* ??? Why is .gcc_exc here? */
  66. ${RELOCATING+ *(.gcc_exc)}
  67. ${RELOCATING+ etext = .;}
  68. *(.gcc_except_table)
  69. /* For EPOC the read only data is located at the end of the .text
  70. section */
  71. *(.rdata)
  72. ${R_RDATA}
  73. *(.eh_frame)
  74. }
  75. /* The Cygwin32 library uses a section to avoid copying certain data
  76. on fork. This used to be named ".data$nocopy". The linker used
  77. to include this between __data_start__ and __data_end__, but that
  78. breaks building the cygwin32 dll. Instead, we name the section
  79. ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
  80. .data ${RELOCATING+BLOCK(__section_alignment__)} :
  81. {
  82. ${RELOCATING+__data_start__ = . ;}
  83. *(.data)
  84. *(.data2)
  85. ${R_DATA}
  86. ${RELOCATING+__data_end__ = . ;}
  87. ${RELOCATING+*(.data_cygwin_nocopy)}
  88. }
  89. .bss ${RELOCATING+BLOCK(__section_alignment__)} :
  90. {
  91. ${RELOCATING+__bss_start__ = . ;}
  92. *(.bss)
  93. *(COMMON)
  94. ${RELOCATING+__bss_end__ = . ;}
  95. }
  96. .edata ${RELOCATING+BLOCK(__section_alignment__)} :
  97. {
  98. *(.edata)
  99. }
  100. /DISCARD/ :
  101. {
  102. *(.debug\$S)
  103. *(.debug\$T)
  104. *(.debug\$F)
  105. *(.drectve)
  106. }
  107. .idata ${RELOCATING+BLOCK(__section_alignment__)} :
  108. {
  109. /* This cannot currently be handled with grouped sections.
  110. See pe.em:sort_sections. */
  111. ${R_IDATA}
  112. }
  113. .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
  114. {
  115. ${R_CRT}
  116. }
  117. .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
  118. {
  119. /* end is deprecated, don't use it */
  120. ${RELOCATING+ end = .;}
  121. ${RELOCATING+ _end = .;}
  122. ${RELOCATING+ __end__ = .;}
  123. }
  124. .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
  125. {
  126. *(.reloc)
  127. }
  128. .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
  129. {
  130. *(.rsrc)
  131. ${R_RSRC}
  132. }
  133. .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  134. {
  135. [ .stab ]
  136. }
  137. .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  138. {
  139. [ .stabstr ]
  140. }
  141. }
  142. EOF