1 # Copyright (C) 2014-2023 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 # This file is variant of elf.sc. For nds32, because the data will be
8 # classified into different sections according to their size, this script
9 # describe these sections map. The order is ".sdata_d, .sdata_w, .sdata_h,
10 # .sdata_b, , sdata_f, .sbss_f, .sbss_b, .sbss_h, .sbss_w, .sbss_d". In
11 # this order we do not have to consider the alignment issue between these
14 if test -n "$NOP"; then
20 test -z "$RODATA_NAME" && RODATA_NAME=rodata
21 test -z "$SDATA_NAME" && SDATA_NAME=sdata
22 test -z "$SBSS_NAME" && SBSS_NAME=sbss
23 test -z "$BSS_NAME" && BSS_NAME=bss
24 test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start
25 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
26 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
27 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
28 test -z "${ELFSIZE}" && ELFSIZE=32
29 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
30 test "$LD_FLAG" = "N" && DATA_ADDR=.
31 test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext
32 test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
33 test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
34 test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
35 test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
36 DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
37 DATA_SEGMENT_RELRO_END=""
39 if test -n "${COMMONPAGESIZE}"; then
40 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
41 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
42 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
44 if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
45 INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
47 if test -z "$PLT"; then
48 IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
49 PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }
52 test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=
53 if test -z "$GOT"; then
54 if test -z "$SEPARATE_GOTPLT"; then
55 GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt) *(.igot.plt)} *(.got)${RELOCATING+ *(.igot)} }"
57 GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }"
58 GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }"
61 REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }"
62 RELA_IFUNC=".rela.ifunc ${RELOCATING-0} : { *(.rela.ifunc) }"
63 REL_IPLT=".rel.iplt ${RELOCATING-0} :
65 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}
67 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}
69 RELA_IPLT=".rela.iplt ${RELOCATING-0} :
71 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}
73 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}
75 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
76 RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
77 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.*) }"
78 DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
79 if test -z "${NO_SMALL_DATA}"; then
80 SBSS=".sbss_b ${RELOCATING-0} :
82 *(.sbss_b${RELOCATING+ .sbss_b.*})
83 ${RELOCATING+*(.scommon_b .scommon_b.*)}
84 ${RELOCATING+. = ALIGN(2);}
86 .sbss_h ${RELOCATING-0} :
88 *(.sbss_h${RELOCATING+ .sbss_h.*})
89 ${RELOCATING+*(.scommon_h .scommon_h.*)}
90 ${RELOCATING+. = ALIGN(4);}
92 .sbss_w ${RELOCATING-0} :
94 *(.sbss_w${RELOCATING+ .sbss_w.*})
95 ${RELOCATING+*(.scommon_w .scommon_w.*)
100 .sbss_d ${RELOCATING-0} :
102 *(.sbss_d${RELOCATING+ .sbss_d.*})
103 ${RELOCATING+*(.scommon_d .scommon_d.*)}
104 ${RELOCATING+PROVIDE (__sbss_end = .);}
105 ${RELOCATING+PROVIDE (___sbss_end = .);}
107 SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }"
108 SDATA="/* We want the small data sections together, so single-instruction offsets
109 can access them all, and initialized data all before uninitialized, so
110 we can shorten the on-disk segment size. */
111 .${SDATA_NAME} ${RELOCATING-0} :
113 ${RELOCATING+${SDATA_START_SYMBOLS}}
114 ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)}
115 *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*})
117 .sdata_d ${RELOCATING-0} :
119 *(.sdata_d${RELOCATING+ .sdata_d.*})
121 .sdata_w ${RELOCATING-0} :
123 *(.sdata_w${RELOCATING+ .sdata_w.*})
125 .sdata_h ${RELOCATING-0} :
127 *(.sdata_h${RELOCATING+ .sdata_h.*})
129 .sdata_b ${RELOCATING-0} :
131 *(.sdata_b${RELOCATING+ .sdata_b.*})
133 .sdata_f ${RELOCATING-0} :
135 *(.sdata_f${RELOCATING+ .sdata_f.*})
137 SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} :
139 ${RELOCATING+${SDATA2_START_SYMBOLS}}
140 *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*})
142 REL_SDATA=".rel.${SDATA_NAME} ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) }
143 .rela.${SDATA_NAME} ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }"
144 REL_SBSS=".rel.${SBSS_NAME} ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) }
145 .rela.${SBSS_NAME} ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }"
146 REL_SDATA2=".rel.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) }
147 .rela.${SDATA_NAME}2 ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }"
148 REL_SBSS2=".rel.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) }
149 .rela.${SBSS_NAME}2 ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }"
153 if test -z "${DATA_GOT}"; then
154 if test -n "${NO_SMALL_DATA}"; then
158 if test -z "${SDATA_GOT}"; then
159 if test -z "${NO_SMALL_DATA}"; then
163 test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
164 test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
165 .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
166 .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
167 .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
168 .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
169 .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
170 .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
171 test "${LARGE_SECTIONS}" = "yes" && LARGE_BSS="
172 .lbss ${RELOCATING-0} :
175 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
178 test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
179 .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
181 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
183 .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
185 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
186 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
188 if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
189 SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
190 SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
191 CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors"
192 DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors"
194 SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
195 SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
199 INIT_ARRAY=".init_array ${RELOCATING-0} :
201 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
203 KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY}))
204 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
206 FINI_ARRAY=".fini_array ${RELOCATING-0} :
208 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
210 KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY}))
211 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
213 CTOR=".ctors ${CONSTRUCTING-0} :
215 ${CONSTRUCTING+${CTOR_START}}
216 /* gcc uses crtbegin.o to find the start of
217 the constructors, so we make sure it is
218 first. Because this is a wildcard, it
219 doesn't matter if the user does not
220 actually link against crtbegin.o; the
221 linker won't look for a file to match a
222 wildcard. The wildcard also means that it
223 doesn't matter which directory crtbegin.o
226 KEEP (*crtbegin.o(.ctors))
227 KEEP (*crtbegin?.o(.ctors))
229 /* We don't want to include the .ctor section from
230 the crtend.o file until after the sorted ctors.
231 The .ctor section from the crtend file contains the
232 end of ctors marker and it must be last */
234 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
235 KEEP (*(SORT(.ctors.*)))
237 ${CONSTRUCTING+${CTOR_END}}
239 DTOR=".dtors ${CONSTRUCTING-0} :
241 ${CONSTRUCTING+${DTOR_START}}
242 KEEP (*crtbegin.o(.dtors))
243 KEEP (*crtbegin?.o(.dtors))
244 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
245 KEEP (*(SORT(.dtors.*)))
247 ${CONSTRUCTING+${DTOR_END}}
249 STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
251 ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
253 ${RELOCATING+${STACK_SENTINEL}}
256 TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
257 SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
259 if [ -z "$SEPARATE_CODE" ]; then
260 SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS"
265 # If this is for an embedded system, don't add SIZEOF_HEADERS.
266 if [ -z "$EMBEDDED" ]; then
267 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}"
270 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
271 NDS32_INIT=".nds32_init : { KEEP(*(.nds32_init)) }"
275 /* Copyright (C) 2014-2023 Free Software Foundation, Inc.
277 Copying and distribution of this script, with or without modification,
278 are permitted in any medium without royalty provided the copyright
279 notice and this notice are preserved. */
281 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
282 "${LITTLE_OUTPUT_FORMAT}")
283 OUTPUT_ARCH(${OUTPUT_ARCH})
284 ${RELOCATING+ENTRY(${ENTRY})}
286 ${RELOCATING+${LIB_SEARCH_DIRS}}
287 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
288 ${RELOCATING+${INPUT_FILES}}
289 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
290 if gld -r is used and the intermediate file has sections starting
291 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
292 bug. But for now assigning the zero vmas works. */}
296 /* Read-only sections, merged into text segment: */
297 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
298 /* Sections saved crt0 and crt1. */
300 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
301 ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
307 ${INITIAL_READONLY_SECTIONS}
308 .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
312 test -n "${SEPARATE_CODE}" || emit_early_ro
314 test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
315 test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
316 cat > ldscripts/dyntmp.$$ <<EOF
317 ${TEXT_DYNAMIC+${DYNAMIC}}
318 .hash ${RELOCATING-0} : { *(.hash) }
319 .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
320 .dynsym ${RELOCATING-0} : { *(.dynsym) }
321 .dynstr ${RELOCATING-0} : { *(.dynstr) }
322 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
323 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
324 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
327 if [ "x$COMBRELOC" = x ]; then
328 COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
330 COMBRELOCCAT="cat > $COMBRELOC"
332 eval $COMBRELOCCAT <<EOF
333 ${INITIAL_RELOC_SECTIONS}
334 .rel.init ${RELOCATING-0} : { *(.rel.init) }
335 .rela.init ${RELOCATING-0} : { *(.rela.init) }
336 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
337 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
338 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
339 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
340 .rel.${RODATA_NAME} ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) }
341 .rela.${RODATA_NAME} ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) }
342 ${OTHER_READONLY_RELOC_SECTIONS}
343 .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) }
344 .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) }
345 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
346 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
347 ${OTHER_READWRITE_RELOC_SECTIONS}
348 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
349 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
350 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
351 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
352 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
353 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
354 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
355 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
356 .rel.got ${RELOCATING-0} : { *(.rel.got) }
357 .rela.got ${RELOCATING-0} : { *(.rela.got) }
358 ${OTHER_GOT_RELOC_SECTIONS}
363 .rel.${BSS_NAME} ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) }
364 .rela.${BSS_NAME} ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) }
366 ${IREL_IN_PLT+$REL_IFUNC}
367 ${IREL_IN_PLT+$RELA_IFUNC}
368 ${IREL_IN_PLT-$REL_IPLT}
369 ${IREL_IN_PLT-$RELA_IPLT}
372 if [ -n "$COMBRELOC" ]; then
373 cat >> ldscripts/dyntmp.$$ <<EOF
374 .rel.dyn ${RELOCATING-0} :
377 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
378 cat >> ldscripts/dyntmp.$$ <<EOF
380 .rela.dyn ${RELOCATING-0} :
383 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
384 cat >> ldscripts/dyntmp.$$ <<EOF
389 cat >> ldscripts/dyntmp.$$ <<EOF
390 .rel.plt ${RELOCATING-0} :
393 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}}
394 ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}}
395 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}}
397 .rela.plt ${RELOCATING-0} :
400 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}}
401 ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}}
402 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}}
404 ${OTHER_PLT_RELOC_SECTIONS}
409 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
410 cat ldscripts/dyntmp.$$
412 if test -z "${NO_REL_RELOCS}"; then
413 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$
415 if test -z "${NO_RELA_RELOCS}"; then
416 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$
419 rm -f ldscripts/dyntmp.$$
422 test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn
425 .init ${RELOCATING-0} :
427 ${RELOCATING+${INIT_START}}
428 KEEP (*(SORT_NONE(.init)))
429 ${RELOCATING+${INIT_END}}
432 ${TEXT_PLT+${PLT_NEXT_DATA-${PLT}}}
433 ${TINY_READONLY_SECTION}
434 .text ${RELOCATING-0} :
436 ${RELOCATING+${TEXT_START_SYMBOLS}}
437 ${RELOCATING+*(.text.unlikely .text.*_unlikely .text.unlikely.*)}
438 ${RELOCATING+*(.text.exit .text.exit.*)}
439 ${RELOCATING+*(.text.startup .text.startup.*)}
440 ${RELOCATING+*(.text.hot .text.hot.*)}
441 ${RELOCATING+*(SORT(.text.sorted.*))}
442 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
443 /* .gnu.warning sections are handled specially by elf.em. */
445 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
447 .fini ${RELOCATING-0} :
449 ${RELOCATING+${FINI_START}}
450 KEEP (*(SORT_NONE(.fini)))
451 ${RELOCATING+${FINI_END}}
453 ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
454 ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
455 ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
458 if test -n "${SEPARATE_CODE}"; then
459 if test -n "${RODATA_ADDR}"; then
461 SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
463 RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
464 RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
466 if test -n "${SHLIB_RODATA_ADDR}"; then
468 SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
470 SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
471 SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
474 /* Adjust the address for the rodata segment. We want to adjust up to
475 the same address within the page on the next page up. */
476 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR};}}}
477 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}}
478 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR};}}
485 ${WRITABLE_RODATA-${RODATA}}
486 .${RODATA_NAME}1 ${RELOCATING-0} : { *(.${RODATA_NAME}1) }
487 ${CREATE_SHLIB-${SDATA2}}
488 ${CREATE_SHLIB-${SBSS2}}
489 ${OTHER_READONLY_SECTIONS}
490 .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr) }
491 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
492 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
493 /* These sections are generated by the Sun/Oracle C++ compiler. */
494 .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges${RELOCATING+*}) }
495 ${TEXT_PLT+${PLT_NEXT_DATA+${PLT}}}
497 /* Adjust the address for the data segment. We want to adjust up to
498 the same address within the page on the next page up. */
499 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
500 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
501 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
503 /* Exception handling */
504 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
505 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
506 .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges${RELOCATING+*}) }
508 /* Thread Local Storage sections */
509 .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
510 .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
512 .preinit_array ${RELOCATING-0} :
514 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
515 KEEP (*(.preinit_array))
516 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
518 ${RELOCATING+${INIT_ARRAY}}
519 ${RELOCATING+${FINI_ARRAY}}
520 ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
521 ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
522 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
524 ${RELOCATING+${DATARELRO}}
525 ${OTHER_RELRO_SECTIONS}
526 ${TEXT_DYNAMIC-${DYNAMIC}}
527 ${DATA_GOT+${RELRO_NOW+${GOT}}}
528 ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
529 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
530 ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
531 ${INITIAL_READWRITE_SECTIONS}
532 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
533 ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
535 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
537 /* For _SDA_BASE_ aligment. */
538 ${RELOCATING+. = ALIGN(4);}
540 .data ${RELOCATING-0} :
542 ${RELOCATING+${DATA_START_SYMBOLS}}
543 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
544 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
546 .data1 ${RELOCATING-0} : { *(.data1) }
547 ${WRITABLE_RODATA+${RODATA}}
548 ${OTHER_READWRITE_SECTIONS}
549 ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
550 ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
551 ${RELOCATING+. = ALIGN(4);}
552 ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
553 ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}}
555 ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
557 ${OTHER_SDATA_SECTIONS}
558 ${RELOCATING+. = ALIGN(4);}
559 ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
561 ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;}
562 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
565 .${BSS_NAME} ${RELOCATING-0} :
567 ${RELOCATING+*(.dyn${BSS_NAME})}
568 *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*})
569 ${RELOCATING+*(COMMON)
570 /* Align here to ensure that the .bss section occupies space up to
571 _end. Align after .bss to ensure correct alignment even if the
572 .bss section disappears because there are no input sections.
573 FIXME: Why do we need it? When there is no .bss section, we do not
574 pad the .data section. */
575 . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
577 ${OTHER_BSS_SECTIONS}
578 ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}}
579 ${RELOCATING+_end = .;}
580 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
581 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
584 LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});"
585 SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});"
588 ${RELOCATING+${CREATE_SHLIB-${CREATE_PIE-${LARGE_DATA_ADDR}}}}
589 ${RELOCATING+${CREATE_SHLIB+${SHLIB_LARGE_DATA_ADDR}}}
590 ${RELOCATING+${CREATE_PIE+${SHLIB_LARGE_DATA_ADDR}}}
592 ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}}
593 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
594 ${RELOCATING+${OTHER_END_SYMBOLS}}
595 ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
596 ${RELOCATING+${DATA_SEGMENT_END}}
599 ${STACK_ADDR+${STACK}}
602 test -z "${NON_ALLOC_DYN}" || emit_dyn
605 /* Stabs debugging sections. */
606 .stab 0 : { *(.stab) }
607 .stabstr 0 : { *(.stabstr) }
608 .stab.excl 0 : { *(.stab.excl) }
609 .stab.exclstr 0 : { *(.stab.exclstr) }
610 .stab.index 0 : { *(.stab.index) }
611 .stab.indexstr 0 : { *(.stab.indexstr) }
613 .comment 0 : { *(.comment) }
617 . $srcdir/scripttempl/DWARF.sc
622 ${RELOCATING+${OTHER_SYMBOLS}}
623 ${RELOCATING+${DISCARDED}}