1 # Copyright (C) 2014-2022 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 # 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
34 # TEXT_BASE_ADDRESS - the first byte of the text segment.
35 # TEXT_START_SYMBOLS - symbols that appear at the start of the
37 # DATA_START_SYMBOLS - symbols that appear at the start of the
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,
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.
82 # When adding sections, do note that the names of some sections are used
83 # when specifying the start address of the next.
86 # Many sections come in three flavours. There is the 'real' section,
87 # like ".data". Then there are the per-procedure or per-variable
88 # sections, generated by -ffunction-sections and -fdata-sections in GCC,
89 # and useful for --gc-sections, which for a variable "foo" might be
90 # ".data.foo". Then there are the linkonce sections, for which the linker
91 # eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
92 # The exact correspondences are:
94 # Section Linkonce section
95 # .text .gnu.linkonce.t.foo
96 # .rodata .gnu.linkonce.r.foo
97 # .data .gnu.linkonce.d.foo
98 # .bss .gnu.linkonce.b.foo
99 # .sdata .gnu.linkonce.s.foo
100 # .sbss .gnu.linkonce.sb.foo
101 # .sdata2 .gnu.linkonce.s2.foo
102 # .sbss2 .gnu.linkonce.sb2.foo
103 # .debug_info .gnu.linkonce.wi.foo
104 # .tdata .gnu.linkonce.td.foo
105 # .tbss .gnu.linkonce.tb.foo
106 # .lrodata .gnu.linkonce.lr.foo
107 # .ldata .gnu.linkonce.l.foo
108 # .lbss .gnu.linkonce.lb.foo
109 # .noinit .gnu.linkonce.n.foo
110 # .persistent .gnu.linkonce.p.foo
112 # Each of these can also have corresponding .rel.* and .rela.* sections.
114 if test -n "$NOP"; then
120 test -n "$CREATE_SHLIB$CREATE_PIE" && CREATE_PIC=" "
121 test -z "$RODATA_NAME" && RODATA_NAME=rodata
122 test -z "$SDATA_NAME" && SDATA_NAME=sdata
123 test -z "$SBSS_NAME" && SBSS_NAME=sbss
124 test -z "$BSS_NAME" && BSS_NAME=bss
125 test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start
126 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
127 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
128 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
129 test -z "${ELFSIZE}" && ELFSIZE=32
130 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
131 test "$LD_FLAG" = "N" && DATA_ADDR=.
132 test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext
133 test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
134 test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
135 if test -z "$DATA_SEGMENT_ALIGN"; then
136 test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
137 test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
138 DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
139 DATA_SEGMENT_RELRO_END=""
141 if test -n "${COMMONPAGESIZE}"; then
142 if test "${SEGMENT_SIZE}" != "${MAXPAGESIZE}"; then
143 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
145 DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
147 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
148 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
151 if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
152 INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
154 if test -z "$PLT"; then
155 IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
156 PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }
157 ${IREL_IN_PLT-$IPLT}"
159 test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=
160 if test -z "$GOT"; then
161 if test -z "$SEPARATE_GOTPLT"; then
162 GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt) *(.igot.plt)} *(.got)${RELOCATING+ *(.igot)} }"
164 GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }"
165 GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }"
168 REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }"
169 RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }"
170 REL_IPLT=".rel.iplt ${RELOCATING-0} :
172 ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}
174 ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}
176 RELA_IPLT=".rela.iplt ${RELOCATING-0} :
178 ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}
180 ${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}
182 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
183 RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
184 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.*) }"
185 DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
186 if test -z "${NO_SMALL_DATA}"; then
187 SBSS=".${SBSS_NAME} ${RELOCATING-0} :
189 ${RELOCATING+${SBSS_START_SYMBOLS}}
190 ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)}
191 ${RELOCATING+*(.dyn${SBSS_NAME})}
192 *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*})
193 ${RELOCATING+*(.scommon)}
194 ${RELOCATING+${SBSS_END_SYMBOLS}}
196 SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }"
197 SDATA="/* We want the small data sections together, so single-instruction offsets
198 can access them all, and initialized data all before uninitialized, so
199 we can shorten the on-disk segment size. */
200 .${SDATA_NAME} ${RELOCATING-0} :
202 ${RELOCATING+${SDATA_START_SYMBOLS}}
203 ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)}
204 *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*})
206 SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} :
208 ${RELOCATING+${SDATA2_START_SYMBOLS}}
209 *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*})
211 REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) }
212 .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }"
213 REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) }
214 .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }"
215 REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) }
216 .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }"
217 REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) }
218 .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }"
222 if test -z "${SDATA_GOT}${DATA_GOT}"; then
223 if test -n "${NO_SMALL_DATA}"; then
227 if test -z "${SDATA_GOT}${DATA_GOT}"; then
228 if test -z "${NO_SMALL_DATA}"; then
232 test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
233 test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
234 .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
235 .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
236 .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
237 .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
238 .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
239 .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
240 test "${LARGE_SECTIONS}" = "yes" && LARGE_BSS="
241 .lbss ${RELOCATING-0} :
243 ${RELOCATING+*(.dynlbss)}
244 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
245 ${RELOCATING+*(LARGE_COMMON)}
247 test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
248 .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
250 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
252 .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
254 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
255 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
257 if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
258 SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
259 SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
260 CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors"
261 DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors"
263 SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
264 SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
268 PREINIT_ARRAY=".preinit_array :
270 ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}
271 KEEP (*(.preinit_array))
272 ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}
274 INIT_ARRAY=".init_array :
276 ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}
278 KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY}))
279 ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}
281 FINI_ARRAY=".fini_array :
283 ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}
285 KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY}))
286 ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}
288 CTOR=".ctors ${CONSTRUCTING-0} :
290 ${CONSTRUCTING+${CTOR_START}}
291 /* gcc uses crtbegin.o to find the start of
292 the constructors, so we make sure it is
293 first. Because this is a wildcard, it
294 doesn't matter if the user does not
295 actually link against crtbegin.o; the
296 linker won't look for a file to match a
297 wildcard. The wildcard also means that it
298 doesn't matter which directory crtbegin.o
301 KEEP (*crtbegin.o(.ctors))
302 KEEP (*crtbegin?.o(.ctors))
304 /* We don't want to include the .ctor section from
305 the crtend.o file until after the sorted ctors.
306 The .ctor section from the crtend file contains the
307 end of ctors marker and it must be last */
309 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
310 KEEP (*(SORT(.ctors.*)))
312 ${CONSTRUCTING+${CTOR_END}}
314 DTOR=".dtors ${CONSTRUCTING-0} :
316 ${CONSTRUCTING+${DTOR_START}}
317 KEEP (*crtbegin.o(.dtors))
318 KEEP (*crtbegin?.o(.dtors))
319 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
320 KEEP (*(SORT(.dtors.*)))
322 ${CONSTRUCTING+${DTOR_END}}
324 STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
326 ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
328 ${RELOCATING+${STACK_SENTINEL}}
330 test "${HAVE_NOINIT}" = "yes" && NOINIT="
331 /* This section contains data that is not initialized during load,
332 or during the application's initialization sequence. */
335 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
336 ${RELOCATING+PROVIDE (__noinit_start = .);}
337 *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*})
338 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
339 ${RELOCATING+PROVIDE (__noinit_end = .);}
341 test "${HAVE_PERSISTENT}" = "yes" && PERSISTENT="
342 /* This section contains data that is initialized during load,
343 but not during the application's initialization sequence. */
346 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
347 ${RELOCATING+PROVIDE (__persistent_start = .);}
348 *(.persistent${RELOCATING+ .persistent.* .gnu.linkonce.p.*})
349 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
350 ${RELOCATING+PROVIDE (__persistent_end = .);}
353 TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
354 SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
356 # Don't bother with separate code segment when there are data sections
357 # between .plt and .text.
358 if test -z "$TINY_READONLY_SECTION"; then
362 TEXT_SEGMENT_ALIGN=". = ALIGN(${MAXPAGESIZE});"
367 if [ -z "$SEPARATE_CODE" ]; then
368 SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS"
373 # If this is for an embedded system, don't add SIZEOF_HEADERS.
374 if [ -z "$EMBEDDED" ]; then
375 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}"
377 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
381 /* Copyright (C) 2014-2022 Free Software Foundation, Inc.
383 Copying and distribution of this script, with or without modification,
384 are permitted in any medium without royalty provided the copyright
385 notice and this notice are preserved. */
387 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
388 "${LITTLE_OUTPUT_FORMAT}")
389 OUTPUT_ARCH(${OUTPUT_ARCH})
390 ${RELOCATING+ENTRY(${ENTRY})}
392 ${RELOCATING+${LIB_SEARCH_DIRS}}
393 ${RELOCATING+${CREATE_SHLIB-${EXECUTABLE_SYMBOLS}}}
394 ${RELOCATING+${INPUT_FILES}}
395 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
396 if gld -r is used and the intermediate file has sections starting
397 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
398 bug. But for now assigning the zero vmas works. */}
402 ${RELOCATING+${SEPARATE_TEXT-/* Read-only sections, merged into text segment: */}}
403 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
404 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
405 ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
411 ${INITIAL_READONLY_SECTIONS}
412 .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
416 test -n "${SEPARATE_CODE}" || emit_early_ro
418 test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
419 test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
420 cat > ldscripts/dyntmp.$$ <<EOF
421 ${TEXT_DYNAMIC+${DYNAMIC}}
422 .hash ${RELOCATING-0} : { *(.hash) }
423 .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
424 .dynsym ${RELOCATING-0} : { *(.dynsym) }
425 .dynstr ${RELOCATING-0} : { *(.dynstr) }
426 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
427 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
428 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
431 if [ "x$COMBRELOC" = x ]; then
432 COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
434 COMBRELOCCAT="cat > $COMBRELOC"
436 eval $COMBRELOCCAT <<EOF
437 ${INITIAL_RELOC_SECTIONS}
438 .rel.init ${RELOCATING-0} : { *(.rel.init) }
439 .rela.init ${RELOCATING-0} : { *(.rela.init) }
440 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
441 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
442 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
443 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
444 .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) }
445 .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) }
446 ${OTHER_READONLY_RELOC_SECTIONS}
447 .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) }
448 .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) }
449 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
450 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
451 ${OTHER_READWRITE_RELOC_SECTIONS}
452 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
453 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
454 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
455 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
456 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
457 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
458 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
459 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
460 .rel.got ${RELOCATING-0} : { *(.rel.got) }
461 .rela.got ${RELOCATING-0} : { *(.rela.got) }
462 ${OTHER_GOT_RELOC_SECTIONS}
467 .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) }
468 .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) }
470 ${IREL_IN_PLT+$REL_IFUNC}
471 ${IREL_IN_PLT+$RELA_IFUNC}
472 ${IREL_IN_PLT-$REL_IPLT}
473 ${IREL_IN_PLT-$RELA_IPLT}
476 if [ -n "$COMBRELOC" ]; then
477 cat >> ldscripts/dyntmp.$$ <<EOF
478 .rel.dyn ${RELOCATING-0} :
481 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
482 cat >> ldscripts/dyntmp.$$ <<EOF
484 .rela.dyn ${RELOCATING-0} :
487 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
488 cat >> ldscripts/dyntmp.$$ <<EOF
493 cat >> ldscripts/dyntmp.$$ <<EOF
494 .rel.plt ${RELOCATING-0} :
497 ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}}
498 ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}}
499 ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}}
501 .rela.plt ${RELOCATING-0} :
504 ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}}
505 ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}}
506 ${IREL_IN_PLT+${RELOCATING+${CREATE_PIC-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}}
508 ${OTHER_PLT_RELOC_SECTIONS}
513 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
514 cat ldscripts/dyntmp.$$
516 if test -z "${NO_REL_RELOCS}"; then
517 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$
519 if test -z "${NO_RELA_RELOCS}"; then
520 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$
523 rm -f ldscripts/dyntmp.$$
524 if test -n "${HAVE_DT_RELR}"; then
525 echo " .relr.dyn : { *(.relr.dyn) }"
529 test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn
532 ${RELOCATING+${TEXT_SEGMENT_ALIGN}}
534 .init ${RELOCATING-0}${RELOCATING+${INIT_ADDR}} :
536 ${RELOCATING+${INIT_START}}
537 KEEP (*(SORT_NONE(.init)))
538 ${RELOCATING+${INIT_END}}
541 ${TEXT_PLT+${PLT_NEXT_DATA-${PLT} ${OTHER_PLT_SECTIONS}}}
542 ${TINY_READONLY_SECTION}
543 .text ${RELOCATING-0} :
545 ${RELOCATING+${TEXT_START_SYMBOLS}}
546 ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)}
547 ${RELOCATING+*(.text.exit .text.exit.*)}
548 ${RELOCATING+*(.text.startup .text.startup.*)}
549 ${RELOCATING+*(.text.hot .text.hot.*)}
550 ${RELOCATING+*(SORT(.text.sorted.*))}
551 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
552 /* .gnu.warning sections are handled specially by elf.em. */
554 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
556 .fini ${RELOCATING-0}${RELOCATING+${FINI_ADDR}} :
558 ${RELOCATING+${FINI_START}}
559 KEEP (*(SORT_NONE(.fini)))
560 ${RELOCATING+${FINI_END}}
562 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT-PROVIDE (__${ETEXT_NAME} = .);}}
563 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT-PROVIDE (_${ETEXT_NAME} = .);}}
564 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT-PROVIDE (${ETEXT_NAME} = .);}}
565 ${RELOCATING+${TEXT_SEGMENT_ALIGN}}
568 if test -n "${SEPARATE_CODE}${SEPARATE_TEXT}"; then
569 if test -n "${RODATA_ADDR}"; then
571 SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
573 RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
574 RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
576 if test -n "${SHLIB_RODATA_ADDR}"; then
578 SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
580 SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
581 SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
584 ${RELOCATING+/* Adjust the address for the rodata segment. We want to adjust up to
585 the same address within the page on the next page up. */
586 ${CREATE_SHLIB-${CREATE_PIE-. = ${RODATA_ADDR};}}
587 ${CREATE_SHLIB+. = ${SHLIB_RODATA_ADDR};}
588 ${CREATE_PIE+. = ${SHLIB_RODATA_ADDR};}}
590 if test -n "${SEPARATE_CODE}"; then
597 ${WRITABLE_RODATA-${RODATA}}
598 .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) }
599 ${CREATE_SHLIB-${SDATA2}}
600 ${CREATE_SHLIB-${SBSS2}}
601 ${OTHER_READONLY_SECTIONS}
602 .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr)${RELOCATING+ *(.eh_frame_entry .eh_frame_entry.*)} }
603 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame))${RELOCATING+ *(.eh_frame.*)} }
604 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
605 .gnu_extab ${RELOCATING-0} : ONLY_IF_RO { *(.gnu_extab*) }
606 /* These sections are generated by the Sun/Oracle C++ compiler. */
607 .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges${RELOCATING+*}) }
608 ${TEXT_PLT+${PLT_NEXT_DATA+${PLT} ${OTHER_PLT_SECTIONS}}}
610 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (__${ETEXT_NAME} = .);}}
611 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (_${ETEXT_NAME} = .);}}
612 ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (${ETEXT_NAME} = .);}}
614 ${RELOCATING+/* Adjust the address for the data segment. We want to adjust up to
615 the same address within the page on the next page up. */}
616 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
617 ${CREATE_SHLIB+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}
618 ${CREATE_PIE+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}
620 /* Exception handling */
621 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame))${RELOCATING+ *(.eh_frame.*)} }
622 .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) }
623 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
624 .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges${RELOCATING+*}) }
626 /* Thread Local Storage sections */
627 .tdata ${RELOCATING-0} :
629 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__tdata_start = .);}}
630 *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*})
632 .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
634 ${RELOCATING+${PREINIT_ARRAY}}
635 ${RELOCATING+${INIT_ARRAY}}
636 ${RELOCATING+${FINI_ARRAY}}
637 ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
638 ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
639 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
641 ${RELOCATING+${DATARELRO}}
642 ${OTHER_RELRO_SECTIONS}
643 ${TEXT_DYNAMIC-${DYNAMIC}}
644 ${OTHER_RELRO_SECTIONS_2}
645 ${DATA_GOT+${RELRO_NOW+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}}
646 ${DATA_GOT+${RELRO_NOW+${GOT}}}
647 ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
648 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
649 ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
650 ${INITIAL_READWRITE_SECTIONS}
651 ${DATA_SDATA+${SDATA}}
652 ${DATA_SDATA+${OTHER_SDATA_SECTIONS}}
653 ${DATA_SDATA+${SBSS}}
654 ${DATA_GOT+${RELRO_NOW-${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}}
655 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
656 ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
658 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
660 .data ${RELOCATING-0} :
662 ${RELOCATING+${DATA_START_SYMBOLS}}
663 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
664 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
666 .data1 ${RELOCATING-0} : { *(.data1) }
667 ${WRITABLE_RODATA+${RODATA}}
668 ${OTHER_READWRITE_SECTIONS}
669 ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
670 ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
671 ${SDATA_GOT+${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}}
672 ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}}
674 ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
675 ${DATA_SDATA-${SDATA}}
676 ${DATA_SDATA-${OTHER_SDATA_SECTIONS}}
677 ${RELOCATING+${DATA_END_SYMBOLS-${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}_edata = .${CREATE_SHLIB+)}; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
680 ${RELOCATING+${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}__bss_start = .${CREATE_SHLIB+)};}
681 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
682 ${DATA_SDATA-${SBSS}}
684 .${BSS_NAME} ${RELOCATING-0} :
686 ${RELOCATING+*(.dynbss)}
687 *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*})
688 ${RELOCATING+*(COMMON)
689 /* Align here to ensure that the .bss section occupies space up to
690 _end. Align after .bss to ensure correct alignment even if the
691 .bss section disappears because there are no input sections.
692 FIXME: Why do we need it? When there is no .bss section, we do not
693 pad the .data section. */
694 . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
696 ${OTHER_BSS_SECTIONS}
697 ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}}
698 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
700 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
703 LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});"
704 SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});"
707 ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}}
708 ${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}
709 ${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}
711 ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}}
712 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
713 ${RELOCATING+${OTHER_END_SYMBOLS}}
714 ${RELOCATING+${END_SYMBOLS-${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}_end = .${CREATE_SHLIB+)}; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
715 ${RELOCATING+${DATA_SEGMENT_END}}
718 ${STACK_ADDR+${STACK}}
721 test -z "${NON_ALLOC_DYN}" || emit_dyn
724 /* Stabs debugging sections. */
725 .stab 0 : { *(.stab) }
726 .stabstr 0 : { *(.stabstr) }
727 .stab.excl 0 : { *(.stab.excl) }
728 .stab.exclstr 0 : { *(.stab.exclstr) }
729 .stab.index 0 : { *(.stab.index) }
730 .stab.indexstr 0 : { *(.stab.indexstr) }
732 .comment 0 : { *(.comment) }
734 .gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) }
738 . $srcdir/scripttempl/DWARF.sc
743 ${RELOCATING+${OTHER_SYMBOLS}}
744 ${RELOCATING+${DISCARDED}}