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