mcorepe.sc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. # Linker script for MCore 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. if test "$RELOCATING"; then
  42. # Can't use ${RELOCATING+blah "blah" blah} for this,
  43. # because bash 2.x will lose the doublequotes.
  44. cat <<EOF
  45. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  46. "${LITTLE_OUTPUT_FORMAT}")
  47. EOF
  48. fi
  49. cat <<EOF
  50. /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
  51. Copying and distribution of this script, with or without modification,
  52. are permitted in any medium without royalty provided the copyright
  53. notice and this notice are preserved. */
  54. ${LIB_SEARCH_DIRS}
  55. ${RELOCATING+ENTRY (_mainCRTStartup)}
  56. SECTIONS
  57. {
  58. .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
  59. {
  60. ${RELOCATING+ *(.init)}
  61. *(.text)
  62. ${R_TEXT}
  63. ${RELOCATING+ *(.text.*)}
  64. *(.glue_7t)
  65. *(.glue_7)
  66. ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
  67. LONG (-1); *(.ctors); *(.ctor); LONG (0); }
  68. ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
  69. LONG (-1); *(.dtors); *(.dtor); LONG (0); }
  70. ${RELOCATING+ *(.fini)}
  71. /* ??? Why is .gcc_exc here? */
  72. ${RELOCATING+ *(.gcc_exc)}
  73. ${RELOCATING+ etext = .;}
  74. *(.gcc_except_table)
  75. }
  76. /* The Cygwin32 library uses a section to avoid copying certain data
  77. on fork. This used to be named ".data$nocopy". The linker used
  78. to include this between __data_start__ and __data_end__, but that
  79. breaks building the cygwin32 dll. Instead, we name the section
  80. ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
  81. .data ${RELOCATING+BLOCK(__section_alignment__)} :
  82. {
  83. ${RELOCATING+__data_start__ = . ;}
  84. *(.data)
  85. *(.data2)
  86. ${R_DATA}
  87. ${RELOCATING+__data_end__ = . ;}
  88. ${RELOCATING+*(.data_cygwin_nocopy)}
  89. }
  90. .bss ${RELOCATING+BLOCK(__section_alignment__)} :
  91. {
  92. ${RELOCATING+__bss_start__ = . ;}
  93. *(.bss)
  94. *(COMMON)
  95. ${RELOCATING+__bss_end__ = . ;}
  96. }
  97. .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
  98. {
  99. *(.rdata)
  100. ${R_RDATA}
  101. *(.eh_frame)
  102. }
  103. .edata ${RELOCATING+BLOCK(__section_alignment__)} :
  104. {
  105. *(.edata)
  106. }
  107. /DISCARD/ :
  108. {
  109. *(.debug\$S)
  110. *(.debug\$T)
  111. *(.debug\$F)
  112. *(.drectve)
  113. }
  114. .idata ${RELOCATING+BLOCK(__section_alignment__)} :
  115. {
  116. /* This cannot currently be handled with grouped sections.
  117. See pe.em:sort_sections. */
  118. ${R_IDATA}
  119. }
  120. .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
  121. {
  122. ${R_CRT}
  123. }
  124. .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
  125. {
  126. /* end is deprecated, don't use it */
  127. ${RELOCATING+ end = .;}
  128. ${RELOCATING+ _end = .;}
  129. ${RELOCATING+ __end__ = .;}
  130. }
  131. .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
  132. {
  133. *(.reloc)
  134. }
  135. .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
  136. {
  137. *(.rsrc)
  138. ${R_RSRC}
  139. }
  140. .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  141. {
  142. [ .stab ]
  143. }
  144. .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
  145. {
  146. [ .stabstr ]
  147. }
  148. .stack 0x80000 :
  149. {
  150. _stack = .;
  151. *(.stack)
  152. }
  153. }
  154. EOF