elfi370.sc 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. # Copyright (C) 2014-2015 Free Software Foundation, Inc.
  2. #
  3. # Copying and distribution of this file, with or without modification,
  4. # are permitted in any medium without royalty provided the copyright
  5. # notice and this notice are preserved.
  6. #
  7. # This is just a raw copy of elfppc.sc and has not been otherwise modified
  8. #
  9. # Unusual variables checked by this code:
  10. # NOP - four byte opcode for no-op (defaults to 0)
  11. # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
  12. # OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
  13. # (e.g., .PARISC.milli)
  14. # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
  15. # (e.g., .PARISC.global)
  16. # ATTRS_SECTIONS - at the end
  17. # OTHER_SECTIONS - at the end
  18. # EXECUTABLE_SYMBOLS - symbols that must be defined for an
  19. # executable (e.g., _DYNAMIC_LINK)
  20. # TEXT_START_SYMBOLS - symbols that appear at the start of the
  21. # .text section.
  22. # DATA_START_SYMBOLS - symbols that appear at the start of the
  23. # .data section.
  24. # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
  25. # .bss section besides __bss_start.
  26. #
  27. # When adding sections, do note that the names of some sections are used
  28. # when specifying the start address of the next.
  29. test -z "$ENTRY" && ENTRY=_start
  30. test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  31. test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  32. test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
  33. test "$LD_FLAG" = "N" && DATA_ADDR=.
  34. SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) }"
  35. SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) }"
  36. INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
  37. PLT=".plt ${RELOCATING-0} : { *(.plt) }"
  38. cat <<EOF
  39. /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
  40. Copying and distribution of this script, with or without modification,
  41. are permitted in any medium without royalty provided the copyright
  42. notice and this notice are preserved. */
  43. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  44. "${LITTLE_OUTPUT_FORMAT}")
  45. OUTPUT_ARCH(${ARCH})
  46. ${RELOCATING+ENTRY(${ENTRY})}
  47. ${RELOCATING+${LIB_SEARCH_DIRS}}
  48. ${RELOCATING+/* Do we need any of these for elf?
  49. __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
  50. ${RELOCATING+${EXECUTABLE_SYMBOLS}}
  51. ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
  52. if gld -r is used and the intermediate file has sections starting
  53. at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
  54. bug. But for now assigning the zero vmas works. */}
  55. ${RELOCATING+PROVIDE (__stack = 0);}
  56. SECTIONS
  57. {
  58. /* Read-only sections, merged into text segment: */
  59. ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}}
  60. ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}}
  61. ${CREATE_SHLIB-${INTERP}}
  62. .hash ${RELOCATING-0} : { *(.hash) }
  63. .dynsym ${RELOCATING-0} : { *(.dynsym) }
  64. .dynstr ${RELOCATING-0} : { *(.dynstr) }
  65. .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
  66. .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
  67. .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
  68. .rela.text ${RELOCATING-0} :
  69. { *(.rela.text) *(.rela.gnu.linkonce.t*) }
  70. .rela.data ${RELOCATING-0} :
  71. { *(.rela.data) *(.rela.gnu.linkonce.d*) }
  72. .rela.rodata ${RELOCATING-0} :
  73. { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
  74. .rela.got ${RELOCATING-0} : { *(.rela.got) }
  75. .rela.got1 ${RELOCATING-0} : { *(.rela.got1) }
  76. .rela.got2 ${RELOCATING-0} : { *(.rela.got2) }
  77. .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
  78. .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
  79. .rela.init ${RELOCATING-0} : { *(.rela.init) }
  80. .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
  81. .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
  82. .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
  83. .rela.sdata ${RELOCATING-0} : { *(.rela.sdata) }
  84. .rela.sbss ${RELOCATING-0} : { *(.rela.sbss) }
  85. .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2) }
  86. .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2) }
  87. .text ${RELOCATING-0} :
  88. {
  89. ${RELOCATING+${TEXT_START_SYMBOLS}}
  90. *(.text)
  91. /* .gnu.warning sections are handled specially by elf32.em. */
  92. *(.gnu.warning)
  93. *(.gnu.linkonce.t*)
  94. } =${NOP-0}
  95. .init ${RELOCATING-0} : { *(.init) } =${NOP-0}
  96. .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0}
  97. .rodata ${RELOCATING-0} : { *(.rodata) *(.gnu.linkonce.r*) }
  98. .rodata1 ${RELOCATING-0} : { *(.rodata1) }
  99. ${RELOCATING+_etext = .;}
  100. ${RELOCATING+PROVIDE (etext = .);}
  101. ${CREATE_SHLIB-${SDATA2}}
  102. ${CREATE_SHLIB-${SBSS2}}
  103. ${OTHER_READONLY_SECTIONS}
  104. /* Adjust the address for the data segment. We want to adjust up to
  105. the same address within the page on the next page up. It would
  106. be more correct to do this:
  107. ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (ALIGN(8) & (${MAXPAGESIZE} - 1))};}
  108. The current expression does not correctly handle the case of a
  109. text segment ending precisely at the end of a page; it causes the
  110. data segment to skip a page. The above expression does not have
  111. this problem, but it will currently (2/95) cause BFD to allocate
  112. a single segment, combining both text and data, for this case.
  113. This will prevent the text segment from being shared among
  114. multiple executions of the program; I think that is more
  115. important than losing a page of the virtual address space (note
  116. that no actual memory is lost; the page which is skipped can not
  117. be referenced). */
  118. ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};}
  119. .data ${RELOCATING-0} :
  120. {
  121. ${RELOCATING+${DATA_START_SYMBOLS}}
  122. *(.data)
  123. *(.gnu.linkonce.d*)
  124. ${CONSTRUCTING+CONSTRUCTORS}
  125. }
  126. .data1 ${RELOCATING-0} : { *(.data1) }
  127. ${OTHER_READWRITE_SECTIONS}
  128. .got1 ${RELOCATING-0} : { *(.got1) }
  129. .dynamic ${RELOCATING-0} : { *(.dynamic) }
  130. /* Put .ctors and .dtors next to the .got2 section, so that the pointers
  131. get relocated with -mrelocatable. Also put in the .fixup pointers.
  132. The current compiler no longer needs this, but keep it around for 2.7.2 */
  133. ${RELOCATING+PROVIDE (_GOT2_START_ = .);}
  134. .got2 ${RELOCATING-0} : { *(.got2) }
  135. ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);}
  136. .ctors ${RELOCATING-0} : { *(.ctors) }
  137. ${RELOCATING+PROVIDE (__CTOR_END__ = .);}
  138. ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);}
  139. .dtors ${RELOCATING-0} : { *(.dtors) }
  140. ${RELOCATING+PROVIDE (__DTOR_END__ = .);}
  141. ${RELOCATING+PROVIDE (_FIXUP_START_ = .);}
  142. .fixup ${RELOCATING-0} : { *(.fixup) }
  143. ${RELOCATING+PROVIDE (_FIXUP_END_ = .);}
  144. ${RELOCATING+PROVIDE (_GOT2_END_ = .);}
  145. ${RELOCATING+PROVIDE (_GOT_START_ = .);}
  146. .got ${RELOCATING-0} : { *(.got) }
  147. .got.plt ${RELOCATING-0} : { *(.got.plt) }
  148. ${CREATE_SHLIB+${SDATA2}}
  149. ${CREATE_SHLIB+${SBSS2}}
  150. ${RELOCATING+PROVIDE (_GOT_END_ = .);}
  151. /* We want the small data sections together, so single-instruction offsets
  152. can access them all, and initialized data all before uninitialized, so
  153. we can shorten the on-disk segment size. */
  154. .sdata ${RELOCATING-0} : { *(.sdata) }
  155. ${RELOCATING+_edata = .;}
  156. ${RELOCATING+PROVIDE (edata = .);}
  157. .sbss ${RELOCATING-0} :
  158. {
  159. ${RELOCATING+PROVIDE (__sbss_start = .);}
  160. *(.sbss)
  161. *(.scommon)
  162. *(.dynsbss)
  163. ${RELOCATING+PROVIDE (__sbss_end = .);}
  164. }
  165. ${PLT}
  166. .bss ${RELOCATING-0} :
  167. {
  168. ${RELOCATING+${OTHER_BSS_SYMBOLS}}
  169. ${RELOCATING+PROVIDE (__bss_start = .);}
  170. *(.dynbss)
  171. *(.bss)
  172. *(COMMON)
  173. }
  174. ${RELOCATING+_end = . ;}
  175. ${RELOCATING+PROVIDE (end = .);}
  176. /* These are needed for ELF backends which have not yet been
  177. converted to the new style linker. */
  178. .stab 0 : { *(.stab) }
  179. .stabstr 0 : { *(.stabstr) }
  180. EOF
  181. . $srcdir/scripttempl/DWARF.sc
  182. cat <<EOF
  183. ${ATTRS_SECTIONS}
  184. ${OTHER_SECTIONS}
  185. }
  186. EOF