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