elf64hppa.sc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. # Copyright (C) 2014-2022 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} : {${RELOCATING+ *(.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. ${RELOCATING+*(.dynsbss)}
  140. *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
  141. ${RELOCATING+*(.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+${USER_LABEL_PREFIX}_stack = .;}
  256. *(.stack)
  257. ${RELOCATING+${STACK_SENTINEL}}
  258. }"
  259. TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
  260. SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
  261. # If this is for an embedded system, don't add SIZEOF_HEADERS.
  262. if [ -z "$EMBEDDED" ]; then
  263. test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
  264. else
  265. test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
  266. fi
  267. cat <<EOF
  268. /* Copyright (C) 2014-2022 Free Software Foundation, Inc.
  269. Copying and distribution of this script, with or without modification,
  270. are permitted in any medium without royalty provided the copyright
  271. notice and this notice are preserved. */
  272. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  273. "${LITTLE_OUTPUT_FORMAT}")
  274. OUTPUT_ARCH(${OUTPUT_ARCH})
  275. ${RELOCATING+ENTRY(${ENTRY})}
  276. ${RELOCATING+${LIB_SEARCH_DIRS}}
  277. ${RELOCATING+${EXECUTABLE_SYMBOLS}}
  278. ${RELOCATING+${INPUT_FILES}}
  279. ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
  280. if gld -r is used and the intermediate file has sections starting
  281. at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
  282. bug. But for now assigning the zero vmas works. */}
  283. SECTIONS
  284. {
  285. /* Read-only sections, merged into text segment: */
  286. ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
  287. ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
  288. ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
  289. ${INITIAL_READONLY_SECTIONS}
  290. .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
  291. EOF
  292. test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
  293. test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
  294. cat > ldscripts/dyntmp.$$ <<EOF
  295. ${TEXT_DYNAMIC+${DYNAMIC}}
  296. .hash ${RELOCATING-0} : { *(.hash) }
  297. .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
  298. .dynsym ${RELOCATING-0} : { *(.dynsym) }
  299. .dynstr ${RELOCATING-0} : { *(.dynstr) }
  300. .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
  301. .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
  302. .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
  303. EOF
  304. if [ "x$COMBRELOC" = x ]; then
  305. COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
  306. else
  307. COMBRELOCCAT="cat > $COMBRELOC"
  308. fi
  309. eval $COMBRELOCCAT <<EOF
  310. .rel.init ${RELOCATING-0} : { *(.rel.init) }
  311. .rela.init ${RELOCATING-0} : { *(.rela.init) }
  312. .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
  313. .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
  314. .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
  315. .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
  316. .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
  317. .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
  318. ${OTHER_READONLY_RELOC_SECTIONS}
  319. .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) }
  320. .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) }
  321. .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
  322. .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
  323. .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
  324. .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
  325. .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
  326. .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
  327. .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
  328. .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
  329. .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
  330. .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
  331. .rel.got ${RELOCATING-0} : { *(.rel.got) }
  332. .rela.got ${RELOCATING-0} : { *(.rela.got) }
  333. ${OTHER_GOT_RELOC_SECTIONS}
  334. ${REL_SDATA}
  335. ${REL_SBSS}
  336. ${REL_SDATA2}
  337. ${REL_SBSS2}
  338. .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
  339. .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
  340. ${REL_LARGE}
  341. EOF
  342. if [ -n "$COMBRELOC" ]; then
  343. cat >> ldscripts/dyntmp.$$ <<EOF
  344. .rel.dyn ${RELOCATING-0} :
  345. {
  346. EOF
  347. sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
  348. cat >> ldscripts/dyntmp.$$ <<EOF
  349. }
  350. .rel.ifunc.dyn ${RELOCATING-0} :
  351. {
  352. *(.rel.ifunc.*)
  353. }
  354. .rela.dyn ${RELOCATING-0} :
  355. {
  356. EOF
  357. sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
  358. cat >> ldscripts/dyntmp.$$ <<EOF
  359. }
  360. .rela.ifunc.dyn ${RELOCATING-0} :
  361. {
  362. *(.rela.ifunc.*)
  363. }
  364. EOF
  365. fi
  366. cat >> ldscripts/dyntmp.$$ <<EOF
  367. .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
  368. .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
  369. ${OTHER_PLT_RELOC_SECTIONS}
  370. EOF
  371. if test -z "${NON_ALLOC_DYN}"; then
  372. if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
  373. cat ldscripts/dyntmp.$$
  374. else
  375. if test -z "${NO_REL_RELOCS}"; then
  376. sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
  377. fi
  378. if test -z "${NO_RELA_RELOCS}"; then
  379. sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
  380. fi
  381. fi
  382. rm -f ldscripts/dyntmp.$$
  383. fi
  384. cat <<EOF
  385. .init ${RELOCATING-0} :
  386. {
  387. ${RELOCATING+${INIT_START}}
  388. KEEP (*(SORT_NONE(.init)))
  389. ${RELOCATING+${INIT_END}}
  390. } =${NOP-0}
  391. ${TEXT_PLT+${PLT}}
  392. ${TINY_READONLY_SECTION}
  393. .text ${RELOCATING-0} :
  394. {
  395. ${RELOCATING+${TEXT_START_SYMBOLS}}
  396. *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
  397. /* .gnu.warning sections are handled specially by elf.em. */
  398. *(.gnu.warning)
  399. ${RELOCATING+${OTHER_TEXT_SECTIONS}}
  400. } =${NOP-0}
  401. .fini ${RELOCATING-0} :
  402. {
  403. ${RELOCATING+${FINI_START}}
  404. KEEP (*(SORT_NONE(.fini)))
  405. ${RELOCATING+${FINI_END}}
  406. } =${NOP-0}
  407. ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
  408. ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
  409. ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
  410. ${WRITABLE_RODATA-${RODATA}}
  411. .rodata1 ${RELOCATING-0} : { *(.rodata1) }
  412. ${CREATE_SHLIB-${SDATA2}}
  413. ${CREATE_SHLIB-${SBSS2}}
  414. ${OTHER_READONLY_SECTIONS}
  415. .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr) }
  416. .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  417. .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
  418. /* Adjust the address for the data segment. We want to adjust up to
  419. the same address within the page on the next page up. */
  420. ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
  421. ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
  422. ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
  423. /* Exception handling */
  424. .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
  425. .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
  426. /* Thread Local Storage sections */
  427. .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
  428. .preinit_array ${RELOCATING-0} :
  429. {
  430. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
  431. KEEP (*(.preinit_array))
  432. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
  433. }
  434. ${RELOCATING+${INIT_ARRAY}}
  435. ${RELOCATING+${FINI_ARRAY}}
  436. ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
  437. ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
  438. .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
  439. ${RELOCATING+${DATARELRO}}
  440. ${OTHER_RELRO_SECTIONS}
  441. ${TEXT_DYNAMIC-${DYNAMIC}}
  442. ${DATA_GOT+${RELRO_NOW+${GOT}}}
  443. ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
  444. ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
  445. ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
  446. ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
  447. ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
  448. ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
  449. .data ${RELOCATING-0} :
  450. {
  451. ${RELOCATING+${DATA_START_SYMBOLS}}
  452. *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
  453. ${CONSTRUCTING+SORT(CONSTRUCTORS)}
  454. }
  455. .data1 ${RELOCATING-0} : { *(.data1) }
  456. ${WRITABLE_RODATA+${RODATA}}
  457. ${OTHER_READWRITE_SECTIONS}
  458. ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
  459. ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
  460. ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
  461. ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}
  462. ${SDATA_GOT+${GOT}}
  463. ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
  464. ${SDATA}
  465. ${OTHER_SDATA_SECTIONS}
  466. ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
  467. ${RELOCATING+__bss_start = .;}
  468. ${RELOCATING+${OTHER_BSS_SYMBOLS}}
  469. ${SBSS}
  470. ${BSS_PLT+${PLT}}
  471. .bss ${RELOCATING-0} :
  472. {
  473. ${RELOCATING+*(.dynbss)}
  474. *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
  475. ${RELOCATING+*(COMMON)
  476. /* Align here to ensure that the .bss section occupies space up to
  477. _end. Align after .bss to ensure correct alignment even if the
  478. .bss section disappears because there are no input sections.
  479. FIXME: Why do we need it? When there is no .bss section, we do not
  480. pad the .data section. */
  481. . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
  482. }
  483. ${OTHER_BSS_SECTIONS}
  484. ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
  485. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  486. ${LARGE_SECTIONS}
  487. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  488. ${RELOCATING+${OTHER_END_SYMBOLS}}
  489. ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
  490. ${RELOCATING+${DATA_SEGMENT_END}}
  491. ${TINY_DATA_SECTION}
  492. ${TINY_BSS_SECTION}
  493. ${STACK_ADDR+${STACK}}
  494. EOF
  495. if test -n "${NON_ALLOC_DYN}"; then
  496. if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
  497. cat ldscripts/dyntmp.$$
  498. else
  499. if test -z "${NO_REL_RELOCS}"; then
  500. sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
  501. fi
  502. if test -z "${NO_RELA_RELOCS}"; then
  503. sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
  504. fi
  505. fi
  506. rm -f ldscripts/dyntmp.$$
  507. fi
  508. cat <<EOF
  509. /* Stabs debugging sections. */
  510. .stab 0 : { *(.stab) }
  511. .stabstr 0 : { *(.stabstr) }
  512. .stab.excl 0 : { *(.stab.excl) }
  513. .stab.exclstr 0 : { *(.stab.exclstr) }
  514. .stab.index 0 : { *(.stab.index) }
  515. .stab.indexstr 0 : { *(.stab.indexstr) }
  516. .comment 0 : { *(.comment) }
  517. EOF
  518. . $srcdir/scripttempl/DWARF.sc
  519. cat <<EOF
  520. ${ATTRS_SECTIONS}
  521. ${OTHER_SECTIONS}
  522. ${RELOCATING+${OTHER_SYMBOLS}}
  523. ${RELOCATING+${DISCARDED}}
  524. }
  525. EOF