]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/iq2000.sc
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / scripttempl / iq2000.sc
CommitLineData
250d07de 1# Copyright (C) 2014-2021 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.
e09a7106
SC
6#
7# Unusual variables checked by this code:
8# NOP - four byte opcode for no-op (defaults to 0)
9# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
10# INITIAL_READONLY_SECTIONS - at start of data segment
11# OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
12# (e.g., .PARISC.milli)
13# OTHER_TEXT_SECTIONS - these get put in .text when relocating
14# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
15# (e.g., .PARISC.global)
e09a7106
SC
16# OTHER_SECTIONS - at the end
17# EXECUTABLE_SYMBOLS - symbols that must be defined for an
18# executable (e.g., _DYNAMIC_LINK)
19# TEXT_START_SYMBOLS - symbols that appear at the start of the
20# .text section.
21# DATA_START_SYMBOLS - symbols that appear at the start of the
22# .data section.
23# OTHER_GOT_SYMBOLS - symbols defined just before .got.
24# OTHER_GOT_SECTIONS - sections just after .got.
25# OTHER_SDATA_SECTIONS - sections just after .sdata.
26# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
27# .bss section besides __bss_start.
28# DATA_PLT - .plt should be in data segment, not text segment.
29# BSS_PLT - .plt should be in bss segment
30# TEXT_DYNAMIC - .dynamic in text segment, not data segment.
6c19b93b 31# EMBEDDED - whether this is for an embedded system.
e09a7106
SC
32# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
33# start address of shared library.
34# INPUT_FILES - INPUT command of files to always include
35# WRITABLE_RODATA - if set, the .rodata section should be writable
36# INIT_START, INIT_END - statements just before and just after
6c19b93b 37# combination of .init sections.
e09a7106 38# FINI_START, FINI_END - statements just before and just after
6c19b93b 39# combination of .fini sections.
e09a7106
SC
40#
41# When adding sections, do note that the names of some sections are used
42# when specifying the start address of the next.
43#
44
45# Many sections come in three flavours. There is the 'real' section,
46# like ".data". Then there are the per-procedure or per-variable
47# sections, generated by -ffunction-sections and -fdata-sections in GCC,
48# and useful for --gc-sections, which for a variable "foo" might be
49# ".data.foo". Then there are the linkonce sections, for which the linker
50# eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
51# The exact correspondences are:
52#
53# Section Linkonce section
54# .text .gnu.linkonce.t.foo
55# .rodata .gnu.linkonce.r.foo
56# .data .gnu.linkonce.d.foo
57# .bss .gnu.linkonce.b.foo
58# .sdata .gnu.linkonce.s.foo
59# .sbss .gnu.linkonce.sb.foo
60# .sdata2 .gnu.linkonce.s2.foo
61# .sbss2 .gnu.linkonce.sb2.foo
62#
63# Each of these can also have corresponding .rel.* and .rela.* sections.
64
65test -z "$ENTRY" && ENTRY=_start
66test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
67test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
68if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
69test -z "${ELFSIZE}" && ELFSIZE=32
70test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
71test "$LD_FLAG" = "N" && DATA_ADDR=.
6c19b93b 72INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
ec2d9b29
AM
73PLT=".plt ${RELOCATING-0} : { *(.plt) }"
74DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
75RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} }"
76SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) ${RELOCATING+*(.sbss2.*)} ${RELOCATING+*(.gnu.linkonce.sb2.*)} }"
77SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) ${RELOCATING+*(.sdata2.*)} ${RELOCATING+*(.gnu.linkonce.s2.*)} }"
6c19b93b 78CTOR=".ctors ${CONSTRUCTING-0} :
e09a7106
SC
79 {
80 ${CONSTRUCTING+${CTOR_START}}
81 /* gcc uses crtbegin.o to find the start of
82 the constructors, so we make sure it is
83 first. Because this is a wildcard, it
84 doesn't matter if the user does not
85 actually link against crtbegin.o; the
86 linker won't look for a file to match a
87 wildcard. The wildcard also means that it
88 doesn't matter which directory crtbegin.o
89 is in. */
90
40cf2291
AM
91 KEEP (*crtbegin.o(.ctors))
92 KEEP (*crtbegin?.o(.ctors))
e09a7106
SC
93
94 /* We don't want to include the .ctor section from
bd6791bc 95 the crtend.o file until after the sorted ctors.
e09a7106
SC
96 The .ctor section from the crtend file contains the
97 end of ctors marker and it must be last */
98
40cf2291 99 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
e09a7106
SC
100 KEEP (*(SORT(.ctors.*)))
101 KEEP (*(.ctors))
102 ${CONSTRUCTING+${CTOR_END}}
103 }"
104
ec2d9b29 105DTOR=" .dtors ${CONSTRUCTING-0} :
e09a7106
SC
106 {
107 ${CONSTRUCTING+${DTOR_START}}
40cf2291
AM
108 KEEP (*crtbegin.o(.dtors))
109 KEEP (*crtbegin?.o(.dtors))
110 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
e09a7106
SC
111 KEEP (*(SORT(.dtors.*)))
112 KEEP (*(.dtors))
113 ${CONSTRUCTING+${DTOR_END}}
114 }"
115
985743c7 116# If this is for an embedded system, don't add SIZEOF_HEADERS.
e09a7106
SC
117if [ -z "$EMBEDDED" ]; then
118 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
119else
120 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
121fi
122
123cat <<EOF
250d07de 124/* Copyright (C) 2014-2021 Free Software Foundation, Inc.
985743c7
NC
125
126 Copying and distribution of this script, with or without modification,
127 are permitted in any medium without royalty provided the copyright
128 notice and this notice are preserved. */
129
e09a7106
SC
130OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
131 "${LITTLE_OUTPUT_FORMAT}")
132OUTPUT_ARCH(${OUTPUT_ARCH})
b34c1498 133${RELOCATING+ENTRY(${ENTRY})}
e09a7106
SC
134
135${RELOCATING+${LIB_SEARCH_DIRS}}
136${RELOCATING+/* Do we need any of these for elf?
137 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
138${RELOCATING+${EXECUTABLE_SYMBOLS}}
139${RELOCATING+${INPUT_FILES}}
ec2d9b29
AM
140${RELOCATING- /* For some reason, the Solaris linker makes bad executables
141 if gld -r is used and the intermediate file has sections starting
142 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
143 bug. But for now assigning the zero vmas works. */}
e09a7106
SC
144
145SECTIONS
146{
147 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}
148 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
149 ${CREATE_SHLIB-${INTERP}}
150 ${TEXT_DYNAMIC+${DYNAMIC}}
151
152EOF
153if [ "x$COMBRELOC" = x ]; then
154 COMBRELOCCAT=cat
155else
156 COMBRELOCCAT="cat > $COMBRELOC"
157fi
158eval $COMBRELOCCAT <<EOF
ec2d9b29
AM
159 .rel.init ${RELOCATING-0} : { *(.rel.init) }
160 .rela.init ${RELOCATING-0} : { *(.rela.init) }
161 .rel.text ${RELOCATING-0} :
e09a7106
SC
162 {
163 *(.rel.text)
164 ${RELOCATING+*(.rel.text.*)}
165 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
166 }
ec2d9b29 167 .rela.text ${RELOCATING-0} :
e09a7106
SC
168 {
169 *(.rela.text)
170 ${RELOCATING+*(.rela.text.*)}
171 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
172 }
ec2d9b29
AM
173 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
174 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
175 .rel.rodata ${RELOCATING-0} :
e09a7106
SC
176 {
177 *(.rel.rodata)
178 ${RELOCATING+*(.rel.rodata.*)}
179 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
180 }
ec2d9b29 181 .rela.rodata ${RELOCATING-0} :
e09a7106
SC
182 {
183 *(.rela.rodata)
184 ${RELOCATING+*(.rela.rodata.*)}
185 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
186 }
187 ${OTHER_READONLY_RELOC_SECTIONS}
ec2d9b29 188 .rel.data ${RELOCATING-0} :
e09a7106
SC
189 {
190 *(.rel.data)
191 ${RELOCATING+*(.rel.data.*)}
192 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
193 }
ec2d9b29 194 .rela.data ${RELOCATING-0} :
e09a7106
SC
195 {
196 *(.rela.data)
197 ${RELOCATING+*(.rela.data.*)}
198 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
199 }
ec2d9b29
AM
200 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
201 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
202 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
203 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
204 .rel.got ${RELOCATING-0} : { *(.rel.got) }
205 .rela.got ${RELOCATING-0} : { *(.rela.got) }
e09a7106 206 ${OTHER_GOT_RELOC_SECTIONS}
ec2d9b29 207 .rel.sdata ${RELOCATING-0} :
e09a7106
SC
208 {
209 *(.rel.sdata)
210 ${RELOCATING+*(.rel.sdata.*)}
211 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
212 }
ec2d9b29 213 .rela.sdata ${RELOCATING-0} :
e09a7106
SC
214 {
215 *(.rela.sdata)
216 ${RELOCATING+*(.rela.sdata.*)}
217 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
218 }
ec2d9b29 219 .rel.sbss ${RELOCATING-0} :
6c19b93b 220 {
e09a7106
SC
221 *(.rel.sbss)
222 ${RELOCATING+*(.rel.sbss.*)}
223 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
224 }
ec2d9b29 225 .rela.sbss ${RELOCATING-0} :
e09a7106
SC
226 {
227 *(.rela.sbss)
228 ${RELOCATING+*(.rela.sbss.*)}
229 ${RELOCATING+*(.rela.gnu.linkonce.sb.*)}
230 }
6c19b93b
AM
231 .rel.sdata2 ${RELOCATING-0} :
232 {
e09a7106
SC
233 *(.rel.sdata2)
234 ${RELOCATING+*(.rel.sdata2.*)}
235 ${RELOCATING+*(.rel.gnu.linkonce.s2.*)}
236 }
6c19b93b 237 .rela.sdata2 ${RELOCATING-0} :
e09a7106
SC
238 {
239 *(.rela.sdata2)
240 ${RELOCATING+*(.rela.sdata2.*)}
241 ${RELOCATING+*(.rela.gnu.linkonce.s2.*)}
242 }
6c19b93b
AM
243 .rel.sbss2 ${RELOCATING-0} :
244 {
245 *(.rel.sbss2)
e09a7106
SC
246 ${RELOCATING+*(.rel.sbss2.*)}
247 ${RELOCATING+*(.rel.gnu.linkonce.sb2.*)}
248 }
6c19b93b
AM
249 .rela.sbss2 ${RELOCATING-0} :
250 {
251 *(.rela.sbss2)
e09a7106
SC
252 ${RELOCATING+*(.rela.sbss2.*)}
253 ${RELOCATING+*(.rela.gnu.linkonce.sb2.*)}
254 }
6c19b93b
AM
255 .rel.bss ${RELOCATING-0} :
256 {
e09a7106
SC
257 *(.rel.bss)
258 ${RELOCATING+*(.rel.bss.*)}
259 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
260 }
6c19b93b
AM
261 .rela.bss ${RELOCATING-0} :
262 {
e09a7106
SC
263 *(.rela.bss)
264 ${RELOCATING+*(.rela.bss.*)}
265 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
266 }
267EOF
268if [ -n "$COMBRELOC" ]; then
269cat <<EOF
270 .rel.dyn :
271 {
272EOF
6c19b93b 273sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC
e09a7106
SC
274cat <<EOF
275 }
276 .rela.dyn :
277 {
278EOF
6c19b93b 279sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC
e09a7106
SC
280cat <<EOF
281 }
282EOF
283fi
284cat <<EOF
ec2d9b29
AM
285 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
286 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
e09a7106
SC
287 ${OTHER_PLT_RELOC_SECTIONS}
288
6c19b93b
AM
289 .init ${RELOCATING-0} :
290 {
e09a7106 291 ${RELOCATING+${INIT_START}}
2d3181c7 292 KEEP (*(SORT_NONE(.init)))
e09a7106
SC
293 ${RELOCATING+${INIT_END}}
294 } =${NOP-0}
295
296 ${DATA_PLT-${BSS_PLT-${PLT}}}
ec2d9b29 297 .text ${RELOCATING-0} :
e09a7106
SC
298 {
299 ${RELOCATING+${TEXT_START_SYMBOLS}}
300 *(.text)
301 ${RELOCATING+*(.text.*)}
302 *(.stub)
075a2b89 303 /* .gnu.warning sections are handled specially by elf.em. */
e09a7106
SC
304 *(.gnu.warning)
305 ${RELOCATING+*(.gnu.linkonce.t.*)}
306 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
307 } =${NOP-0}
ec2d9b29 308 .fini ${RELOCATING-0} :
e09a7106
SC
309 {
310 ${RELOCATING+${FINI_START}}
2d3181c7 311 KEEP (*(SORT_NONE(.fini)))
e09a7106
SC
312 ${RELOCATING+${FINI_END}}
313 } =${NOP-0}
314 ${RELOCATING+PROVIDE (__etext = .);}
315 ${RELOCATING+PROVIDE (_etext = .);}
316 ${RELOCATING+PROVIDE (etext = .);}
317
318 /* Adjust the address for the data segment. We want to adjust up to
319 the same address within the page on the next page up. */
320 ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
321 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
322
ec2d9b29 323 .data ${RELOCATING-0} :
e09a7106
SC
324 {
325 ${RELOCATING+${DATA_START_SYMBOLS}}
326 *(.data)
327 ${RELOCATING+*(.data.*)}
328 ${RELOCATING+*(.gnu.linkonce.d.*)}
329 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
330 }
ec2d9b29 331 .data1 ${RELOCATING-0} : { *(.data1) }
6c19b93b
AM
332 .eh_frame ${RELOCATING-0} :
333 {
e09a7106 334 ${RELOCATING+PROVIDE (__eh_frame_begin = .);}
6c19b93b 335 *(.eh_frame)
2bf2bf23 336 ${RELOCATING+LONG (0);}
e09a7106 337 ${RELOCATING+PROVIDE (__eh_frame_end = .);}
2bf2bf23 338 }
e09a7106
SC
339 .gcc_except_table : { *(.gcc_except_table) }
340 ${INITIAL_READONLY_SECTIONS}
ec2d9b29
AM
341 .hash ${RELOCATING-0} : { *(.hash) }
342 .dynsym ${RELOCATING-0} : { *(.dynsym) }
343 .dynstr ${RELOCATING-0} : { *(.dynstr) }
344 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
345 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
346 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
e09a7106 347 ${RODATA}
ec2d9b29 348 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
e09a7106
SC
349 ${CREATE_SHLIB-${SDATA2}}
350 ${CREATE_SHLIB-${SBSS2}}
351 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
352 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
353 ${TEXT_DYNAMIC-${DYNAMIC}}
354 ${RELOCATING+${CTOR}}
355 ${RELOCATING+${DTOR}}
356 .jcr : { KEEP (*(.jcr)) }
357 ${DATA_PLT+${PLT}}
358 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
2bf2bf23 359 .got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) }
e09a7106
SC
360 ${RELOCATING+${OTHER_GOT_SECTIONS}}
361 ${CREATE_SHLIB+${SDATA2}}
362 ${CREATE_SHLIB+${SBSS2}}
363 /* We want the small data sections together, so single-instruction offsets
364 can access them all, and initialized data all before uninitialized, so
365 we can shorten the on-disk segment size. */
6c19b93b 366 .sdata ${RELOCATING-0} :
e09a7106
SC
367 {
368 ${RELOCATING+${SDATA_START_SYMBOLS}}
6c19b93b 369 *(.sdata)
e09a7106
SC
370 ${RELOCATING+*(.sdata.*)}
371 ${RELOCATING+*(.gnu.linkonce.s.*)}
372 }
373 ${RELOCATING+${OTHER_SDATA_SECTIONS}}
374 ${RELOCATING+_edata = .;}
375 ${RELOCATING+PROVIDE (edata = .);}
376 ${RELOCATING+__bss_start = .;}
377 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
ec2d9b29 378 .sbss ${RELOCATING-0} :
e09a7106
SC
379 {
380 ${RELOCATING+PROVIDE (__sbss_start = .);}
381 ${RELOCATING+PROVIDE (___sbss_start = .);}
2bf2bf23 382 ${RELOCATING+*(.dynsbss)}
e09a7106
SC
383 *(.sbss)
384 ${RELOCATING+*(.sbss.*)}
385 ${RELOCATING+*(.gnu.linkonce.sb.*)}
2bf2bf23 386 ${RELOCATING+*(.scommon)}
e09a7106
SC
387 ${RELOCATING+PROVIDE (__sbss_end = .);}
388 ${RELOCATING+PROVIDE (___sbss_end = .);}
389 }
390 ${BSS_PLT+${PLT}}
ec2d9b29 391 .bss ${RELOCATING-0} :
e09a7106 392 {
2bf2bf23 393 ${RELOCATING+*(.dynbss)}
e09a7106
SC
394 *(.bss)
395 ${RELOCATING+*(.bss.*)}
396 ${RELOCATING+*(.gnu.linkonce.b.*)}
2bf2bf23 397 ${RELOCATING+*(COMMON)
e09a7106
SC
398 /* Align here to ensure that the .bss section occupies space up to
399 _end. Align after .bss to ensure correct alignment even if the
400 .bss section disappears because there are no input sections. */
2bf2bf23 401 . = ALIGN(${ALIGNMENT});}
e09a7106 402 }
827a1c67 403 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
e09a7106 404 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
9f4fb502 405 ${RELOCATING+${OTHER_END_SYMBOLS}}
827a1c67 406 ${RELOCATING+_end = .;}
e09a7106
SC
407 ${RELOCATING+PROVIDE (end = .);}
408
409 /* Stabs debugging sections. */
410 .stab 0 : { *(.stab) }
411 .stabstr 0 : { *(.stabstr) }
412 .stab.excl 0 : { *(.stab.excl) }
413 .stab.exclstr 0 : { *(.stab.exclstr) }
414 .stab.index 0 : { *(.stab.index) }
415 .stab.indexstr 0 : { *(.stab.indexstr) }
416
417 .comment 0 : { *(.comment) }
418
ceb0a680 419EOF
2a995fc1 420
d061dfac 421. $srcdir/scripttempl/DWARF.sc
2a995fc1 422
ceb0a680 423cat <<EOF
e09a7106
SC
424 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
425
426 /* These must appear regardless of ${RELOCATING}. */
427 ${OTHER_SECTIONS}
428}
429EOF