elf.sc 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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 none)
  9. # NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
  10. # empty.
  11. # HAVE_NOINIT - Include a .noinit output section in the script.
  12. # HAVE_PERSISTENT - Include a .persistent output section in the script.
  13. # HAVE_DT_RELR - Include a .relr.dyn output section in the script.
  14. # SMALL_DATA_CTOR - .ctors contains small data.
  15. # SMALL_DATA_DTOR - .dtors contains small data.
  16. # DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
  17. # INITIAL_READONLY_SECTIONS - at start of text segment
  18. # OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
  19. # (e.g., .PARISC.milli)
  20. # OTHER_TEXT_SECTIONS - these get put in .text when relocating
  21. # INITIAL_READWRITE_SECTIONS - at start of data segment (after relro)
  22. # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
  23. # (e.g., .PARISC.global)
  24. # OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
  25. # (e.g. PPC32 .fixup, .got[12])
  26. # OTHER_RELRO_SECTIONS_2 - as above, but after .dynamic in text segment
  27. # OTHER_BSS_SECTIONS - other than .bss .sbss ...
  28. # ATTRS_SECTIONS - at the end
  29. # OTHER_SECTIONS - at the end
  30. # EXECUTABLE_SYMBOLS - symbols that must be defined for an
  31. # executable (e.g., _DYNAMIC_LINK)
  32. # TEXT_START_ADDR - the first byte of the text segment, after any
  33. # headers.
  34. # TEXT_BASE_ADDRESS - the first byte of the text segment.
  35. # TEXT_START_SYMBOLS - symbols that appear at the start of the
  36. # .text section.
  37. # DATA_START_SYMBOLS - symbols that appear at the start of the
  38. # .data section.
  39. # DATA_END_SYMBOLS - symbols that appear at the end of the
  40. # writeable data sections.
  41. # OTHER_GOT_SYMBOLS - symbols defined just before .got.
  42. # OTHER_GOT_SECTIONS - sections just after .got.
  43. # OTHER_PLT_SECTIONS - sections just after .plt.
  44. # OTHER_SDATA_SECTIONS - sections just after .sdata.
  45. # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
  46. # .bss section besides __bss_start.
  47. # PLT_NEXT_DATA - .plt next to data segment when .plt is in text segment.
  48. # DATA_PLT - .plt should be in data segment, not text segment.
  49. # PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
  50. # BSS_PLT - .plt should be in bss segment
  51. # NO_REL_RELOCS - Don't include .rel.* sections in script
  52. # NO_RELA_RELOCS - Don't include .rela.* sections in script
  53. # NON_ALLOC_DYN - Place dynamic sections after data segment.
  54. # TEXT_DYNAMIC - .dynamic in text segment, not data segment.
  55. # EMBEDDED - whether this is for an embedded system.
  56. # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
  57. # start address of shared library.
  58. # INPUT_FILES - INPUT command of files to always include
  59. # WRITABLE_RODATA - if set, the .rodata section should be writable
  60. # INIT_START, INIT_END - statements just before and just after
  61. # combination of .init sections.
  62. # FINI_START, FINI_END - statements just before and just after
  63. # combination of .fini sections.
  64. # STACK_ADDR - start of a .stack section.
  65. # OTHER_SYMBOLS - symbols to place right at the end of the script.
  66. # ETEXT_NAME - name of a symbol for the end of the text section,
  67. # normally etext.
  68. # ETEXT_LAST_IN_RODATA_SEGMENT - emit ETEXT_NAME after all sections in
  69. # the read-only data segment (which may or may not be equal to
  70. # the code segment), instead of after just the code parts.
  71. # SEPARATE_CODE - if set, .text and similar sections containing
  72. # actual machine instructions must be in wholly disjoint
  73. # pages from any other data, including headers
  74. # SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
  75. # so that .got can be in the RELRO area. It should be set to
  76. # the number of bytes in the beginning of .got.plt which can be
  77. # in the RELRO area as well.
  78. # USER_LABEL_PREFIX - prefix to add to user-visible symbols.
  79. # RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names
  80. # for standard sections, without initial "." or suffixes.
  81. #
  82. # When adding sections, do note that the names of some sections are used
  83. # when specifying the start address of the next.
  84. #
  85. # Many sections come in three flavours. There is the 'real' section,
  86. # like ".data". Then there are the per-procedure or per-variable
  87. # sections, generated by -ffunction-sections and -fdata-sections in GCC,
  88. # and useful for --gc-sections, which for a variable "foo" might be
  89. # ".data.foo". Then there are the linkonce sections, for which the linker
  90. # eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
  91. # The exact correspondences are:
  92. #
  93. # Section Linkonce section
  94. # .text .gnu.linkonce.t.foo
  95. # .rodata .gnu.linkonce.r.foo
  96. # .data .gnu.linkonce.d.foo
  97. # .bss .gnu.linkonce.b.foo
  98. # .sdata .gnu.linkonce.s.foo
  99. # .sbss .gnu.linkonce.sb.foo
  100. # .sdata2 .gnu.linkonce.s2.foo
  101. # .sbss2 .gnu.linkonce.sb2.foo
  102. # .debug_info .gnu.linkonce.wi.foo
  103. # .tdata .gnu.linkonce.td.foo
  104. # .tbss .gnu.linkonce.tb.foo
  105. # .lrodata .gnu.linkonce.lr.foo
  106. # .ldata .gnu.linkonce.l.foo
  107. # .lbss .gnu.linkonce.lb.foo
  108. # .noinit .gnu.linkonce.n.foo
  109. # .persistent .gnu.linkonce.p.foo
  110. #
  111. # Each of these can also have corresponding .rel.* and .rela.* sections.
  112. if test -n "$NOP"; then
  113. FILL="=$NOP"
  114. else
  115. FILL=
  116. fi
  117. test -n "$CREATE_SHLIB$CREATE_PIE" && CREATE_PIC=" "
  118. test -z "$RODATA_NAME" && RODATA_NAME=rodata
  119. test -z "$SDATA_NAME" && SDATA_NAME=sdata
  120. test -z "$SBSS_NAME" && SBSS_NAME=sbss
  121. test -z "$BSS_NAME" && BSS_NAME=bss
  122. test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start
  123. test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  124. test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  125. if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
  126. test -z "${ELFSIZE}" && ELFSIZE=32
  127. test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
  128. test "$LD_FLAG" = "N" && DATA_ADDR=.
  129. test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext
  130. test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
  131. test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
  132. if test -z "$DATA_SEGMENT_ALIGN"; then
  133. test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
  134. test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
  135. DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
  136. DATA_SEGMENT_RELRO_END=""
  137. DATA_SEGMENT_END=""
  138. if test -n "${COMMONPAGESIZE}"; then
  139. if test "${SEGMENT_SIZE}" != "${MAXPAGESIZE}"; then
  140. DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
  141. else
  142. DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
  143. fi
  144. DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
  145. DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
  146. fi
  147. fi
  148. if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
  149. INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
  150. fi
  151. if test -z "$PLT"; then
  152. IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
  153. PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }
  154. ${IREL_IN_PLT-$IPLT}"
  155. fi
  156. test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=
  157. if test -z "$GOT"; then
  158. if test -z "$SEPARATE_GOTPLT"; then
  159. GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt) *(.igot.plt)} *(.got)${RELOCATING+ *(.igot)} }"
  160. else
  161. GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }"
  162. GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }"
  163. fi
  164. fi
  165. REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }"
  166. RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }"
  167. REL_IPLT=".rel.iplt ${RELOCATING-0} :
  168. {
  169. ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}
  170. *(.rel.iplt)
  171. ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}
  172. }"
  173. RELA_IPLT=".rela.iplt ${RELOCATING-0} :
  174. {
  175. ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}
  176. *(.rela.iplt)
  177. ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}
  178. }"
  179. DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
  180. RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
  181. 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.*) }"
  182. DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
  183. if test -z "${NO_SMALL_DATA}"; then
  184. SBSS=".${SBSS_NAME} ${RELOCATING-0} :
  185. {
  186. ${RELOCATING+${SBSS_START_SYMBOLS}}
  187. ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)}
  188. ${RELOCATING+*(.dyn${SBSS_NAME})}
  189. *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*})
  190. ${RELOCATING+*(.scommon)}
  191. ${RELOCATING+${SBSS_END_SYMBOLS}}
  192. }"
  193. SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }"
  194. SDATA="/* We want the small data sections together, so single-instruction offsets
  195. can access them all, and initialized data all before uninitialized, so
  196. we can shorten the on-disk segment size. */
  197. .${SDATA_NAME} ${RELOCATING-0} :
  198. {
  199. ${RELOCATING+${SDATA_START_SYMBOLS}}
  200. ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)}
  201. *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*})
  202. }"
  203. SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} :
  204. {
  205. ${RELOCATING+${SDATA2_START_SYMBOLS}}
  206. *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*})
  207. }"
  208. REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) }
  209. .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }"
  210. REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) }
  211. .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }"
  212. REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) }
  213. .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }"
  214. REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) }
  215. .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }"
  216. else
  217. NO_SMALL_DATA=" "
  218. fi
  219. if test -z "${SDATA_GOT}${DATA_GOT}"; then
  220. if test -n "${NO_SMALL_DATA}"; then
  221. DATA_GOT=" "
  222. fi
  223. fi
  224. if test -z "${SDATA_GOT}${DATA_GOT}"; then
  225. if test -z "${NO_SMALL_DATA}"; then
  226. SDATA_GOT=" "
  227. fi
  228. fi
  229. test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
  230. test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
  231. .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
  232. .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
  233. .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
  234. .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
  235. .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
  236. .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
  237. test "${LARGE_SECTIONS}" = "yes" && LARGE_BSS="
  238. .lbss ${RELOCATING-0} :
  239. {
  240. ${RELOCATING+*(.dynlbss)}
  241. *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
  242. ${RELOCATING+*(LARGE_COMMON)}
  243. }"
  244. test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
  245. .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
  246. {
  247. *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
  248. }
  249. .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
  250. {
  251. *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
  252. ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
  253. }"
  254. if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
  255. SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
  256. SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
  257. CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors"
  258. DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors"
  259. else
  260. SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
  261. SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
  262. CTORS_IN_INIT_ARRAY=
  263. DTORS_IN_FINI_ARRAY=
  264. fi
  265. PREINIT_ARRAY=".preinit_array :
  266. {
  267. ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}
  268. KEEP (*(.preinit_array))
  269. ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}
  270. }"
  271. INIT_ARRAY=".init_array :
  272. {
  273. ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}
  274. ${SORT_INIT_ARRAY}
  275. KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY}))
  276. ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}
  277. }"
  278. FINI_ARRAY=".fini_array :
  279. {
  280. ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}
  281. ${SORT_FINI_ARRAY}
  282. KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY}))
  283. ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}
  284. }"
  285. CTOR=".ctors ${CONSTRUCTING-0} :
  286. {
  287. ${CONSTRUCTING+${CTOR_START}}
  288. /* gcc uses crtbegin.o to find the start of
  289. the constructors, so we make sure it is
  290. first. Because this is a wildcard, it
  291. doesn't matter if the user does not
  292. actually link against crtbegin.o; the
  293. linker won't look for a file to match a
  294. wildcard. The wildcard also means that it
  295. doesn't matter which directory crtbegin.o
  296. is in. */
  297. KEEP (*crtbegin.o(.ctors))
  298. KEEP (*crtbegin?.o(.ctors))
  299. /* We don't want to include the .ctor section from
  300. the crtend.o file until after the sorted ctors.
  301. The .ctor section from the crtend file contains the
  302. end of ctors marker and it must be last */
  303. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
  304. KEEP (*(SORT(.ctors.*)))
  305. KEEP (*(.ctors))
  306. ${CONSTRUCTING+${CTOR_END}}
  307. }"
  308. DTOR=".dtors ${CONSTRUCTING-0} :
  309. {
  310. ${CONSTRUCTING+${DTOR_START}}
  311. KEEP (*crtbegin.o(.dtors))
  312. KEEP (*crtbegin?.o(.dtors))
  313. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
  314. KEEP (*(SORT(.dtors.*)))
  315. KEEP (*(.dtors))
  316. ${CONSTRUCTING+${DTOR_END}}
  317. }"
  318. STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
  319. {
  320. ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
  321. *(.stack)
  322. ${RELOCATING+${STACK_SENTINEL}}
  323. }"
  324. test "${HAVE_NOINIT}" = "yes" && NOINIT="
  325. /* This section contains data that is not initialized during load,
  326. or during the application's initialization sequence. */
  327. .noinit (NOLOAD) :
  328. {
  329. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  330. ${RELOCATING+PROVIDE (__noinit_start = .);}
  331. *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*})
  332. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  333. ${RELOCATING+PROVIDE (__noinit_end = .);}
  334. }"
  335. test "${HAVE_PERSISTENT}" = "yes" && PERSISTENT="
  336. /* This section contains data that is initialized during load,
  337. but not during the application's initialization sequence. */
  338. .persistent :
  339. {
  340. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  341. ${RELOCATING+PROVIDE (__persistent_start = .);}
  342. *(.persistent${RELOCATING+ .persistent.* .gnu.linkonce.p.*})
  343. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  344. ${RELOCATING+PROVIDE (__persistent_end = .);}
  345. }"
  346. TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
  347. SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
  348. # Don't bother with separate code segment when there are data sections
  349. # between .plt and .text.
  350. if test -z "$TINY_READONLY_SECTION"; then
  351. case "$LD_FLAG" in
  352. *textonly*)
  353. SEPARATE_TEXT=" "
  354. TEXT_SEGMENT_ALIGN=". = ALIGN(${MAXPAGESIZE});"
  355. ;;
  356. esac
  357. fi
  358. if [ -z "$SEPARATE_CODE" ]; then
  359. SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS"
  360. else
  361. SIZEOF_HEADERS_CODE=
  362. fi
  363. # If this is for an embedded system, don't add SIZEOF_HEADERS.
  364. if [ -z "$EMBEDDED" ]; then
  365. test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}"
  366. else
  367. test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
  368. fi
  369. cat <<EOF
  370. /* Copyright (C) 2014-2022 Free Software Foundation, Inc.
  371. Copying and distribution of this script, with or without modification,
  372. are permitted in any medium without royalty provided the copyright
  373. notice and this notice are preserved. */
  374. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  375. "${LITTLE_OUTPUT_FORMAT}")
  376. OUTPUT_ARCH(${OUTPUT_ARCH})
  377. ${RELOCATING+ENTRY(${ENTRY})}
  378. ${RELOCATING+${LIB_SEARCH_DIRS}}
  379. ${RELOCATING+${CREATE_SHLIB-${EXECUTABLE_SYMBOLS}}}
  380. ${RELOCATING+${INPUT_FILES}}
  381. ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
  382. if gld -r is used and the intermediate file has sections starting
  383. at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
  384. bug. But for now assigning the zero vmas works. */}
  385. SECTIONS
  386. {
  387. ${RELOCATING+${SEPARATE_TEXT-/* Read-only sections, merged into text segment: */}}
  388. ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
  389. ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
  390. ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
  391. EOF
  392. emit_early_ro()
  393. {
  394. cat <<EOF
  395. ${INITIAL_READONLY_SECTIONS}
  396. .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
  397. EOF
  398. }
  399. test -n "${SEPARATE_CODE}" || emit_early_ro
  400. test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
  401. test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
  402. cat > ldscripts/dyntmp.$$ <<EOF
  403. ${TEXT_DYNAMIC+${DYNAMIC}}
  404. .hash ${RELOCATING-0} : { *(.hash) }
  405. .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
  406. .dynsym ${RELOCATING-0} : { *(.dynsym) }
  407. .dynstr ${RELOCATING-0} : { *(.dynstr) }
  408. .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
  409. .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
  410. .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
  411. EOF
  412. if [ "x$COMBRELOC" = x ]; then
  413. COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
  414. else
  415. COMBRELOCCAT="cat > $COMBRELOC"
  416. fi
  417. eval $COMBRELOCCAT <<EOF
  418. ${INITIAL_RELOC_SECTIONS}
  419. .rel.init ${RELOCATING-0} : { *(.rel.init) }
  420. .rela.init ${RELOCATING-0} : { *(.rela.init) }
  421. .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
  422. .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
  423. .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
  424. .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
  425. .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) }
  426. .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) }
  427. ${OTHER_READONLY_RELOC_SECTIONS}
  428. .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) }
  429. .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) }
  430. .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
  431. .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
  432. ${OTHER_READWRITE_RELOC_SECTIONS}
  433. .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
  434. .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
  435. .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
  436. .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
  437. .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
  438. .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
  439. .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
  440. .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
  441. .rel.got ${RELOCATING-0} : { *(.rel.got) }
  442. .rela.got ${RELOCATING-0} : { *(.rela.got) }
  443. ${OTHER_GOT_RELOC_SECTIONS}
  444. ${REL_SDATA}
  445. ${REL_SBSS}
  446. ${REL_SDATA2}
  447. ${REL_SBSS2}
  448. .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) }
  449. .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) }
  450. ${REL_LARGE}
  451. ${IREL_IN_PLT+$REL_IFUNC}
  452. ${IREL_IN_PLT+$RELA_IFUNC}
  453. ${IREL_IN_PLT-$REL_IPLT}
  454. ${IREL_IN_PLT-$RELA_IPLT}
  455. EOF
  456. if [ -n "$COMBRELOC" ]; then
  457. cat >> ldscripts/dyntmp.$$ <<EOF
  458. .rel.dyn ${RELOCATING-0} :
  459. {
  460. EOF
  461. sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
  462. cat >> ldscripts/dyntmp.$$ <<EOF
  463. }
  464. .rela.dyn ${RELOCATING-0} :
  465. {
  466. EOF
  467. sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
  468. cat >> ldscripts/dyntmp.$$ <<EOF
  469. }
  470. EOF
  471. fi
  472. cat >> ldscripts/dyntmp.$$ <<EOF
  473. .rel.plt ${RELOCATING-0} :
  474. {
  475. *(.rel.plt)
  476. ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}}
  477. ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}}
  478. ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}}
  479. }
  480. .rela.plt ${RELOCATING-0} :
  481. {
  482. *(.rela.plt)
  483. ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}}
  484. ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}}
  485. ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}}
  486. }
  487. ${OTHER_PLT_RELOC_SECTIONS}
  488. EOF
  489. emit_dyn()
  490. {
  491. if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
  492. cat ldscripts/dyntmp.$$
  493. else
  494. if test -z "${NO_REL_RELOCS}"; then
  495. sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$
  496. fi
  497. if test -z "${NO_RELA_RELOCS}"; then
  498. sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$
  499. fi
  500. fi
  501. rm -f ldscripts/dyntmp.$$
  502. if test -n "${HAVE_DT_RELR}"; then
  503. echo " .relr.dyn : { *(.relr.dyn) }"
  504. fi
  505. }
  506. test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn
  507. cat <<EOF
  508. ${RELOCATING+${TEXT_SEGMENT_ALIGN}}
  509. .init ${RELOCATING-0}${RELOCATING+${INIT_ADDR}} :
  510. {
  511. ${RELOCATING+${INIT_START}}
  512. KEEP (*(SORT_NONE(.init)))
  513. ${RELOCATING+${INIT_END}}
  514. } ${FILL}
  515. ${TEXT_PLT+${PLT_NEXT_DATA-${PLT} ${OTHER_PLT_SECTIONS}}}
  516. ${TINY_READONLY_SECTION}
  517. .text ${RELOCATING-0} :
  518. {
  519. ${RELOCATING+${TEXT_START_SYMBOLS}}
  520. ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)}
  521. ${RELOCATING+*(.text.exit .text.exit.*)}
  522. ${RELOCATING+*(.text.startup .text.startup.*)}
  523. ${RELOCATING+*(.text.hot .text.hot.*)}
  524. ${RELOCATING+*(SORT(.text.sorted.*))}
  525. *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
  526. /* .gnu.warning sections are handled specially by elf.em. */
  527. *(.gnu.warning)
  528. ${RELOCATING+${OTHER_TEXT_SECTIONS}}
  529. } ${FILL}
  530. .fini ${RELOCATING-0}${RELOCATING+${FINI_ADDR}} :
  531. {
  532. ${RELOCATING+${FINI_START}}
  533. KEEP (*(SORT_NONE(.fini)))
  534. ${RELOCATING+${FINI_END}}
  535. } ${FILL}
  536. ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT-PROVIDE (__${ETEXT_NAME} = .);}}
  537. ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT-PROVIDE (_${ETEXT_NAME} = .);}}
  538. ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT-PROVIDE (${ETEXT_NAME} = .);}}
  539. ${RELOCATING+${TEXT_SEGMENT_ALIGN}}
  540. EOF
  541. if test -n "${SEPARATE_CODE}${SEPARATE_TEXT}"; then
  542. if test -n "${RODATA_ADDR}"; then
  543. RODATA_ADDR="\
  544. SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
  545. else
  546. RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
  547. RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
  548. fi
  549. if test -n "${SHLIB_RODATA_ADDR}"; then
  550. SHLIB_RODATA_ADDR="\
  551. SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
  552. else
  553. SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
  554. SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
  555. fi
  556. cat <<EOF
  557. ${RELOCATING+/* Adjust the address for the rodata segment. We want to adjust up to
  558. the same address within the page on the next page up. */
  559. ${CREATE_SHLIB-${CREATE_PIE-. = ${RODATA_ADDR};}}
  560. ${CREATE_SHLIB+. = ${SHLIB_RODATA_ADDR};}
  561. ${CREATE_PIE+. = ${SHLIB_RODATA_ADDR};}}
  562. EOF
  563. if test -n "${SEPARATE_CODE}"; then
  564. emit_early_ro
  565. emit_dyn
  566. fi
  567. fi
  568. cat <<EOF
  569. ${WRITABLE_RODATA-${RODATA}}
  570. .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) }
  571. ${CREATE_SHLIB-${SDATA2}}
  572. ${CREATE_SHLIB-${SBSS2}}
  573. ${OTHER_READONLY_SECTIONS}
  574. .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr)${RELOCATING+ *(.eh_frame_entry .eh_frame_entry.*)} }
  575. .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame))${RELOCATING+ *(.eh_frame.*)} }
  576. .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
  577. .gnu_extab ${RELOCATING-0} : ONLY_IF_RO { *(.gnu_extab*) }
  578. /* These sections are generated by the Sun/Oracle C++ compiler. */
  579. .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges${RELOCATING+*}) }
  580. ${TEXT_PLT+${PLT_NEXT_DATA+${PLT} ${OTHER_PLT_SECTIONS}}}
  581. ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (__${ETEXT_NAME} = .);}}
  582. ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (_${ETEXT_NAME} = .);}}
  583. ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (${ETEXT_NAME} = .);}}
  584. ${RELOCATING+/* Adjust the address for the data segment. We want to adjust up to
  585. the same address within the page on the next page up. */}
  586. ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
  587. ${CREATE_SHLIB+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}
  588. ${CREATE_PIE+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}
  589. /* Exception handling */
  590. .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame))${RELOCATING+ *(.eh_frame.*)} }
  591. .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) }
  592. .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
  593. .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges${RELOCATING+*}) }
  594. /* Thread Local Storage sections */
  595. .tdata ${RELOCATING-0} :
  596. {
  597. ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__tdata_start = .);}}
  598. *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*})
  599. }
  600. .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
  601. ${RELOCATING+${PREINIT_ARRAY}}
  602. ${RELOCATING+${INIT_ARRAY}}
  603. ${RELOCATING+${FINI_ARRAY}}
  604. ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
  605. ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
  606. .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
  607. ${RELOCATING+${DATARELRO}}
  608. ${OTHER_RELRO_SECTIONS}
  609. ${TEXT_DYNAMIC-${DYNAMIC}}
  610. ${OTHER_RELRO_SECTIONS_2}
  611. ${DATA_GOT+${RELRO_NOW+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}}
  612. ${DATA_GOT+${RELRO_NOW+${GOT}}}
  613. ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
  614. ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
  615. ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
  616. ${INITIAL_READWRITE_SECTIONS}
  617. ${DATA_SDATA+${SDATA}}
  618. ${DATA_SDATA+${OTHER_SDATA_SECTIONS}}
  619. ${DATA_SDATA+${SBSS}}
  620. ${DATA_GOT+${RELRO_NOW-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}}
  621. ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
  622. ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
  623. ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
  624. .data ${RELOCATING-0} :
  625. {
  626. ${RELOCATING+${DATA_START_SYMBOLS}}
  627. *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
  628. ${CONSTRUCTING+SORT(CONSTRUCTORS)}
  629. }
  630. .data1 ${RELOCATING-0} : { *(.data1) }
  631. ${WRITABLE_RODATA+${RODATA}}
  632. ${OTHER_READWRITE_SECTIONS}
  633. ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
  634. ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
  635. ${SDATA_GOT+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}
  636. ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}}
  637. ${SDATA_GOT+${GOT}}
  638. ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
  639. ${DATA_SDATA-${SDATA}}
  640. ${DATA_SDATA-${OTHER_SDATA_SECTIONS}}
  641. ${RELOCATING+${DATA_END_SYMBOLS-${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}_edata = .${CREATE_SHLIB+)}; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
  642. ${PERSISTENT}
  643. ${RELOCATING+. = .;}
  644. ${RELOCATING+${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}__bss_start = .${CREATE_SHLIB+)};}
  645. ${RELOCATING+${OTHER_BSS_SYMBOLS}}
  646. ${DATA_SDATA-${SBSS}}
  647. ${BSS_PLT+${PLT}}
  648. .${BSS_NAME} ${RELOCATING-0} :
  649. {
  650. ${RELOCATING+*(.dynbss)}
  651. *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*})
  652. ${RELOCATING+*(COMMON)
  653. /* Align here to ensure that the .bss section occupies space up to
  654. _end. Align after .bss to ensure correct alignment even if the
  655. .bss section disappears because there are no input sections.
  656. FIXME: Why do we need it? When there is no .bss section, we do not
  657. pad the .data section. */
  658. . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
  659. }
  660. ${OTHER_BSS_SECTIONS}
  661. ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}}
  662. ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
  663. ${NOINIT}
  664. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  665. EOF
  666. LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});"
  667. SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});"
  668. cat <<EOF
  669. ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}}
  670. ${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}
  671. ${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}
  672. ${LARGE_SECTIONS}
  673. ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}}
  674. ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  675. ${RELOCATING+${OTHER_END_SYMBOLS}}
  676. ${RELOCATING+${END_SYMBOLS-${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}_end = .${CREATE_SHLIB+)}; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
  677. ${RELOCATING+${DATA_SEGMENT_END}}
  678. ${TINY_DATA_SECTION}
  679. ${TINY_BSS_SECTION}
  680. ${STACK_ADDR+${STACK}}
  681. EOF
  682. test -z "${NON_ALLOC_DYN}" || emit_dyn
  683. cat <<EOF
  684. /* Stabs debugging sections. */
  685. .stab 0 : { *(.stab) }
  686. .stabstr 0 : { *(.stabstr) }
  687. .stab.excl 0 : { *(.stab.excl) }
  688. .stab.exclstr 0 : { *(.stab.exclstr) }
  689. .stab.index 0 : { *(.stab.index) }
  690. .stab.indexstr 0 : { *(.stab.indexstr) }
  691. .comment 0 : { *(.comment) }
  692. .gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) }
  693. EOF
  694. . $srcdir/scripttempl/DWARF.sc
  695. cat <<EOF
  696. ${ATTRS_SECTIONS}
  697. ${OTHER_SECTIONS}
  698. ${RELOCATING+${OTHER_SYMBOLS}}
  699. ${RELOCATING+${DISCARDED}}
  700. }
  701. EOF