]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/elf.sc
* scripttempl/elf32cr16.sc: Emit empty script for ld -r and ld -Ur.
[thirdparty/binutils-gdb.git] / ld / scripttempl / elf.sc
CommitLineData
252b5132
RH
1#
2# Unusual variables checked by this code:
563e308f 3# NOP - four byte opcode for no-op (defaults to 0)
48459341
L
4# NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
5# empty.
951e9133
L
6# SMALL_DATA_CTOR - .ctors contains small data.
7# SMALL_DATA_DTOR - .dtors contains small data.
252b5132
RH
8# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
9# INITIAL_READONLY_SECTIONS - at start of text segment
10# OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
11# (e.g., .PARISC.milli)
12# OTHER_TEXT_SECTIONS - these get put in .text when relocating
13# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
14# (e.g., .PARISC.global)
8c37241b
JJ
15# OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
16# (e.g. PPC32 .fixup, .got[12])
e9f53129 17# OTHER_BSS_SECTIONS - other than .bss .sbss ...
104d59d1 18# ATTRS_SECTIONS - at the end
252b5132
RH
19# OTHER_SECTIONS - at the end
20# EXECUTABLE_SYMBOLS - symbols that must be defined for an
21# executable (e.g., _DYNAMIC_LINK)
ba916c8a
MM
22# TEXT_START_ADDR - the first byte of the text segment, after any
23# headers.
24# TEXT_BASE_ADDRESS - the first byte of the text segment.
252b5132
RH
25# TEXT_START_SYMBOLS - symbols that appear at the start of the
26# .text section.
27# DATA_START_SYMBOLS - symbols that appear at the start of the
28# .data section.
eac338cf
PB
29# DATA_END_SYMBOLS - symbols that appear at the end of the
30# writeable data sections.
252b5132 31# OTHER_GOT_SYMBOLS - symbols defined just before .got.
5253f23b
AM
32# OTHER_GOT_SECTIONS - sections just after .got.
33# OTHER_SDATA_SECTIONS - sections just after .sdata.
252b5132
RH
34# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
35# .bss section besides __bss_start.
36# DATA_PLT - .plt should be in data segment, not text segment.
b71a5181 37# PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
6c86c541 38# BSS_PLT - .plt should be in bss segment
485cf679
AM
39# NO_REL_RELOCS - Don't include .rel.* sections in script
40# NO_RELA_RELOCS - Don't include .rela.* sections in script
41# NON_ALLOC_DYN - Place dynamic sections after data segment.
252b5132
RH
42# TEXT_DYNAMIC - .dynamic in text segment, not data segment.
43# EMBEDDED - whether this is for an embedded system.
44# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
45# start address of shared library.
46# INPUT_FILES - INPUT command of files to always include
a8e53fb0 47# WRITABLE_RODATA - if set, the .rodata section should be writable
904ecb2d
JL
48# INIT_START, INIT_END - statements just before and just after
49# combination of .init sections.
50# FINI_START, FINI_END - statements just before and just after
51# combination of .fini sections.
465bc359 52# STACK_ADDR - start of a .stack section.
827a1c67 53# OTHER_SYMBOLS - symbols to place right at the end of the script.
eac338cf
PB
54# ETEXT_NAME - name of a symbol for the end of the text section,
55# normally etext.
8c37241b
JJ
56# SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
57# so that .got can be in the RELRO area. It should be set to
58# the number of bytes in the beginning of .got.plt which can be
59# in the RELRO area as well.
a817dba3 60# USER_LABEL_PREFIX - prefix to add to user-visible symbols.
252b5132
RH
61#
62# When adding sections, do note that the names of some sections are used
63# when specifying the start address of the next.
64#
65
d73e9da0
AS
66# Many sections come in three flavours. There is the 'real' section,
67# like ".data". Then there are the per-procedure or per-variable
68# sections, generated by -ffunction-sections and -fdata-sections in GCC,
69# and useful for --gc-sections, which for a variable "foo" might be
70# ".data.foo". Then there are the linkonce sections, for which the linker
71# eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
72# The exact correspondences are:
73#
74# Section Linkonce section
75# .text .gnu.linkonce.t.foo
76# .rodata .gnu.linkonce.r.foo
77# .data .gnu.linkonce.d.foo
78# .bss .gnu.linkonce.b.foo
79# .sdata .gnu.linkonce.s.foo
80# .sbss .gnu.linkonce.sb.foo
81# .sdata2 .gnu.linkonce.s2.foo
82# .sbss2 .gnu.linkonce.sb2.foo
465bc359 83# .debug_info .gnu.linkonce.wi.foo
13ae64f3
JJ
84# .tdata .gnu.linkonce.td.foo
85# .tbss .gnu.linkonce.tb.foo
3b22753a
L
86# .lrodata .gnu.linkonce.lr.foo
87# .ldata .gnu.linkonce.l.foo
88# .lbss .gnu.linkonce.lb.foo
d73e9da0
AS
89#
90# Each of these can also have corresponding .rel.* and .rela.* sections.
9ac4db9c 91
8d17e044 92test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start
252b5132
RH
93test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
94test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
95if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
96test -z "${ELFSIZE}" && ELFSIZE=32
97test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
98test "$LD_FLAG" = "N" && DATA_ADDR=.
8d17e044 99test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext
9203ba99
JJ
100test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
101test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
8c37241b 102test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
104d59d1 103test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
1ddd7b13 104DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
8c37241b 105DATA_SEGMENT_RELRO_END=""
2d13d8c5
JJ
106DATA_SEGMENT_END=""
107if test -n "${COMMONPAGESIZE}"; then
1ddd7b13 108 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
2d13d8c5 109 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
4ca02259 110 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
2d20f7bf 111fi
5a8e7be2 112if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
df381c72 113 INITIAL_READONLY_SECTIONS=".interp : { *(.interp) }"
5a8e7be2 114fi
0cf7d72c 115if test -z "$PLT"; then
df381c72
AM
116 IPLT=".iplt : { *(.iplt) }"
117 PLT=".plt : { *(.plt)${IREL_IN_PLT+ *(.iplt)} }
8dfab6dd 118 ${IREL_IN_PLT-$IPLT}"
0cf7d72c 119fi
8d6d53d4 120test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
8c37241b
JJ
121if test -z "$GOT"; then
122 if test -z "$SEPARATE_GOTPLT"; then
df381c72 123 GOT=".got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }"
8c37241b 124 else
df381c72
AM
125 GOT=".got : { *(.got) *(.igot) }"
126 GOTPLT=".got.plt : { *(.got.plt) *(.igot.plt) }"
8c37241b
JJ
127 fi
128fi
df381c72
AM
129REL_IFUNC=".rel.ifunc : { *(.rel.ifunc) }"
130RELA_IFUNC=".rela.ifunc : { *(.rela.ifunc) }"
131REL_IPLT=".rel.iplt :
8dfab6dd
AM
132 {
133 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}
134 *(.rel.iplt)
135 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}
136 }"
df381c72 137RELA_IPLT=".rela.iplt :
8dfab6dd
AM
138 {
139 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}
140 *(.rela.iplt)
141 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}
142 }"
df381c72
AM
143DYNAMIC=".dynamic : { *(.dynamic) }"
144RODATA=".rodata : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
4e8aba04 145DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }"
032b94c5 146DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
48459341 147if test -z "${NO_SMALL_DATA}"; then
df381c72 148 SBSS=".sbss :
48459341 149 {
046183de 150 ${RELOCATING+${SBSS_START_SYMBOLS}}
0fb53118 151 ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)}
48459341
L
152 *(.dynsbss)
153 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
154 *(.scommon)
046183de 155 ${RELOCATING+${SBSS_END_SYMBOLS}}
48459341 156 }"
df381c72 157 SBSS2=".sbss2 : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
48459341
L
158 SDATA="/* We want the small data sections together, so single-instruction offsets
159 can access them all, and initialized data all before uninitialized, so
160 we can shorten the on-disk segment size. */
df381c72 161 .sdata :
48459341
L
162 {
163 ${RELOCATING+${SDATA_START_SYMBOLS}}
0fb53118 164 ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}
48459341
L
165 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
166 }"
df381c72 167 SDATA2=".sdata2 :
046183de
AM
168 {
169 ${RELOCATING+${SDATA2_START_SYMBOLS}}
170 *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*})
171 }"
df381c72
AM
172 REL_SDATA=".rel.sdata : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
173 .rela.sdata : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
174 REL_SBSS=".rel.sbss : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
175 .rela.sbss : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
176 REL_SDATA2=".rel.sdata2 : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
177 .rela.sdata2 : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
178 REL_SBSS2=".rel.sbss2 : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
179 .rela.sbss2 : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
8c37241b
JJ
180else
181 NO_SMALL_DATA=" "
48459341 182fi
0cf7d72c
AM
183if test -z "${DATA_GOT}"; then
184 if test -n "${NO_SMALL_DATA}"; then
185 DATA_GOT=" "
186 fi
187fi
188if test -z "${SDATA_GOT}"; then
189 if test -z "${NO_SMALL_DATA}"; then
190 SDATA_GOT=" "
191 fi
192fi
8c37241b 193test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
9599dfb1 194test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
df381c72
AM
195 .rel.ldata : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
196 .rela.ldata : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
197 .rel.lbss : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
198 .rela.lbss : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
199 .rel.lrodata : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
200 .rela.lrodata : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
1bc214ba
L
201test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS="
202 ${OTHER_BSS_SECTIONS}
df381c72 203 .lbss :
9599dfb1
AM
204 {
205 *(.dynlbss)
206 *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
207 *(LARGE_COMMON)
1bc214ba
L
208 }"
209test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
df381c72 210 .lrodata ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
9599dfb1
AM
211 {
212 *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
213 }
df381c72 214 .ldata ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
9599dfb1
AM
215 {
216 *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
217 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
218 }"
df381c72 219CTOR=".ctors :
252b5132
RH
220 {
221 ${CONSTRUCTING+${CTOR_START}}
222 /* gcc uses crtbegin.o to find the start of
223 the constructors, so we make sure it is
224 first. Because this is a wildcard, it
225 doesn't matter if the user does not
226 actually link against crtbegin.o; the
227 linker won't look for a file to match a
228 wildcard. The wildcard also means that it
229 doesn't matter which directory crtbegin.o
230 is in. */
231
40cf2291
AM
232 KEEP (*crtbegin.o(.ctors))
233 KEEP (*crtbegin?.o(.ctors))
252b5132
RH
234
235 /* We don't want to include the .ctor section from
bd6791bc 236 the crtend.o file until after the sorted ctors.
252b5132
RH
237 The .ctor section from the crtend file contains the
238 end of ctors marker and it must be last */
239
40cf2291 240 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
252b5132
RH
241 KEEP (*(SORT(.ctors.*)))
242 KEEP (*(.ctors))
243 ${CONSTRUCTING+${CTOR_END}}
244 }"
df381c72 245DTOR=".dtors :
252b5132
RH
246 {
247 ${CONSTRUCTING+${DTOR_START}}
40cf2291
AM
248 KEEP (*crtbegin.o(.dtors))
249 KEEP (*crtbegin?.o(.dtors))
250 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
252b5132
RH
251 KEEP (*(SORT(.dtors.*)))
252 KEEP (*(.dtors))
253 ${CONSTRUCTING+${DTOR_END}}
254 }"
df381c72 255STACK=" .stack ${RELOCATING+${STACK_ADDR}} :
465bc359 256 {
8d17e044 257 ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
465bc359
AM
258 *(.stack)
259 }"
252b5132 260
258795f5
L
261TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
262SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
263
252b5132
RH
264# if this is for an embedded system, don't add SIZEOF_HEADERS.
265if [ -z "$EMBEDDED" ]; then
266 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
267else
268 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
269fi
270
271cat <<EOF
272OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
273 "${LITTLE_OUTPUT_FORMAT}")
274OUTPUT_ARCH(${OUTPUT_ARCH})
ac69cbc6 275${RELOCATING+ENTRY(${ENTRY})}
252b5132
RH
276
277${RELOCATING+${LIB_SEARCH_DIRS}}
252b5132
RH
278${RELOCATING+${EXECUTABLE_SYMBOLS}}
279${RELOCATING+${INPUT_FILES}}
252b5132
RH
280
281SECTIONS
282{
283 /* Read-only sections, merged into text segment: */
c6d3b05f 284 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
258795f5
L
285 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
286 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
252b5132 287 ${INITIAL_READONLY_SECTIONS}
cd714b79 288 .note.gnu.build-id : { *(.note.gnu.build-id) }
485cf679
AM
289EOF
290
291test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
292test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
293cat > ldscripts/dyntmp.$$ <<EOF
252b5132 294 ${TEXT_DYNAMIC+${DYNAMIC}}
df381c72
AM
295 .hash : { *(.hash) }
296 .gnu.hash : { *(.gnu.hash) }
297 .dynsym : { *(.dynsym) }
298 .dynstr : { *(.dynstr) }
299 .gnu.version : { *(.gnu.version) }
300 .gnu.version_d : { *(.gnu.version_d) }
301 .gnu.version_r : { *(.gnu.version_r) }
db6751f2 302EOF
485cf679 303
db6751f2 304if [ "x$COMBRELOC" = x ]; then
485cf679 305 COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
db6751f2
JJ
306else
307 COMBRELOCCAT="cat > $COMBRELOC"
308fi
309eval $COMBRELOCCAT <<EOF
df381c72
AM
310 .rel.init : { *(.rel.init) }
311 .rela.init : { *(.rela.init) }
312 .rel.text : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
313 .rela.text : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
314 .rel.fini : { *(.rel.fini) }
315 .rela.fini : { *(.rela.fini) }
316 .rel.rodata : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
317 .rela.rodata : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
9e4141bc 318 ${OTHER_READONLY_RELOC_SECTIONS}
df381c72
AM
319 .rel.data.rel.ro : { *(.rel.data.rel.ro${RELOCATING+* .rel.gnu.linkonce.d.rel.ro.*}) }
320 .rela.data.rel.ro : { *(.rela.data.rel.ro${RELOCATING+* .rela.gnu.linkonce.d.rel.ro.*}) }
321 .rel.data : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
322 .rela.data : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
323 .rel.tdata : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
324 .rela.tdata : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
325 .rel.tbss : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
326 .rela.tbss : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
327 .rel.ctors : { *(.rel.ctors) }
328 .rela.ctors : { *(.rela.ctors) }
329 .rel.dtors : { *(.rel.dtors) }
330 .rela.dtors : { *(.rela.dtors) }
331 .rel.got : { *(.rel.got) }
332 .rela.got : { *(.rela.got) }
9e4141bc 333 ${OTHER_GOT_RELOC_SECTIONS}
48459341
L
334 ${REL_SDATA}
335 ${REL_SBSS}
336 ${REL_SDATA2}
337 ${REL_SBSS2}
df381c72
AM
338 .rel.bss : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
339 .rela.bss : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
827a1c67 340 ${REL_LARGE}
8dfab6dd
AM
341 ${IREL_IN_PLT+$REL_IFUNC}
342 ${IREL_IN_PLT+$RELA_IFUNC}
343 ${IREL_IN_PLT-$REL_IPLT}
344 ${IREL_IN_PLT-$RELA_IPLT}
db6751f2 345EOF
485cf679 346
db6751f2 347if [ -n "$COMBRELOC" ]; then
485cf679 348cat >> ldscripts/dyntmp.$$ <<EOF
df381c72 349 .rel.dyn :
db6751f2
JJ
350 {
351EOF
485cf679
AM
352sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
353cat >> ldscripts/dyntmp.$$ <<EOF
db6751f2 354 }
df381c72 355 .rela.dyn :
db6751f2
JJ
356 {
357EOF
485cf679
AM
358sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC >> ldscripts/dyntmp.$$
359cat >> ldscripts/dyntmp.$$ <<EOF
db6751f2
JJ
360 }
361EOF
362fi
485cf679
AM
363
364cat >> ldscripts/dyntmp.$$ <<EOF
df381c72 365 .rel.plt :
3aa14d16
L
366 {
367 *(.rel.plt)
8dfab6dd
AM
368 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}}
369 ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}}
370 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}}
3aa14d16 371 }
df381c72 372 .rela.plt :
3aa14d16
L
373 {
374 *(.rela.plt)
8dfab6dd
AM
375 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}}
376 ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}}
377 ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}}
3aa14d16 378 }
9e673ad1 379 ${OTHER_PLT_RELOC_SECTIONS}
485cf679 380EOF
9e4141bc 381
485cf679
AM
382if test -z "${NON_ALLOC_DYN}"; then
383 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
384 cat ldscripts/dyntmp.$$
385 else
386 if test -z "${NO_REL_RELOCS}"; then
387 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
388 fi
389 if test -z "${NO_RELA_RELOCS}"; then
390 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
391 fi
392 fi
393 rm -f ldscripts/dyntmp.$$
394fi
395
396cat <<EOF
df381c72 397 .init :
4ab10e93 398 {
53db15ed 399 ${RELOCATING+${INIT_START}}
4ab10e93 400 KEEP (*(.init))
53db15ed 401 ${RELOCATING+${INIT_END}}
4ab10e93
GK
402 } =${NOP-0}
403
8d6d53d4 404 ${TEXT_PLT+${PLT}}
ecc49060 405 ${TINY_READONLY_SECTION}
df381c72 406 .text :
252b5132
RH
407 {
408 ${RELOCATING+${TEXT_START_SYMBOLS}}
4c4fb5da 409 ${RELOCATING+*(.text.unlikely .text.*_unlikely)}
465bc359 410 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
252b5132
RH
411 /* .gnu.warning sections are handled specially by elf32.em. */
412 *(.gnu.warning)
252b5132
RH
413 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
414 } =${NOP-0}
df381c72 415 .fini :
904ecb2d 416 {
53db15ed 417 ${RELOCATING+${FINI_START}}
904ecb2d 418 KEEP (*(.fini))
53db15ed 419 ${RELOCATING+${FINI_END}}
904ecb2d 420 } =${NOP-0}
eac338cf
PB
421 ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
422 ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
423 ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
a8e53fb0 424 ${WRITABLE_RODATA-${RODATA}}
df381c72 425 .rodata1 : { *(.rodata1) }
6c86c541
GK
426 ${CREATE_SHLIB-${SDATA2}}
427 ${CREATE_SHLIB-${SBSS2}}
465bc359 428 ${OTHER_READONLY_SECTIONS}
65765700 429 .eh_frame_hdr : { *(.eh_frame_hdr) }
df381c72
AM
430 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
431 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
252b5132
RH
432
433 /* Adjust the address for the data segment. We want to adjust up to
434 the same address within the page on the next page up. */
9203ba99 435 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
2d20f7bf 436 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
9203ba99 437 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
252b5132 438
8c37241b 439 /* Exception handling */
df381c72
AM
440 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
441 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
8c37241b
JJ
442
443 /* Thread Local Storage sections */
df381c72
AM
444 .tdata : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
445 .tbss : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
8c37241b 446
df381c72 447 .preinit_array :
046183de 448 {
a817dba3 449 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
046183de 450 KEEP (*(.preinit_array))
a817dba3 451 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
046183de 452 }
df381c72 453 .init_array :
046183de 454 {
a817dba3 455 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
6f2942ed 456 KEEP (*(SORT(.init_array.*)))
046183de 457 KEEP (*(.init_array))
a817dba3 458 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
046183de 459 }
df381c72 460 .fini_array :
046183de 461 {
a817dba3 462 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
046183de 463 KEEP (*(.fini_array))
6f2942ed 464 KEEP (*(SORT(.fini_array.*)))
a817dba3 465 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
046183de 466 }
951e9133
L
467 ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
468 ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
df381c72 469 .jcr : { KEEP (*(.jcr)) }
8c37241b
JJ
470
471 ${RELOCATING+${DATARELRO}}
472 ${OTHER_RELRO_SECTIONS}
473 ${TEXT_DYNAMIC-${DYNAMIC}}
0cf7d72c
AM
474 ${DATA_GOT+${RELRO_NOW+${GOT}}}
475 ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
476 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
8c37241b 477 ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
0cf7d72c
AM
478 ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
479 ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
8c37241b 480
b71a5181 481 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
8c37241b 482
df381c72 483 .data :
252b5132
RH
484 {
485 ${RELOCATING+${DATA_START_SYMBOLS}}
465bc359 486 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
252b5132
RH
487 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
488 }
df381c72 489 .data1 : { *(.data1) }
a8e53fb0 490 ${WRITABLE_RODATA+${RODATA}}
465bc359 491 ${OTHER_READWRITE_SECTIONS}
951e9133
L
492 ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
493 ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
b71a5181 494 ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
0cf7d72c
AM
495 ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}
496 ${SDATA_GOT+${GOT}}
497 ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
48459341 498 ${SDATA}
465bc359 499 ${OTHER_SDATA_SECTIONS}
a817dba3 500 ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
8d17e044 501 ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;}
252b5132 502 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
48459341 503 ${SBSS}
6c86c541 504 ${BSS_PLT+${PLT}}
df381c72 505 .bss :
252b5132
RH
506 {
507 *(.dynbss)
465bc359 508 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
252b5132
RH
509 *(COMMON)
510 /* Align here to ensure that the .bss section occupies space up to
511 _end. Align after .bss to ensure correct alignment even if the
3b22753a
L
512 .bss section disappears because there are no input sections.
513 FIXME: Why do we need it? When there is no .bss section, we don't
514 pad the .data section. */
9d12f64c 515 ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
252b5132 516 }
e9f53129 517 ${OTHER_BSS_SECTIONS}
827a1c67
AM
518 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
519 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
3b22753a 520 ${LARGE_SECTIONS}
252b5132 521 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
9f4fb502 522 ${RELOCATING+${OTHER_END_SYMBOLS}}
a817dba3 523 ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
2d13d8c5 524 ${RELOCATING+${DATA_SEGMENT_END}}
485cf679 525EOF
252b5132 526
485cf679
AM
527if test -n "${NON_ALLOC_DYN}"; then
528 if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
529 cat ldscripts/dyntmp.$$
530 else
531 if test -z "${NO_REL_RELOCS}"; then
532 sed -e '/^[ ]*\.rela\.[^}]*$/,/}/d' -e '/^[ ]*\.rela\./d' ldscripts/dyntmp.$$
533 fi
534 if test -z "${NO_RELA_RELOCS}"; then
535 sed -e '/^[ ]*\.rel\.[^}]*$/,/}/d' -e '/^[ ]*\.rel\./d' ldscripts/dyntmp.$$
536 fi
537 fi
538 rm -f ldscripts/dyntmp.$$
539fi
540
541cat <<EOF
252b5132 542 /* Stabs debugging sections. */
465bc359
AM
543 .stab 0 : { *(.stab) }
544 .stabstr 0 : { *(.stabstr) }
545 .stab.excl 0 : { *(.stab.excl) }
546 .stab.exclstr 0 : { *(.stab.exclstr) }
547 .stab.index 0 : { *(.stab.index) }
252b5132
RH
548 .stab.indexstr 0 : { *(.stab.indexstr) }
549
465bc359 550 .comment 0 : { *(.comment) }
252b5132
RH
551
552 /* DWARF debug sections.
553 Symbols in the DWARF debugging sections are relative to the beginning
554 of the section so we begin them at 0. */
555
556 /* DWARF 1 */
557 .debug 0 : { *(.debug) }
558 .line 0 : { *(.line) }
559
560 /* GNU DWARF 1 extensions */
561 .debug_srcinfo 0 : { *(.debug_srcinfo) }
562 .debug_sfnames 0 : { *(.debug_sfnames) }
563
564 /* DWARF 1.1 and DWARF 2 */
565 .debug_aranges 0 : { *(.debug_aranges) }
566 .debug_pubnames 0 : { *(.debug_pubnames) }
567
568 /* DWARF 2 */
779dafb4 569 .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) }
252b5132
RH
570 .debug_abbrev 0 : { *(.debug_abbrev) }
571 .debug_line 0 : { *(.debug_line) }
572 .debug_frame 0 : { *(.debug_frame) }
573 .debug_str 0 : { *(.debug_str) }
574 .debug_loc 0 : { *(.debug_loc) }
575 .debug_macinfo 0 : { *(.debug_macinfo) }
576
577 /* SGI/MIPS DWARF 2 extensions */
578 .debug_weaknames 0 : { *(.debug_weaknames) }
579 .debug_funcnames 0 : { *(.debug_funcnames) }
580 .debug_typenames 0 : { *(.debug_typenames) }
581 .debug_varnames 0 : { *(.debug_varnames) }
582
083a6ddf
AM
583 /* DWARF 3 */
584 .debug_pubtypes 0 : { *(.debug_pubtypes) }
585 .debug_ranges 0 : { *(.debug_ranges) }
586
ecc49060
NC
587 ${TINY_DATA_SECTION}
588 ${TINY_BSS_SECTION}
589
465bc359 590 ${STACK_ADDR+${STACK}}
104d59d1 591 ${ATTRS_SECTIONS}
252b5132 592 ${OTHER_SECTIONS}
827a1c67 593 ${RELOCATING+${OTHER_SYMBOLS}}
1c68693b 594 ${RELOCATING+${DISCARDED}}
252b5132
RH
595}
596EOF