]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/scripttempl/nds32elf.sc
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / scripttempl / nds32elf.sc
1 # Copyright (C) 2014-2021 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 # 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
12 # sections.
13
14 if test -n "$NOP"; then
15 FILL="=$NOP"
16 else
17 FILL=
18 fi
19
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=""
38 DATA_SEGMENT_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}, .);"
43 fi
44 if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
45 INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
46 fi
47 if test -z "$PLT"; then
48 IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
49 PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }
50 ${IREL_IN_PLT-$IPLT}"
51 fi
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)} }"
56 else
57 GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }"
58 GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }"
59 fi
60 fi
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} :
64 {
65 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}
66 *(.rel.iplt)
67 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}
68 }"
69 RELA_IPLT=".rela.iplt ${RELOCATING-0} :
70 {
71 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}
72 *(.rela.iplt)
73 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}
74 }"
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} :
81 {
82 *(.sbss_b${RELOCATING+ .sbss_b.*})
83 ${RELOCATING+*(.scommon_b .scommon_b.*)}
84 ${RELOCATING+. = ALIGN(2);}
85 }
86 .sbss_h ${RELOCATING-0} :
87 {
88 *(.sbss_h${RELOCATING+ .sbss_h.*})
89 ${RELOCATING+*(.scommon_h .scommon_h.*)}
90 ${RELOCATING+. = ALIGN(4);}
91 }
92 .sbss_w ${RELOCATING-0} :
93 {
94 *(.sbss_w${RELOCATING+ .sbss_w.*})
95 ${RELOCATING+*(.scommon_w .scommon_w.*)
96 *(.dynsbss)
97 *(.scommon)
98 . = ALIGN(8);}
99 }
100 .sbss_d ${RELOCATING-0} :
101 {
102 *(.sbss_d${RELOCATING+ .sbss_d.*})
103 ${RELOCATING+*(.scommon_d .scommon_d.*)}
104 ${RELOCATING+PROVIDE (__sbss_end = .);}
105 ${RELOCATING+PROVIDE (___sbss_end = .);}
106 }"
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} :
112 {
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.*})
116 }
117 .sdata_d ${RELOCATING-0} :
118 {
119 *(.sdata_d${RELOCATING+ .sdata_d.*})
120 }
121 .sdata_w ${RELOCATING-0} :
122 {
123 *(.sdata_w${RELOCATING+ .sdata_w.*})
124 }
125 .sdata_h ${RELOCATING-0} :
126 {
127 *(.sdata_h${RELOCATING+ .sdata_h.*})
128 }
129 .sdata_b ${RELOCATING-0} :
130 {
131 *(.sdata_b${RELOCATING+ .sdata_b.*})
132 }
133 .sdata_f ${RELOCATING-0} :
134 {
135 *(.sdata_f${RELOCATING+ .sdata_f.*})
136 }"
137 SDATA2=".${SDATA_NAME}2 ${RELOCATING-0} :
138 {
139 ${RELOCATING+${SDATA2_START_SYMBOLS}}
140 *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*})
141 }"
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.*}) }"
150 else
151 NO_SMALL_DATA=" "
152 fi
153 if test -z "${DATA_GOT}"; then
154 if test -n "${NO_SMALL_DATA}"; then
155 DATA_GOT=" "
156 fi
157 fi
158 if test -z "${SDATA_GOT}"; then
159 if test -z "${NO_SMALL_DATA}"; then
160 SDATA_GOT=" "
161 fi
162 fi
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} :
173 {
174 *(.dynlbss)
175 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
176 *(LARGE_COMMON)
177 }"
178 test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
179 .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
180 {
181 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
182 }
183 .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
184 {
185 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
186 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
187 }"
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"
193 else
194 SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
195 SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
196 CTORS_IN_INIT_ARRAY=
197 DTORS_IN_FINI_ARRAY=
198 fi
199 INIT_ARRAY=".init_array ${RELOCATING-0} :
200 {
201 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
202 ${SORT_INIT_ARRAY}
203 KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY}))
204 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
205 }"
206 FINI_ARRAY=".fini_array ${RELOCATING-0} :
207 {
208 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
209 ${SORT_FINI_ARRAY}
210 KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY}))
211 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
212 }"
213 CTOR=".ctors ${CONSTRUCTING-0} :
214 {
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
224 is in. */
225
226 KEEP (*crtbegin.o(.ctors))
227 KEEP (*crtbegin?.o(.ctors))
228
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 */
233
234 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
235 KEEP (*(SORT(.ctors.*)))
236 KEEP (*(.ctors))
237 ${CONSTRUCTING+${CTOR_END}}
238 }"
239 DTOR=".dtors ${CONSTRUCTING-0} :
240 {
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.*)))
246 KEEP (*(.dtors))
247 ${CONSTRUCTING+${DTOR_END}}
248 }"
249 STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
250 {
251 ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
252 *(.stack)
253 ${RELOCATING+${STACK_SENTINEL}}
254 }"
255
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})"
258
259 if [ -z "$SEPARATE_CODE" ]; then
260 SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS"
261 else
262 SIZEOF_HEADERS_CODE=
263 fi
264
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}"
268 NDS32_INIT=""
269 else
270 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
271 NDS32_INIT=".nds32_init : { KEEP(*(.nds32_init)) }"
272 fi
273
274 cat <<EOF
275 /* Copyright (C) 2014-2021 Free Software Foundation, Inc.
276
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. */
280
281 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
282 "${LITTLE_OUTPUT_FORMAT}")
283 OUTPUT_ARCH(${OUTPUT_ARCH})
284 ${RELOCATING+ENTRY(${ENTRY})}
285
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. */}
293
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 /* Sections saved crt0 and crt1. */
299 ${NDS32_INIT}
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};}}
302 EOF
303
304 emit_early_ro()
305 {
306 cat <<EOF
307 ${INITIAL_READONLY_SECTIONS}
308 .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
309 EOF
310 }
311
312 test -n "${SEPARATE_CODE}" || emit_early_ro
313
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) }
325 EOF
326
327 if [ "x$COMBRELOC" = x ]; then
328 COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
329 else
330 COMBRELOCCAT="cat > $COMBRELOC"
331 fi
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}
359 ${REL_SDATA}
360 ${REL_SBSS}
361 ${REL_SDATA2}
362 ${REL_SBSS2}
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.*}) }
365 ${REL_LARGE}
366 ${IREL_IN_PLT+$REL_IFUNC}
367 ${IREL_IN_PLT+$RELA_IFUNC}
368 ${IREL_IN_PLT-$REL_IPLT}
369 ${IREL_IN_PLT-$RELA_IPLT}
370 EOF
371
372 if [ -n "$COMBRELOC" ]; then
373 cat >> ldscripts/dyntmp.$$ <<EOF
374 .rel.dyn ${RELOCATING-0} :
375 {
376 EOF
377 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;/__rela_iplt_/d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
378 cat >> ldscripts/dyntmp.$$ <<EOF
379 }
380 .rela.dyn ${RELOCATING-0} :
381 {
382 EOF
383 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;/__rel_iplt_/d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
384 cat >> ldscripts/dyntmp.$$ <<EOF
385 }
386 EOF
387 fi
388
389 cat >> ldscripts/dyntmp.$$ <<EOF
390 .rel.plt ${RELOCATING-0} :
391 {
392 *(.rel.plt)
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 = .);}}}
396 }
397 .rela.plt ${RELOCATING-0} :
398 {
399 *(.rela.plt)
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 = .);}}}
403 }
404 ${OTHER_PLT_RELOC_SECTIONS}
405 EOF
406
407 emit_dyn()
408 {
409 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
410 cat ldscripts/dyntmp.$$
411 else
412 if test -z "${NO_REL_RELOCS}"; then
413 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d;/^[ ]*\.rela\./d;/__rela_iplt_/d' ldscripts/dyntmp.$$
414 fi
415 if test -z "${NO_RELA_RELOCS}"; then
416 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d;/^[ ]*\.rel\./d;/__rel_iplt_/d' ldscripts/dyntmp.$$
417 fi
418 fi
419 rm -f ldscripts/dyntmp.$$
420 }
421
422 test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn
423
424 cat <<EOF
425 .init ${RELOCATING-0} :
426 {
427 ${RELOCATING+${INIT_START}}
428 KEEP (*(SORT_NONE(.init)))
429 ${RELOCATING+${INIT_END}}
430 } ${FILL}
431
432 ${TEXT_PLT+${PLT_NEXT_DATA-${PLT}}}
433 ${TINY_READONLY_SECTION}
434 .text ${RELOCATING-0} :
435 {
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. */
444 *(.gnu.warning)
445 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
446 } ${FILL}
447 .fini ${RELOCATING-0} :
448 {
449 ${RELOCATING+${FINI_START}}
450 KEEP (*(SORT_NONE(.fini)))
451 ${RELOCATING+${FINI_END}}
452 } ${FILL}
453 ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
454 ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
455 ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
456 EOF
457
458 if test -n "${SEPARATE_CODE}"; then
459 if test -n "${RODATA_ADDR}"; then
460 RODATA_ADDR="\
461 SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
462 else
463 RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
464 RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
465 fi
466 if test -n "${SHLIB_RODATA_ADDR}"; then
467 SHLIB_RODATA_ADDR="\
468 SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
469 else
470 SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
471 SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
472 fi
473 cat <<EOF
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};}}
479 EOF
480 emit_early_ro
481 emit_dyn
482 fi
483
484 cat <<EOF
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}}}
496
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}};}}
502
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+*}) }
507
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)} }
511
512 .preinit_array ${RELOCATING-0} :
513 {
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 = .);}}
517 }
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)) }
523
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}}}
534
535 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
536
537 /* For _SDA_BASE_ aligment. */
538 ${RELOCATING+. = ALIGN(4);}
539
540 .data ${RELOCATING-0} :
541 {
542 ${RELOCATING+${DATA_START_SYMBOLS}}
543 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
544 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
545 }
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}}}}
554 ${SDATA_GOT+${GOT}}
555 ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
556 ${SDATA}
557 ${OTHER_SDATA_SECTIONS}
558 ${RELOCATING+. = ALIGN(4);}
559 ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
560 ${RELOCATING+. = .;}
561 ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;}
562 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
563 ${SBSS}
564 ${BSS_PLT+${PLT}}
565 .${BSS_NAME} ${RELOCATING-0} :
566 {
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);}
576 }
577 ${OTHER_BSS_SECTIONS}
578 ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}}
579 ${RELOCATING+_end = .;}
580 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
581 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
582 EOF
583
584 LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${LARGE_DATA_ADDR-.});"
585 SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_ADDR-.});"
586
587 cat <<EOF
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}}}
591 ${LARGE_SECTIONS}
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}}
597 ${TINY_DATA_SECTION}
598 ${TINY_BSS_SECTION}
599 ${STACK_ADDR+${STACK}}
600 EOF
601
602 test -z "${NON_ALLOC_DYN}" || emit_dyn
603
604 cat <<EOF
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) }
612
613 .comment 0 : { *(.comment) }
614
615 EOF
616
617 . $srcdir/scripttempl/DWARF.sc
618
619 cat <<EOF
620 ${ATTRS_SECTIONS}
621 ${OTHER_SECTIONS}
622 ${RELOCATING+${OTHER_SYMBOLS}}
623 ${RELOCATING+${DISCARDED}}
624 }
625 EOF