]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/elf64hppa.sc
Revert "2.41 Release sources"
[thirdparty/binutils-gdb.git] / ld / scripttempl / elf64hppa.sc
CommitLineData
d87bef3a 1# Copyright (C) 2014-2023 Free Software Foundation, Inc.
6c19b93b 2#
985743c7
NC
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.
d1bbb13a
DA
6#
7# Unusual variables checked by this code:
8# NOP - four byte opcode for no-op (defaults to 0)
9# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
10# empty.
11# SMALL_DATA_CTOR - .ctors contains small data.
12# SMALL_DATA_DTOR - .dtors contains small data.
13# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
14# INITIAL_READONLY_SECTIONS - at start of text segment
15# OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
16# (e.g., .PARISC.milli)
17# OTHER_TEXT_SECTIONS - these get put in .text when relocating
18# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
19# (e.g., .PARISC.global)
20# OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
21# (e.g. PPC32 .fixup, .got[12])
22# OTHER_BSS_SECTIONS - other than .bss .sbss ...
23# ATTRS_SECTIONS - at the end
24# OTHER_SECTIONS - at the end
25# EXECUTABLE_SYMBOLS - symbols that must be defined for an
26# executable (e.g., _DYNAMIC_LINK)
27# TEXT_START_ADDR - the first byte of the text segment, after any
28# headers.
29# TEXT_BASE_ADDRESS - the first byte of the text segment.
30# TEXT_START_SYMBOLS - symbols that appear at the start of the
31# .text section.
32# DATA_START_SYMBOLS - symbols that appear at the start of the
33# .data section.
34# DATA_END_SYMBOLS - symbols that appear at the end of the
35# writeable data sections.
36# OTHER_GOT_SYMBOLS - symbols defined just before .got.
37# OTHER_GOT_SECTIONS - sections just after .got.
38# OTHER_SDATA_SECTIONS - sections just after .sdata.
39# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
40# .bss section besides __bss_start.
41# DATA_PLT - .plt should be in data segment, not text segment.
42# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
43# BSS_PLT - .plt should be in bss segment
44# NO_REL_RELOCS - Don't include .rel.* sections in script
45# NO_RELA_RELOCS - Don't include .rela.* sections in script
46# NON_ALLOC_DYN - Place dynamic sections after data segment.
47# TEXT_DYNAMIC - .dynamic in text segment, not data segment.
6c19b93b 48# EMBEDDED - whether this is for an embedded system.
d1bbb13a
DA
49# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
50# start address of shared library.
51# INPUT_FILES - INPUT command of files to always include
52# WRITABLE_RODATA - if set, the .rodata section should be writable
53# INIT_START, INIT_END - statements just before and just after
6c19b93b 54# combination of .init sections.
d1bbb13a 55# FINI_START, FINI_END - statements just before and just after
6c19b93b 56# combination of .fini sections.
d1bbb13a
DA
57# STACK_ADDR - start of a .stack section.
58# OTHER_SYMBOLS - symbols to place right at the end of the script.
59# ETEXT_NAME - name of a symbol for the end of the text section,
60# normally etext.
61# SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
62# so that .got can be in the RELRO area. It should be set to
63# the number of bytes in the beginning of .got.plt which can be
64# in the RELRO area as well.
65# USER_LABEL_PREFIX - prefix to add to user-visible symbols.
66#
67# When adding sections, do note that the names of some sections are used
68# when specifying the start address of the next.
69#
70
71# Many sections come in three flavours. There is the 'real' section,
72# like ".data". Then there are the per-procedure or per-variable
73# sections, generated by -ffunction-sections and -fdata-sections in GCC,
74# and useful for --gc-sections, which for a variable "foo" might be
75# ".data.foo". Then there are the linkonce sections, for which the linker
76# eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
77# The exact correspondences are:
78#
79# Section Linkonce section
80# .text .gnu.linkonce.t.foo
81# .rodata .gnu.linkonce.r.foo
82# .data .gnu.linkonce.d.foo
83# .bss .gnu.linkonce.b.foo
84# .sdata .gnu.linkonce.s.foo
85# .sbss .gnu.linkonce.sb.foo
86# .sdata2 .gnu.linkonce.s2.foo
87# .sbss2 .gnu.linkonce.sb2.foo
88# .debug_info .gnu.linkonce.wi.foo
89# .tdata .gnu.linkonce.td.foo
90# .tbss .gnu.linkonce.tb.foo
91# .lrodata .gnu.linkonce.lr.foo
92# .ldata .gnu.linkonce.l.foo
93# .lbss .gnu.linkonce.lb.foo
94#
95# Each of these can also have corresponding .rel.* and .rela.* sections.
96
97test -z "$ENTRY" && ENTRY=_start
98test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
99test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
100if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
101test -z "${ELFSIZE}" && ELFSIZE=32
102test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
103test "$LD_FLAG" = "N" && DATA_ADDR=.
104test -z "${ETEXT_NAME}" && ETEXT_NAME=etext
105test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
106test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
107test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
108test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
109DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
110DATA_SEGMENT_RELRO_END=""
111DATA_SEGMENT_END=""
112if test -n "${COMMONPAGESIZE}"; then
113 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
114 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
115 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
116fi
117if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
ec2d9b29 118 INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
d1bbb13a
DA
119fi
120if test -z "$PLT"; then
ec2d9b29 121 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
d1bbb13a
DA
122fi
123test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
124if test -z "$GOT"; then
125 if test -z "$SEPARATE_GOTPLT"; then
2bf2bf23 126 GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) }"
d1bbb13a 127 else
ec2d9b29
AM
128 GOT=".got ${RELOCATING-0} : { *(.got) }"
129 GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }"
d1bbb13a
DA
130 fi
131fi
ec2d9b29
AM
132DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
133RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
18bbc1c5 134DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
43e56c34 135DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
d1bbb13a 136if test -z "${NO_SMALL_DATA}"; then
ec2d9b29 137 SBSS=".sbss ${RELOCATING-0} :
d1bbb13a
DA
138 {
139 ${RELOCATING+${SBSS_START_SYMBOLS}}
140 ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)}
2bf2bf23 141 ${RELOCATING+*(.dynsbss)}
d1bbb13a 142 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
2bf2bf23 143 ${RELOCATING+*(.scommon)}
d1bbb13a
DA
144 ${RELOCATING+${SBSS_END_SYMBOLS}}
145 }"
ec2d9b29 146 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
d1bbb13a
DA
147 SDATA="/* We want the small data sections together, so single-instruction offsets
148 can access them all, and initialized data all before uninitialized, so
149 we can shorten the on-disk segment size. */
6c19b93b 150 .sdata ${RELOCATING-0} :
d1bbb13a
DA
151 {
152 ${RELOCATING+${SDATA_START_SYMBOLS}}
153 ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}
154 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
155 }"
ec2d9b29 156 SDATA2=".sdata2 ${RELOCATING-0} :
d1bbb13a
DA
157 {
158 ${RELOCATING+${SDATA2_START_SYMBOLS}}
159 *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*})
160 }"
ec2d9b29
AM
161 REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
162 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
163 REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
164 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
165 REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
166 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
167 REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
168 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
d1bbb13a
DA
169else
170 NO_SMALL_DATA=" "
171fi
172if test -z "${DATA_GOT}"; then
173 if test -n "${NO_SMALL_DATA}"; then
174 DATA_GOT=" "
175 fi
176fi
177if test -z "${SDATA_GOT}"; then
178 if test -z "${NO_SMALL_DATA}"; then
179 SDATA_GOT=" "
180 fi
181fi
182test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
183test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
ec2d9b29
AM
184 .rel.ldata ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
185 .rela.ldata ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
186 .rel.lbss ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
187 .rela.lbss ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
188 .rel.lrodata ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
189 .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
d1bbb13a
DA
190test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS="
191 ${OTHER_BSS_SECTIONS}
ec2d9b29 192 .lbss ${RELOCATING-0} :
d1bbb13a
DA
193 {
194 *(.dynlbss)
195 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
196 *(LARGE_COMMON)
197 }"
198test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
ec2d9b29 199 .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
d1bbb13a
DA
200 {
201 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
202 }
ec2d9b29 203 .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
d1bbb13a
DA
204 {
205 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
206 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
207 }"
3cff7cc7
JZ
208INIT_ARRAY=".init_array ${RELOCATING-0} :
209 {
210 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
211 KEEP (*(SORT(.init_array.*)))
212 KEEP (*(.init_array))
213 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
214 }"
215FINI_ARRAY=".fini_array ${RELOCATING-0} :
216 {
217 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
218 KEEP (*(SORT(.fini_array.*)))
219 KEEP (*(.fini_array))
220 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
221 }"
6c19b93b 222CTOR=".ctors ${CONSTRUCTING-0} :
d1bbb13a
DA
223 {
224 ${CONSTRUCTING+${CTOR_START}}
225 /* gcc uses crtbegin.o to find the start of
226 the constructors, so we make sure it is
227 first. Because this is a wildcard, it
228 doesn't matter if the user does not
229 actually link against crtbegin.o; the
230 linker won't look for a file to match a
231 wildcard. The wildcard also means that it
232 doesn't matter which directory crtbegin.o
233 is in. */
234
235 KEEP (*crtbegin.o(.ctors))
236 KEEP (*crtbegin?.o(.ctors))
237
238 /* We don't want to include the .ctor section from
239 the crtend.o file until after the sorted ctors.
240 The .ctor section from the crtend file contains the
241 end of ctors marker and it must be last */
242
243 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
244 KEEP (*(SORT(.ctors.*)))
245 KEEP (*(.ctors))
246 ${CONSTRUCTING+${CTOR_END}}
247 }"
ec2d9b29 248DTOR=".dtors ${CONSTRUCTING-0} :
d1bbb13a
DA
249 {
250 ${CONSTRUCTING+${DTOR_START}}
251 KEEP (*crtbegin.o(.dtors))
252 KEEP (*crtbegin?.o(.dtors))
253 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
254 KEEP (*(SORT(.dtors.*)))
255 KEEP (*(.dtors))
256 ${CONSTRUCTING+${DTOR_END}}
257 }"
74dc9032 258STACK=".stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
d1bbb13a 259 {
74dc9032 260 ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
d1bbb13a 261 *(.stack)
74dc9032 262 ${RELOCATING+${STACK_SENTINEL}}
d1bbb13a
DA
263 }"
264
265TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
266SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
267
985743c7 268# If this is for an embedded system, don't add SIZEOF_HEADERS.
d1bbb13a
DA
269if [ -z "$EMBEDDED" ]; then
270 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
271else
272 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
273fi
274
275cat <<EOF
d87bef3a 276/* Copyright (C) 2014-2023 Free Software Foundation, Inc.
985743c7
NC
277
278 Copying and distribution of this script, with or without modification,
279 are permitted in any medium without royalty provided the copyright
280 notice and this notice are preserved. */
281
d1bbb13a
DA
282OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
283 "${LITTLE_OUTPUT_FORMAT}")
284OUTPUT_ARCH(${OUTPUT_ARCH})
285${RELOCATING+ENTRY(${ENTRY})}
286
287${RELOCATING+${LIB_SEARCH_DIRS}}
288${RELOCATING+${EXECUTABLE_SYMBOLS}}
289${RELOCATING+${INPUT_FILES}}
ec2d9b29
AM
290${RELOCATING- /* For some reason, the Solaris linker makes bad executables
291 if gld -r is used and the intermediate file has sections starting
292 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
293 bug. But for now assigning the zero vmas works. */}
d1bbb13a
DA
294
295SECTIONS
296{
297 /* Read-only sections, merged into text segment: */
298 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
299 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
300 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
301 ${INITIAL_READONLY_SECTIONS}
c2e86386 302 .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
d1bbb13a
DA
303EOF
304
305test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
306test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
307cat > ldscripts/dyntmp.$$ <<EOF
308 ${TEXT_DYNAMIC+${DYNAMIC}}
ec2d9b29
AM
309 .hash ${RELOCATING-0} : { *(.hash) }
310 .gnu.hash ${RELOCATING-0} : { *(.gnu.hash) }
311 .dynsym ${RELOCATING-0} : { *(.dynsym) }
312 .dynstr ${RELOCATING-0} : { *(.dynstr) }
313 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
314 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
315 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
d1bbb13a
DA
316EOF
317
318if [ "x$COMBRELOC" = x ]; then
319 COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
320else
321 COMBRELOCCAT="cat > $COMBRELOC"
322fi
323eval $COMBRELOCCAT <<EOF
ec2d9b29
AM
324 .rel.init ${RELOCATING-0} : { *(.rel.init) }
325 .rela.init ${RELOCATING-0} : { *(.rela.init) }
326 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
327 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
328 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
329 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
330 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
331 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
d1bbb13a 332 ${OTHER_READONLY_RELOC_SECTIONS}
18bbc1c5
CC
333 .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) }
334 .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) }
ec2d9b29
AM
335 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
336 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
337 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
338 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
339 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
340 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
341 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
342 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
343 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
344 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
345 .rel.got ${RELOCATING-0} : { *(.rel.got) }
346 .rela.got ${RELOCATING-0} : { *(.rela.got) }
d1bbb13a
DA
347 ${OTHER_GOT_RELOC_SECTIONS}
348 ${REL_SDATA}
349 ${REL_SBSS}
350 ${REL_SDATA2}
351 ${REL_SBSS2}
ec2d9b29
AM
352 .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
353 .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
d1bbb13a
DA
354 ${REL_LARGE}
355EOF
356
357if [ -n "$COMBRELOC" ]; then
358cat >> ldscripts/dyntmp.$$ <<EOF
ec2d9b29 359 .rel.dyn ${RELOCATING-0} :
d1bbb13a
DA
360 {
361EOF
6c19b93b 362sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
d1bbb13a
DA
363cat >> ldscripts/dyntmp.$$ <<EOF
364 }
ec2d9b29 365 .rel.ifunc.dyn ${RELOCATING-0} :
d1bbb13a
DA
366 {
367 *(.rel.ifunc.*)
368 }
ec2d9b29 369 .rela.dyn ${RELOCATING-0} :
d1bbb13a
DA
370 {
371EOF
6c19b93b 372sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
d1bbb13a
DA
373cat >> ldscripts/dyntmp.$$ <<EOF
374 }
ec2d9b29 375 .rela.ifunc.dyn ${RELOCATING-0} :
d1bbb13a
DA
376 {
377 *(.rela.ifunc.*)
378 }
379EOF
380fi
381
382cat >> ldscripts/dyntmp.$$ <<EOF
ec2d9b29
AM
383 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
384 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
d1bbb13a
DA
385 ${OTHER_PLT_RELOC_SECTIONS}
386EOF
387
388if test -z "${NON_ALLOC_DYN}"; then
389 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
390 cat ldscripts/dyntmp.$$
391 else
392 if test -z "${NO_REL_RELOCS}"; then
6c19b93b 393 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
d1bbb13a
DA
394 fi
395 if test -z "${NO_RELA_RELOCS}"; then
6c19b93b 396 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
d1bbb13a
DA
397 fi
398 fi
399 rm -f ldscripts/dyntmp.$$
400fi
401
402cat <<EOF
6c19b93b
AM
403 .init ${RELOCATING-0} :
404 {
d1bbb13a 405 ${RELOCATING+${INIT_START}}
2d3181c7 406 KEEP (*(SORT_NONE(.init)))
d1bbb13a
DA
407 ${RELOCATING+${INIT_END}}
408 } =${NOP-0}
409
410 ${TEXT_PLT+${PLT}}
411 ${TINY_READONLY_SECTION}
ec2d9b29 412 .text ${RELOCATING-0} :
d1bbb13a
DA
413 {
414 ${RELOCATING+${TEXT_START_SYMBOLS}}
415 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
075a2b89 416 /* .gnu.warning sections are handled specially by elf.em. */
d1bbb13a
DA
417 *(.gnu.warning)
418 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
419 } =${NOP-0}
ec2d9b29 420 .fini ${RELOCATING-0} :
d1bbb13a
DA
421 {
422 ${RELOCATING+${FINI_START}}
2d3181c7 423 KEEP (*(SORT_NONE(.fini)))
d1bbb13a
DA
424 ${RELOCATING+${FINI_END}}
425 } =${NOP-0}
426 ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
427 ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
428 ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
429 ${WRITABLE_RODATA-${RODATA}}
ec2d9b29 430 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
d1bbb13a
DA
431 ${CREATE_SHLIB-${SDATA2}}
432 ${CREATE_SHLIB-${SBSS2}}
433 ${OTHER_READONLY_SECTIONS}
c2e86386 434 .eh_frame_hdr ${RELOCATING-0} : { *(.eh_frame_hdr) }
ec2d9b29 435 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
2bf2bf23 436 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
d1bbb13a
DA
437
438 /* Adjust the address for the data segment. We want to adjust up to
439 the same address within the page on the next page up. */
440 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
441 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
442 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
443
444 /* Exception handling */
ec2d9b29 445 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
2bf2bf23 446 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) }
d1bbb13a
DA
447
448 /* Thread Local Storage sections */
ec2d9b29 449 .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
d1bbb13a 450
ec2d9b29 451 .preinit_array ${RELOCATING-0} :
d1bbb13a
DA
452 {
453 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
454 KEEP (*(.preinit_array))
455 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
456 }
3cff7cc7
JZ
457 ${RELOCATING+${INIT_ARRAY}}
458 ${RELOCATING+${FINI_ARRAY}}
d1bbb13a
DA
459 ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
460 ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
ec2d9b29 461 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
d1bbb13a
DA
462
463 ${RELOCATING+${DATARELRO}}
464 ${OTHER_RELRO_SECTIONS}
465 ${TEXT_DYNAMIC-${DYNAMIC}}
466 ${DATA_GOT+${RELRO_NOW+${GOT}}}
467 ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
468 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
469 ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
470 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
471 ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
472
473 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
474
ec2d9b29 475 .data ${RELOCATING-0} :
d1bbb13a
DA
476 {
477 ${RELOCATING+${DATA_START_SYMBOLS}}
478 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
479 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
480 }
ec2d9b29 481 .data1 ${RELOCATING-0} : { *(.data1) }
d1bbb13a
DA
482 ${WRITABLE_RODATA+${RODATA}}
483 ${OTHER_READWRITE_SECTIONS}
484 ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
485 ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
486 ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
487 ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}
488 ${SDATA_GOT+${GOT}}
489 ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
490 ${SDATA}
491 ${OTHER_SDATA_SECTIONS}
492 ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
b5c37946 493 ${RELOCATING+. = ALIGN(ALIGNOF(NEXT_SECTION));}
d1bbb13a
DA
494 ${RELOCATING+__bss_start = .;}
495 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
496 ${SBSS}
497 ${BSS_PLT+${PLT}}
ec2d9b29 498 .bss ${RELOCATING-0} :
d1bbb13a 499 {
2bf2bf23
AM
500 ${RELOCATING+*(.dynbss)}
501 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
502 ${RELOCATING+*(COMMON)
503 /* Align here to ensure that the .bss section occupies space up to
504 _end. Align after .bss to ensure correct alignment even if the
505 .bss section disappears because there are no input sections.
506 FIXME: Why do we need it? When there is no .bss section, we do not
507 pad the .data section. */
508 . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
d1bbb13a
DA
509 }
510 ${OTHER_BSS_SECTIONS}
511 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
512 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
513 ${LARGE_SECTIONS}
514 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
515 ${RELOCATING+${OTHER_END_SYMBOLS}}
516 ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
517 ${RELOCATING+${DATA_SEGMENT_END}}
74dc9032
AM
518 ${TINY_DATA_SECTION}
519 ${TINY_BSS_SECTION}
520 ${STACK_ADDR+${STACK}}
d1bbb13a
DA
521EOF
522
523if test -n "${NON_ALLOC_DYN}"; then
524 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
525 cat ldscripts/dyntmp.$$
526 else
527 if test -z "${NO_REL_RELOCS}"; then
6c19b93b 528 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
d1bbb13a
DA
529 fi
530 if test -z "${NO_RELA_RELOCS}"; then
6c19b93b 531 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
d1bbb13a
DA
532 fi
533 fi
534 rm -f ldscripts/dyntmp.$$
535fi
536
6752dd75
AM
537source_sh $srcdir/scripttempl/misc-sections.sc
538source_sh $srcdir/scripttempl/DWARF.sc
d1bbb13a 539
ceb0a680 540cat <<EOF
d1bbb13a
DA
541 ${ATTRS_SECTIONS}
542 ${OTHER_SECTIONS}
543 ${RELOCATING+${OTHER_SYMBOLS}}
544 ${RELOCATING+${DISCARDED}}
545}
546EOF