1 # Copyright (C) 2014-2018 Free Software Foundation, Inc.
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.
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
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 # INITIAL_READWRITE_SECTIONS - at start of data segment (after relro)
19 # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
20 # (e.g., .PARISC.global)
21 # OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
22 # (e.g. PPC32 .fixup, .got[12])
23 # OTHER_RELRO_SECTIONS_2 - as above, but after .dynamic in text segment
24 # OTHER_BSS_SECTIONS - other than .bss .sbss ...
25 # ATTRS_SECTIONS - at the end
26 # OTHER_SECTIONS - at the end
27 # EXECUTABLE_SYMBOLS - symbols that must be defined for an
28 # executable (e.g., _DYNAMIC_LINK)
29 # TEXT_START_ADDR - the first byte of the text segment, after any
31 # TEXT_BASE_ADDRESS - the first byte of the text segment.
32 # TEXT_START_SYMBOLS - symbols that appear at the start of the
34 # DATA_START_SYMBOLS - symbols that appear at the start of the
36 # DATA_END_SYMBOLS - symbols that appear at the end of the
37 # writeable data sections.
38 # OTHER_GOT_SYMBOLS - symbols defined just before .got.
39 # OTHER_GOT_SECTIONS - sections just after .got.
40 # OTHER_PLT_SECTIONS - sections just after .plt.
41 # OTHER_SDATA_SECTIONS - sections just after .sdata.
42 # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
43 # .bss section besides __bss_start.
44 # PLT_NEXT_DATA - .plt next to data segment when .plt is in text segment.
45 # DATA_PLT - .plt should be in data segment, not text segment.
46 # PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
47 # BSS_PLT - .plt should be in bss segment
48 # NO_REL_RELOCS - Don't include .rel.* sections in script
49 # NO_RELA_RELOCS - Don't include .rela.* sections in script
50 # NON_ALLOC_DYN - Place dynamic sections after data segment.
51 # TEXT_DYNAMIC - .dynamic in text segment, not data segment.
52 # EMBEDDED - whether this is for an embedded system.
53 # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
54 # start address of shared library.
55 # INPUT_FILES - INPUT command of files to always include
56 # WRITABLE_RODATA - if set, the .rodata section should be writable
57 # INIT_START, INIT_END - statements just before and just after
58 # combination of .init sections.
59 # FINI_START, FINI_END - statements just before and just after
60 # combination of .fini sections.
61 # STACK_ADDR - start of a .stack section.
62 # OTHER_SYMBOLS - symbols to place right at the end of the script.
63 # ETEXT_NAME - name of a symbol for the end of the text section,
65 # SEPARATE_CODE - if set, .text and similar sections containing
66 # actual machine instructions must be in wholly disjoint
67 # pages from any other data, including headers
68 # SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
69 # so that .got can be in the RELRO area. It should be set to
70 # the number of bytes in the beginning of .got.plt which can be
71 # in the RELRO area as well.
72 # USER_LABEL_PREFIX - prefix to add to user-visible symbols.
73 # RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names
74 # for standard sections, without initial "." or suffixes.
76 # When adding sections, do note that the names of some sections are used
77 # when specifying the start address of the next.
80 # Many sections come in three flavours. There is the 'real' section,
81 # like ".data". Then there are the per-procedure or per-variable
82 # sections, generated by -ffunction-sections and -fdata-sections in GCC,
83 # and useful for --gc-sections, which for a variable "foo" might be
84 # ".data.foo". Then there are the linkonce sections, for which the linker
85 # eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
86 # The exact correspondences are:
88 # Section Linkonce section
89 # .text .gnu.linkonce.t.foo
90 # .rodata .gnu.linkonce.r.foo
91 # .data .gnu.linkonce.d.foo
92 # .bss .gnu.linkonce.b.foo
93 # .sdata .gnu.linkonce.s.foo
94 # .sbss .gnu.linkonce.sb.foo
95 # .sdata2 .gnu.linkonce.s2.foo
96 # .sbss2 .gnu.linkonce.sb2.foo
97 # .debug_info .gnu.linkonce.wi.foo
98 # .tdata .gnu.linkonce.td.foo
99 # .tbss .gnu.linkonce.tb.foo
100 # .lrodata .gnu.linkonce.lr.foo
101 # .ldata .gnu.linkonce.l.foo
102 # .lbss .gnu.linkonce.lb.foo
104 # Each of these can also have corresponding .rel.* and .rela.* sections.
106 if test -n "$NOP"; then
112 test -z "$RODATA_NAME" && RODATA_NAME=rodata
113 test -z "$SDATA_NAME" && SDATA_NAME=sdata
114 test -z "$SBSS_NAME" && SBSS_NAME=sbss
115 test -z "$BSS_NAME" && BSS_NAME=bss
116 test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start
117 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
118 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
119 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
120 test -z "${ELFSIZE}" && ELFSIZE=32
121 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
122 test "$LD_FLAG" = "N" && DATA_ADDR=.
123 test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext
124 test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
125 test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
126 if test -z "$DATA_SEGMENT_ALIGN"; then
127 test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
128 test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
129 DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
130 DATA_SEGMENT_RELRO_END=""
132 if test -n "${COMMONPAGESIZE}"; then
133 if test "${SEGMENT_SIZE}" != "${MAXPAGESIZE}"; then
134 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
136 DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
138 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
139 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
142 if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
143 INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
145 if test -z "$PLT"; then
146 IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
147 PLT=".plt ${RELOCATING-0} : { *(.plt)${IREL_IN_PLT+ *(.iplt)} }
148 ${IREL_IN_PLT-$IPLT}"
150 test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=
151 if test -z "$GOT"; then
152 if test -z "$SEPARATE_GOTPLT"; then
153 GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }"
155 GOT=".got ${RELOCATING-0} : { *(.got) *(.igot) }"
156 GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) }"
159 REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }"
160 RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }"
161 REL_IPLT=".rel.iplt ${RELOCATING-0} :
163 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}
165 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}
167 RELA_IPLT=".rela.iplt ${RELOCATING-0} :
169 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}
171 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}
173 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
174 RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
175 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.*) }"
176 DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
177 if test -z "${NO_SMALL_DATA}"; then
178 SBSS=".${SBSS_NAME} ${RELOCATING-0} :
180 ${RELOCATING+${SBSS_START_SYMBOLS}}
181 ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)}
183 *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*})
185 ${RELOCATING+${SBSS_END_SYMBOLS}}
187 SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }"
188 SDATA="/* We want the small data sections together, so single-instruction offsets
189 can access them all, and initialized data all before uninitialized, so
190 we can shorten the on-disk segment size. */
191 .${SDATA_NAME} ${RELOCATING-0} :
193 ${RELOCATING+${SDATA_START_SYMBOLS}}
194 ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)}
195 *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*})
197 SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} :
199 ${RELOCATING+${SDATA2_START_SYMBOLS}}
200 *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*})
202 REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) }
203 .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }"
204 REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) }
205 .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }"
206 REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) }
207 .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }"
208 REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) }
209 .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }"
213 if test -z "${SDATA_GOT}${DATA_GOT}"; then
214 if test -n "${NO_SMALL_DATA}"; then
218 if test -z "${SDATA_GOT}${DATA_GOT}"; then
219 if test -z "${NO_SMALL_DATA}"; then
223 test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
224 test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
225 .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
226 .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
227 .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
228 .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
229 .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
230 .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
231 test "${LARGE_SECTIONS}" = "yes" && LARGE_BSS="
232 .lbss ${RELOCATING-0} :
235 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
238 test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
239 .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
241 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
243 .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
245 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
246 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
248 if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
249 SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
250 SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
251 CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors"
252 DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors"
254 SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
255 SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
259 INIT_ARRAY=".init_array ${RELOCATING-0} :
261 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
263 KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY}))
264 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
266 FINI_ARRAY=".fini_array ${RELOCATING-0} :
268 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
270 KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY}))
271 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
273 CTOR=".ctors ${CONSTRUCTING-0} :
275 ${CONSTRUCTING+${CTOR_START}}
276 /* gcc uses crtbegin.o to find the start of
277 the constructors, so we make sure it is
278 first. Because this is a wildcard, it
279 doesn't matter if the user does not
280 actually link against crtbegin.o; the
281 linker won't look for a file to match a
282 wildcard. The wildcard also means that it
283 doesn't matter which directory crtbegin.o
286 KEEP (*crtbegin.o(.ctors))
287 KEEP (*crtbegin?.o(.ctors))
289 /* We don't want to include the .ctor section from
290 the crtend.o file until after the sorted ctors.
291 The .ctor section from the crtend file contains the
292 end of ctors marker and it must be last */
294 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
295 KEEP (*(SORT(.ctors.*)))
297 ${CONSTRUCTING+${CTOR_END}}
299 DTOR=".dtors ${CONSTRUCTING-0} :
301 ${CONSTRUCTING+${DTOR_START}}
302 KEEP (*crtbegin.o(.dtors))
303 KEEP (*crtbegin?.o(.dtors))
304 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
305 KEEP (*(SORT(.dtors.*)))
307 ${CONSTRUCTING+${DTOR_END}}
309 STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
311 ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
313 ${RELOCATING+${STACK_SENTINEL}}
316 TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
317 SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
319 if [ -z "$SEPARATE_CODE" ]; then
320 SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS"
325 # If this is for an embedded system, don't add SIZEOF_HEADERS.
326 if [ -z "$EMBEDDED" ]; then
327 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}"
329 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
333 /* Copyright (C) 2014-2018 Free Software Foundation, Inc.
335 Copying and distribution of this script, with or without modification,
336 are permitted in any medium without royalty provided the copyright
337 notice and this notice are preserved. */
339 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
340 "${LITTLE_OUTPUT_FORMAT}")
341 OUTPUT_ARCH(${OUTPUT_ARCH})
342 ${RELOCATING+ENTRY(${ENTRY})}
344 ${RELOCATING+${LIB_SEARCH_DIRS}}
345 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
346 ${RELOCATING+${INPUT_FILES}}
347 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
348 if gld -r is used and the intermediate file has sections starting
349 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
350 bug. But for now assigning the zero vmas works. */}
354 /* Read-only sections, merged into text segment: */
355 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
356 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
357 ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
363 ${INITIAL_READONLY_SECTIONS}
364 .note.gnu.build-id : { *(.note.gnu.build-id) }
368 test -n "${SEPARATE_CODE}" || emit_early_ro
370 test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
371 test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
372 cat > ldscripts/dyntmp.$$ <<EOF
373 ${TEXT_DYNAMIC+${DYNAMIC}}
374 .hash ${RELOCATING-0} : { *(.hash) }
375 .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
376 .dynsym ${RELOCATING-0} : { *(.dynsym) }
377 .dynstr ${RELOCATING-0} : { *(.dynstr) }
378 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
379 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
380 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
383 if [ "x$COMBRELOC" = x ]; then
384 COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
386 COMBRELOCCAT="cat > $COMBRELOC"
388 eval $COMBRELOCCAT <<EOF
389 ${INITIAL_RELOC_SECTIONS}
390 .rel.init ${RELOCATING-0} : { *(.rel.init) }
391 .rela.init ${RELOCATING-0} : { *(.rela.init) }
392 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
393 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
394 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
395 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
396 .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) }
397 .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) }
398 ${OTHER_READONLY_RELOC_SECTIONS}
399 .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) }
400 .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) }
401 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
402 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
403 ${OTHER_READWRITE_RELOC_SECTIONS}
404 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
405 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
406 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
407 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
408 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
409 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
410 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
411 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
412 .rel.got ${RELOCATING-0} : { *(.rel.got) }
413 .rela.got ${RELOCATING-0} : { *(.rela.got) }
414 ${OTHER_GOT_RELOC_SECTIONS}
419 .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) }
420 .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) }
422 ${IREL_IN_PLT+$REL_IFUNC}
423 ${IREL_IN_PLT+$RELA_IFUNC}
424 ${IREL_IN_PLT-$REL_IPLT}
425 ${IREL_IN_PLT-$RELA_IPLT}
428 if [ -n "$COMBRELOC" ]; then
429 cat >> ldscripts/dyntmp.$$ <<EOF
430 .rel.dyn ${RELOCATING-0} :
433 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
434 cat >> ldscripts/dyntmp.$$ <<EOF
436 .rela.dyn ${RELOCATING-0} :
439 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
440 cat >> ldscripts/dyntmp.$$ <<EOF
445 cat >> ldscripts/dyntmp.$$ <<EOF
446 .rel.plt ${RELOCATING-0} :
449 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}}
450 ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}}
451 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}}
453 .rela.plt ${RELOCATING-0} :
456 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}}
457 ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}}
458 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}}
460 ${OTHER_PLT_RELOC_SECTIONS}
465 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
466 cat ldscripts/dyntmp.$$
468 if test -z "${NO_REL_RELOCS}"; then
469 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$
471 if test -z "${NO_RELA_RELOCS}"; then
472 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$
475 rm -f ldscripts/dyntmp.$$
478 test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn
481 .init ${RELOCATING-0}${RELOCATING+${INIT_ADDR}} :
483 ${RELOCATING+${INIT_START}}
484 KEEP (*(SORT_NONE(.init)))
485 ${RELOCATING+${INIT_END}}
488 ${TEXT_PLT+${PLT_NEXT_DATA-${PLT} ${OTHER_PLT_SECTIONS}}}
489 ${TINY_READONLY_SECTION}
490 .text ${RELOCATING-0} :
492 ${RELOCATING+${TEXT_START_SYMBOLS}}
493 ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)}
494 ${RELOCATING+*(.text.exit .text.exit.*)}
495 ${RELOCATING+*(.text.startup .text.startup.*)}
496 ${RELOCATING+*(.text.hot .text.hot.*)}
497 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
498 /* .gnu.warning sections are handled specially by elf32.em. */
500 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
502 .fini ${RELOCATING-0}${RELOCATING+${FINI_ADDR}} :
504 ${RELOCATING+${FINI_START}}
505 KEEP (*(SORT_NONE(.fini)))
506 ${RELOCATING+${FINI_END}}
508 ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
509 ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
510 ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
513 if test -n "${SEPARATE_CODE}"; then
514 if test -n "${RODATA_ADDR}"; then
516 SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
518 RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
519 RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
521 if test -n "${SHLIB_RODATA_ADDR}"; then
523 SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
525 SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
526 SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
529 /* Adjust the address for the rodata segment. We want to adjust up to
530 the same address within the page on the next page up. */
531 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR};}}}
532 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}}
533 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}}
540 ${WRITABLE_RODATA-${RODATA}}
541 .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) }
542 ${CREATE_SHLIB-${SDATA2}}
543 ${CREATE_SHLIB-${SBSS2}}
544 ${OTHER_READONLY_SECTIONS}
545 .eh_frame_hdr : { *(.eh_frame_hdr) ${RELOCATING+*(.eh_frame_entry .eh_frame_entry.*)} }
546 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} }
547 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table
548 .gcc_except_table.*) }
549 .gnu_extab ${RELOCATING-0} : ONLY_IF_RO { *(.gnu_extab*) }
550 /* These sections are generated by the Sun/Oracle C++ compiler. */
551 .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges
552 .exception_ranges*) }
553 ${TEXT_PLT+${PLT_NEXT_DATA+${PLT} ${OTHER_PLT_SECTIONS}}}
555 /* Adjust the address for the data segment. We want to adjust up to
556 the same address within the page on the next page up. */
557 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
558 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
559 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
561 /* Exception handling */
562 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} }
563 .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) }
564 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
565 .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
567 /* Thread Local Storage sections */
568 .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
569 .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
571 .preinit_array ${RELOCATING-0} :
573 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
574 KEEP (*(.preinit_array))
575 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
577 ${RELOCATING+${INIT_ARRAY}}
578 ${RELOCATING+${FINI_ARRAY}}
579 ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
580 ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
581 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
583 ${RELOCATING+${DATARELRO}}
584 ${OTHER_RELRO_SECTIONS}
585 ${TEXT_DYNAMIC-${DYNAMIC}}
586 ${OTHER_RELRO_SECTIONS_2}
587 ${DATA_GOT+${RELRO_NOW+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}}
588 ${DATA_GOT+${RELRO_NOW+${GOT}}}
589 ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
590 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
591 ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
592 ${INITIAL_READWRITE_SECTIONS}
593 ${DATA_SDATA+${SDATA}}
594 ${DATA_SDATA+${OTHER_SDATA_SECTIONS}}
595 ${DATA_SDATA+${SBSS}}
596 ${DATA_GOT+${RELRO_NOW-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}}
597 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
598 ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
600 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
602 .data ${RELOCATING-0} :
604 ${RELOCATING+${DATA_START_SYMBOLS}}
605 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
606 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
608 .data1 ${RELOCATING-0} : { *(.data1) }
609 ${WRITABLE_RODATA+${RODATA}}
610 ${OTHER_READWRITE_SECTIONS}
611 ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
612 ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
613 ${SDATA_GOT+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}
614 ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}}
616 ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
617 ${DATA_SDATA-${SDATA}}
618 ${DATA_SDATA-${OTHER_SDATA_SECTIONS}}
619 ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
621 ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;}
622 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
623 ${DATA_SDATA-${SBSS}}
625 .${BSS_NAME} ${RELOCATING-0} :
627 ${RELOCATING+*(.dynbss)}
628 *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*})
630 /* Align here to ensure that the .bss section occupies space up to
631 _end. Align after .bss to ensure correct alignment even if the
632 .bss section disappears because there are no input sections.
633 FIXME: Why do we need it? When there is no .bss section, we don't
634 pad the .data section. */
635 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
637 ${OTHER_BSS_SECTIONS}
638 ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}}
639 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
640 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
643 LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});"
644 SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});"
647 ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}}
648 ${RELOCATING+${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}}
649 ${RELOCATING+${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}}
651 ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}}
652 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
653 ${RELOCATING+${OTHER_END_SYMBOLS}}
654 ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
655 ${RELOCATING+${DATA_SEGMENT_END}}
658 ${STACK_ADDR+${STACK}}
661 test -z "${NON_ALLOC_DYN}" || emit_dyn
664 /* Stabs debugging sections. */
665 .stab 0 : { *(.stab) }
666 .stabstr 0 : { *(.stabstr) }
667 .stab.excl 0 : { *(.stab.excl) }
668 .stab.exclstr 0 : { *(.stab.exclstr) }
669 .stab.index 0 : { *(.stab.index) }
670 .stab.indexstr 0 : { *(.stab.indexstr) }
672 .comment 0 : { *(.comment) }
676 . $srcdir/scripttempl/DWARF.sc
681 ${RELOCATING+${OTHER_SYMBOLS}}
682 ${RELOCATING+${DISCARDED}}