elfxtensa.sc 23 KB

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