elf64hppa.sc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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. # Unusual variables checked by this code:
  8. # NOP - four byte opcode for no-op (defaults to 0)
  9. # NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
  10. # empty.
  11. # SMALL_DATA_CTOR - .ctors contains small data.
  12. # SMALL_DATA_DTOR - .dtors contains small data.
  13. # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
  14. # INITIAL_READONLY_SECTIONS - at start of text segment
  15. # OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
  16. # (e.g., .PARISC.milli)
  17. # OTHER_TEXT_SECTIONS - these get put in .text when relocating
  18. # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
  19. # (e.g., .PARISC.global)
  20. # OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
  21. # (e.g. PPC32 .fixup, .got[12])
  22. # OTHER_BSS_SECTIONS - other than .bss .sbss ...
  23. # ATTRS_SECTIONS - at the end
  24. # OTHER_SECTIONS - at the end
  25. # EXECUTABLE_SYMBOLS - symbols that must be defined for an
  26. # executable (e.g., _DYNAMIC_LINK)
  27. # TEXT_START_ADDR - the first byte of the text segment, after any
  28. # headers.
  29. # TEXT_BASE_ADDRESS - the first byte of the text segment.
  30. # TEXT_START_SYMBOLS - symbols that appear at the start of the
  31. # .text section.
  32. # DATA_START_SYMBOLS - symbols that appear at the start of the
  33. # .data section.
  34. # DATA_END_SYMBOLS - symbols that appear at the end of the
  35. # writeable data sections.
  36. # OTHER_GOT_SYMBOLS - symbols defined just before .got.
  37. # OTHER_GOT_SECTIONS - sections just after .got.
  38. # OTHER_SDATA_SECTIONS - sections just after .sdata.
  39. # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
  40. # .bss section besides __bss_start.
  41. # DATA_PLT - .plt should be in data segment, not text segment.
  42. # PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
  43. # BSS_PLT - .plt should be in bss segment
  44. # NO_REL_RELOCS - Don't include .rel.* sections in script
  45. # NO_RELA_RELOCS - Don't include .rela.* sections in script
  46. # NON_ALLOC_DYN - Place dynamic sections after data segment.
  47. # TEXT_DYNAMIC - .dynamic in text segment, not data segment.
  48. # EMBEDDED - whether this is for an embedded system.
  49. # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
  50. # start address of shared library.
  51. # INPUT_FILES - INPUT command of files to always include
  52. # WRITABLE_RODATA - if set, the .rodata section should be writable
  53. # INIT_START, INIT_END - statements just before and just after
  54. # combination of .init sections.
  55. # FINI_START, FINI_END - statements just before and just after
  56. # combination of .fini sections.
  57. # STACK_ADDR - start of a .stack section.
  58. # OTHER_SYMBOLS - symbols to place right at the end of the script.
  59. # ETEXT_NAME - name of a symbol for the end of the text section,
  60. # normally etext.
  61. # SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
  62. # so that .got can be in the RELRO area. It should be set to
  63. # the number of bytes in the beginning of .got.plt which can be
  64. # in the RELRO area as well.
  65. # USER_LABEL_PREFIX - prefix to add to user-visible symbols.
  66. #
  67. # When adding sections, do note that the names of some sections are used
  68. # when specifying the start address of the next.
  69. #
  70. # Many sections come in three flavours. There is the 'real' section,
  71. # like ".data". Then there are the per-procedure or per-variable
  72. # sections, generated by -ffunction-sections and -fdata-sections in GCC,
  73. # and useful for --gc-sections, which for a variable "foo" might be
  74. # ".data.foo". Then there are the linkonce sections, for which the linker
  75. # eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
  76. # The exact correspondences are:
  77. #
  78. # Section Linkonce section
  79. # .text .gnu.linkonce.t.foo
  80. # .rodata .gnu.linkonce.r.foo
  81. # .data .gnu.linkonce.d.foo
  82. # .bss .gnu.linkonce.b.foo
  83. # .sdata .gnu.linkonce.s.foo
  84. # .sbss .gnu.linkonce.sb.foo
  85. # .sdata2 .gnu.linkonce.s2.foo
  86. # .sbss2 .gnu.linkonce.sb2.foo
  87. # .debug_info .gnu.linkonce.wi.foo
  88. # .tdata .gnu.linkonce.td.foo
  89. # .tbss .gnu.linkonce.tb.foo
  90. # .lrodata .gnu.linkonce.lr.foo
  91. # .ldata .gnu.linkonce.l.foo
  92. # .lbss .gnu.linkonce.lb.foo
  93. #
  94. # Each of these can also have corresponding .rel.* and .rela.* sections.
  95. test -z "$ENTRY" && ENTRY=_start
  96. test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  97. test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  98. if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
  99. test -z "${ELFSIZE}" && ELFSIZE=32
  100. test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
  101. test "$LD_FLAG" = "N" && DATA_ADDR=.
  102. test -z "${ETEXT_NAME}" && ETEXT_NAME=etext
  103. test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
  104. test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
  105. test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
  106. test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
  107. DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
  108. DATA_SEGMENT_RELRO_END=""
  109. DATA_SEGMENT_END=""
  110. if test -n "${COMMONPAGESIZE}"; then
  111. DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
  112. DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
  113. DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
  114. fi
  115. if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
  116. INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
  117. fi
  118. if test -z "$PLT"; then
  119. PLT=".plt ${RELOCATING-0} : { *(.plt) }"
  120. fi
  121. test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
  122. if test -z "$GOT"; then
  123. if test -z "$SEPARATE_GOTPLT"; then
  124. GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }"
  125. else
  126. GOT=".got ${RELOCATING-0} : { *(.got) }"
  127. GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }"
  128. fi
  129. fi
  130. DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
  131. RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
  132. DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
  133. DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
  134. if test -z "${NO_SMALL_DATA}"; then
  135. SBSS=".sbss ${RELOCATING-0} :
  136. {
  137. ${RELOCATING+${SBSS_START_SYMBOLS}}
  138. ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)}
  139. *(.dynsbss)
  140. *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
  141. *(.scommon)
  142. ${RELOCATING+${SBSS_END_SYMBOLS}}
  143. }"
  144. SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
  145. SDATA="/* We want the small data sections together, so single-instruction offsets
  146. can access them all, and initialized data all before uninitialized, so
  147. we can shorten the on-disk segment size. */
  148. .sdata ${RELOCATING-0} :
  149. {
  150. ${RELOCATING+${SDATA_START_SYMBOLS}}
  151. ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}
  152. *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
  153. }"
  154. SDATA2=".sdata2 ${RELOCATING-0} :
  155. {
  156. ${RELOCATING+${SDATA2_START_SYMBOLS}}
  157. *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*})
  158. }"
  159. REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
  160. .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
  161. REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
  162. .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
  163. REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
  164. .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
  165. REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
  166. .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
  167. else
  168. NO_SMALL_DATA=" "
  169. fi
  170. if test -z "${DATA_GOT}"; then
  171. if test -n "${NO_SMALL_DATA}"; then
  172. DATA_GOT=" "
  173. fi
  174. fi
  175. if test -z "${SDATA_GOT}"; then
  176. if test -z "${NO_SMALL_DATA}"; then
  177. SDATA_GOT=" "
  178. fi
  179. fi
  180. test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
  181. test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
  182. .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
  183. .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
  184. .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
  185. .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
  186. .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
  187. .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
  188. test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS="
  189. ${OTHER_BSS_SECTIONS}
  190. .lbss ${RELOCATING-0} :
  191. {
  192. *(.dynlbss)
  193. *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
  194. *(LARGE_COMMON)
  195. }"
  196. test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
  197. .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
  198. {
  199. *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
  200. }
  201. .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
  202. {
  203. *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
  204. ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
  205. }"
  206. INIT_ARRAY=".init_array ${RELOCATING-0} :
  207. {
  208. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
  209. KEEP (*(SORT(.init_array.*)))
  210. KEEP (*(.init_array))
  211. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
  212. }"
  213. FINI_ARRAY=".fini_array ${RELOCATING-0} :
  214. {
  215. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
  216. KEEP (*(SORT(.fini_array.*)))
  217. KEEP (*(.fini_array))
  218. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
  219. }"
  220. CTOR=".ctors ${CONSTRUCTING-0} :
  221. {
  222. ${CONSTRUCTING+${CTOR_START}}
  223. /* gcc uses crtbegin.o to find the start of
  224. the constructors, so we make sure it is
  225. first. Because this is a wildcard, it
  226. doesn't matter if the user does not
  227. actually link against crtbegin.o; the
  228. linker won't look for a file to match a
  229. wildcard. The wildcard also means that it
  230. doesn't matter which directory crtbegin.o
  231. is in. */
  232. KEEP (*crtbegin.o(.ctors))
  233. KEEP (*crtbegin?.o(.ctors))
  234. /* We don't want to include the .ctor section from
  235. the crtend.o file until after the sorted ctors.
  236. The .ctor section from the crtend file contains the
  237. end of ctors marker and it must be last */
  238. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
  239. KEEP (*(SORT(.ctors.*)))
  240. KEEP (*(.ctors))
  241. ${CONSTRUCTING+${CTOR_END}}
  242. }"
  243. DTOR=".dtors ${CONSTRUCTING-0} :
  244. {
  245. ${CONSTRUCTING+${DTOR_START}}
  246. KEEP (*crtbegin.o(.dtors))
  247. KEEP (*crtbegin?.o(.dtors))
  248. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
  249. KEEP (*(SORT(.dtors.*)))
  250. KEEP (*(.dtors))
  251. ${CONSTRUCTING+${DTOR_END}}
  252. }"
  253. STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
  254. {
  255. ${RELOCATING+_stack = .;}
  256. *(.stack)
  257. }"
  258. TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
  259. SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
  260. # If this is for an embedded system, don't add SIZEOF_HEADERS.
  261. if [ -z "$EMBEDDED" ]; then
  262. test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
  263. else
  264. test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
  265. fi
  266. cat <<EOF
  267. /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
  268. Copying and distribution of this script, with or without modification,
  269. are permitted in any medium without royalty provided the copyright
  270. notice and this notice are preserved. */
  271. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  272. "${LITTLE_OUTPUT_FORMAT}")
  273. OUTPUT_ARCH(${OUTPUT_ARCH})
  274. ${RELOCATING+ENTRY(${ENTRY})}
  275. ${RELOCATING+${LIB_SEARCH_DIRS}}
  276. ${RELOCATING+${EXECUTABLE_SYMBOLS}}
  277. ${RELOCATING+${INPUT_FILES}}
  278. ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
  279. if gld -r is used and the intermediate file has sections starting
  280. at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
  281. bug. But for now assigning the zero vmas works. */}
  282. SECTIONS
  283. {
  284. /* Read-only sections, merged into text segment: */
  285. ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
  286. ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
  287. ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
  288. ${INITIAL_READONLY_SECTIONS}
  289. .note.gnu.build-id : { *(.note.gnu.build-id) }
  290. EOF
  291. test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
  292. test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
  293. cat > ldscripts/dyntmp.$$ <<EOF
  294. ${TEXT_DYNAMIC+${DYNAMIC}}
  295. .hash ${RELOCATING-0} : { *(.hash) }
  296. .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
  297. .dynsym ${RELOCATING-0} : { *(.dynsym) }
  298. .dynstr ${RELOCATING-0} : { *(.dynstr) }
  299. .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
  300. .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
  301. .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
  302. EOF
  303. if [ "x$COMBRELOC" = x ]; then
  304. COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
  305. else
  306. COMBRELOCCAT="cat > $COMBRELOC"
  307. fi
  308. eval $COMBRELOCCAT <<EOF
  309. .rel.init ${RELOCATING-0} : { *(.rel.init) }
  310. .rela.init ${RELOCATING-0} : { *(.rela.init) }
  311. .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
  312. .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
  313. .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
  314. .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
  315. .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
  316. .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
  317. ${OTHER_READONLY_RELOC_SECTIONS}
  318. .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) }
  319. .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) }
  320. .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
  321. .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
  322. .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
  323. .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
  324. .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
  325. .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
  326. .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
  327. .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
  328. .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
  329. .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
  330. .rel.got ${RELOCATING-0} : { *(.rel.got) }
  331. .rela.got ${RELOCATING-0} : { *(.rela.got) }
  332. ${OTHER_GOT_RELOC_SECTIONS}
  333. ${REL_SDATA}
  334. ${REL_SBSS}
  335. ${REL_SDATA2}
  336. ${REL_SBSS2}
  337. .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
  338. .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
  339. ${REL_LARGE}
  340. EOF
  341. if [ -n "$COMBRELOC" ]; then
  342. cat >> ldscripts/dyntmp.$$ <<EOF
  343. .rel.dyn ${RELOCATING-0} :
  344. {
  345. EOF
  346. sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
  347. cat >> ldscripts/dyntmp.$$ <<EOF
  348. }
  349. .rel.ifunc.dyn ${RELOCATING-0} :
  350. {
  351. *(.rel.ifunc.*)
  352. }
  353. .rela.dyn ${RELOCATING-0} :
  354. {
  355. EOF
  356. sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
  357. cat >> ldscripts/dyntmp.$$ <<EOF
  358. }
  359. .rela.ifunc.dyn ${RELOCATING-0} :
  360. {
  361. *(.rela.ifunc.*)
  362. }
  363. EOF
  364. fi
  365. cat >> ldscripts/dyntmp.$$ <<EOF
  366. .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
  367. .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
  368. ${OTHER_PLT_RELOC_SECTIONS}
  369. EOF
  370. if test -z "${NON_ALLOC_DYN}"; then
  371. if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
  372. cat ldscripts/dyntmp.$$
  373. else
  374. if test -z "${NO_REL_RELOCS}"; then
  375. sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
  376. fi
  377. if test -z "${NO_RELA_RELOCS}"; then
  378. sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
  379. fi
  380. fi
  381. rm -f ldscripts/dyntmp.$$
  382. fi
  383. cat <<EOF
  384. .init ${RELOCATING-0} :
  385. {
  386. ${RELOCATING+${INIT_START}}
  387. KEEP (*(.init))
  388. ${RELOCATING+${INIT_END}}
  389. } =${NOP-0}
  390. ${TEXT_PLT+${PLT}}
  391. ${TINY_READONLY_SECTION}
  392. .text ${RELOCATING-0} :
  393. {
  394. ${RELOCATING+${TEXT_START_SYMBOLS}}
  395. *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
  396. /* .gnu.warning sections are handled specially by elf32.em. */
  397. *(.gnu.warning)
  398. ${RELOCATING+${OTHER_TEXT_SECTIONS}}
  399. } =${NOP-0}
  400. .fini ${RELOCATING-0} :
  401. {
  402. ${RELOCATING+${FINI_START}}
  403. KEEP (*(.fini))
  404. ${RELOCATING+${FINI_END}}
  405. } =${NOP-0}
  406. ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
  407. ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
  408. ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
  409. ${WRITABLE_RODATA-${RODATA}}
  410. .rodata1 ${RELOCATING-0} : { *(.rodata1) }
  411. ${CREATE_SHLIB-${SDATA2}}
  412. ${CREATE_SHLIB-${SBSS2}}
  413. ${OTHER_READONLY_SECTIONS}
  414. .eh_frame_hdr : { *(.eh_frame_hdr) }
  415. .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  416. .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
  417. /* Adjust the address for the data segment. We want to adjust up to
  418. the same address within the page on the next page up. */
  419. ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
  420. ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
  421. ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
  422. /* Exception handling */
  423. .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
  424. .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
  425. /* Thread Local Storage sections */
  426. .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
  427. .preinit_array ${RELOCATING-0} :
  428. {
  429. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
  430. KEEP (*(.preinit_array))
  431. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
  432. }
  433. ${RELOCATING+${INIT_ARRAY}}
  434. ${RELOCATING+${FINI_ARRAY}}
  435. ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
  436. ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
  437. .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
  438. ${RELOCATING+${DATARELRO}}
  439. ${OTHER_RELRO_SECTIONS}
  440. ${TEXT_DYNAMIC-${DYNAMIC}}
  441. ${DATA_GOT+${RELRO_NOW+${GOT}}}
  442. ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
  443. ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
  444. ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
  445. ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
  446. ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
  447. ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
  448. .data ${RELOCATING-0} :
  449. {
  450. ${RELOCATING+${DATA_START_SYMBOLS}}
  451. *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
  452. ${CONSTRUCTING+SORT(CONSTRUCTORS)}
  453. }
  454. .data1 ${RELOCATING-0} : { *(.data1) }
  455. ${WRITABLE_RODATA+${RODATA}}
  456. ${OTHER_READWRITE_SECTIONS}
  457. ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
  458. ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
  459. ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
  460. ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}
  461. ${SDATA_GOT+${GOT}}
  462. ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
  463. ${SDATA}
  464. ${OTHER_SDATA_SECTIONS}
  465. ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
  466. ${RELOCATING+__bss_start = .;}
  467. ${RELOCATING+${OTHER_BSS_SYMBOLS}}
  468. ${SBSS}
  469. ${BSS_PLT+${PLT}}
  470. .bss ${RELOCATING-0} :
  471. {
  472. *(.dynbss)
  473. *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
  474. *(COMMON)
  475. /* Align here to ensure that the .bss section occupies space up to
  476. _end. Align after .bss to ensure correct alignment even if the
  477. .bss section disappears because there are no input sections.
  478. FIXME: Why do we need it? When there is no .bss section, we don't
  479. pad the .data section. */
  480. ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
  481. }
  482. ${OTHER_BSS_SECTIONS}
  483. ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
  484. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  485. ${LARGE_SECTIONS}
  486. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  487. ${RELOCATING+${OTHER_END_SYMBOLS}}
  488. ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
  489. ${RELOCATING+${DATA_SEGMENT_END}}
  490. EOF
  491. if test -n "${NON_ALLOC_DYN}"; then
  492. if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
  493. cat ldscripts/dyntmp.$$
  494. else
  495. if test -z "${NO_REL_RELOCS}"; then
  496. sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
  497. fi
  498. if test -z "${NO_RELA_RELOCS}"; then
  499. sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
  500. fi
  501. fi
  502. rm -f ldscripts/dyntmp.$$
  503. fi
  504. cat <<EOF
  505. /* Stabs debugging sections. */
  506. .stab 0 : { *(.stab) }
  507. .stabstr 0 : { *(.stabstr) }
  508. .stab.excl 0 : { *(.stab.excl) }
  509. .stab.exclstr 0 : { *(.stab.exclstr) }
  510. .stab.index 0 : { *(.stab.index) }
  511. .stab.indexstr 0 : { *(.stab.indexstr) }
  512. .comment 0 : { *(.comment) }
  513. EOF
  514. . $srcdir/scripttempl/DWARF.sc
  515. cat <<EOF
  516. ${TINY_DATA_SECTION}
  517. ${TINY_BSS_SECTION}
  518. ${STACK_ADDR+${STACK}}
  519. ${ATTRS_SECTIONS}
  520. ${OTHER_SECTIONS}
  521. ${RELOCATING+${OTHER_SYMBOLS}}
  522. ${RELOCATING+${DISCARDED}}
  523. }
  524. EOF