merge from gcc
[deliverable/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=.
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} :
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
877d60f7 86 KEEP (*crtbegin*.o(.ctors))
e09a7106
SC
87
88 /* We don't want to include the .ctor section from
bd6791bc 89 the crtend.o file until after the sorted ctors.
e09a7106
SC
90 The .ctor section from the crtend file contains the
91 end of ctors marker and it must be last */
92
877d60f7 93 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
e09a7106
SC
94 KEEP (*(SORT(.ctors.*)))
95 KEEP (*(.ctors))
96 ${CONSTRUCTING+${CTOR_END}}
97 }"
98
99DTOR=" .dtors ${CONSTRUCTING-0} :
100 {
101 ${CONSTRUCTING+${DTOR_START}}
877d60f7
AM
102 KEEP (*crtbegin*.o(.dtors))
103 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
e09a7106
SC
104 KEEP (*(SORT(.dtors.*)))
105 KEEP (*(.dtors))
106 ${CONSTRUCTING+${DTOR_END}}
107 }"
108
109# if this is for an embedded system, don't add SIZEOF_HEADERS.
110if [ -z "$EMBEDDED" ]; then
111 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
112else
113 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
114fi
115
116cat <<EOF
117OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
118 "${LITTLE_OUTPUT_FORMAT}")
119OUTPUT_ARCH(${OUTPUT_ARCH})
120ENTRY(${ENTRY})
121
122${RELOCATING+${LIB_SEARCH_DIRS}}
123${RELOCATING+/* Do we need any of these for elf?
124 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
125${RELOCATING+${EXECUTABLE_SYMBOLS}}
126${RELOCATING+${INPUT_FILES}}
127${RELOCATING- /* For some reason, the Solaris linker makes bad executables
128 if gld -r is used and the intermediate file has sections starting
129 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
130 bug. But for now assigning the zero vmas works. */}
131
132SECTIONS
133{
134 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}
135 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
136 ${CREATE_SHLIB-${INTERP}}
137 ${TEXT_DYNAMIC+${DYNAMIC}}
138
139EOF
140if [ "x$COMBRELOC" = x ]; then
141 COMBRELOCCAT=cat
142else
143 COMBRELOCCAT="cat > $COMBRELOC"
144fi
145eval $COMBRELOCCAT <<EOF
146 .rel.init ${RELOCATING-0} : { *(.rel.init) }
147 .rela.init ${RELOCATING-0} : { *(.rela.init) }
148 .rel.text ${RELOCATING-0} :
149 {
150 *(.rel.text)
151 ${RELOCATING+*(.rel.text.*)}
152 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
153 }
154 .rela.text ${RELOCATING-0} :
155 {
156 *(.rela.text)
157 ${RELOCATING+*(.rela.text.*)}
158 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
159 }
160 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
161 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
162 .rel.rodata ${RELOCATING-0} :
163 {
164 *(.rel.rodata)
165 ${RELOCATING+*(.rel.rodata.*)}
166 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
167 }
168 .rela.rodata ${RELOCATING-0} :
169 {
170 *(.rela.rodata)
171 ${RELOCATING+*(.rela.rodata.*)}
172 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
173 }
174 ${OTHER_READONLY_RELOC_SECTIONS}
175 .rel.data ${RELOCATING-0} :
176 {
177 *(.rel.data)
178 ${RELOCATING+*(.rel.data.*)}
179 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
180 }
181 .rela.data ${RELOCATING-0} :
182 {
183 *(.rela.data)
184 ${RELOCATING+*(.rela.data.*)}
185 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
186 }
187 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
188 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
189 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
190 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
191 .rel.got ${RELOCATING-0} : { *(.rel.got) }
192 .rela.got ${RELOCATING-0} : { *(.rela.got) }
193 ${OTHER_GOT_RELOC_SECTIONS}
194 .rel.sdata ${RELOCATING-0} :
195 {
196 *(.rel.sdata)
197 ${RELOCATING+*(.rel.sdata.*)}
198 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
199 }
200 .rela.sdata ${RELOCATING-0} :
201 {
202 *(.rela.sdata)
203 ${RELOCATING+*(.rela.sdata.*)}
204 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
205 }
206 .rel.sbss ${RELOCATING-0} :
207 {
208 *(.rel.sbss)
209 ${RELOCATING+*(.rel.sbss.*)}
210 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
211 }
212 .rela.sbss ${RELOCATING-0} :
213 {
214 *(.rela.sbss)
215 ${RELOCATING+*(.rela.sbss.*)}
216 ${RELOCATING+*(.rela.gnu.linkonce.sb.*)}
217 }
218 .rel.sdata2 ${RELOCATING-0} :
219 {
220 *(.rel.sdata2)
221 ${RELOCATING+*(.rel.sdata2.*)}
222 ${RELOCATING+*(.rel.gnu.linkonce.s2.*)}
223 }
224 .rela.sdata2 ${RELOCATING-0} :
225 {
226 *(.rela.sdata2)
227 ${RELOCATING+*(.rela.sdata2.*)}
228 ${RELOCATING+*(.rela.gnu.linkonce.s2.*)}
229 }
230 .rel.sbss2 ${RELOCATING-0} :
231 {
232 *(.rel.sbss2)
233 ${RELOCATING+*(.rel.sbss2.*)}
234 ${RELOCATING+*(.rel.gnu.linkonce.sb2.*)}
235 }
236 .rela.sbss2 ${RELOCATING-0} :
237 {
238 *(.rela.sbss2)
239 ${RELOCATING+*(.rela.sbss2.*)}
240 ${RELOCATING+*(.rela.gnu.linkonce.sb2.*)}
241 }
242 .rel.bss ${RELOCATING-0} :
243 {
244 *(.rel.bss)
245 ${RELOCATING+*(.rel.bss.*)}
246 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
247 }
248 .rela.bss ${RELOCATING-0} :
249 {
250 *(.rela.bss)
251 ${RELOCATING+*(.rela.bss.*)}
252 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
253 }
254EOF
255if [ -n "$COMBRELOC" ]; then
256cat <<EOF
257 .rel.dyn :
258 {
259EOF
260sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC
261cat <<EOF
262 }
263 .rela.dyn :
264 {
265EOF
266sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC
267cat <<EOF
268 }
269EOF
270fi
271cat <<EOF
272 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
273 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
274 ${OTHER_PLT_RELOC_SECTIONS}
275
276 .init ${RELOCATING-0} :
277 {
278 ${RELOCATING+${INIT_START}}
279 KEEP (*(.init))
280 ${RELOCATING+${INIT_END}}
281 } =${NOP-0}
282
283 ${DATA_PLT-${BSS_PLT-${PLT}}}
284 .text ${RELOCATING-0} :
285 {
286 ${RELOCATING+${TEXT_START_SYMBOLS}}
287 *(.text)
288 ${RELOCATING+*(.text.*)}
289 *(.stub)
290 /* .gnu.warning sections are handled specially by elf32.em. */
291 *(.gnu.warning)
292 ${RELOCATING+*(.gnu.linkonce.t.*)}
293 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
294 } =${NOP-0}
295 .fini ${RELOCATING-0} :
296 {
297 ${RELOCATING+${FINI_START}}
298 KEEP (*(.fini))
299 ${RELOCATING+${FINI_END}}
300 } =${NOP-0}
301 ${RELOCATING+PROVIDE (__etext = .);}
302 ${RELOCATING+PROVIDE (_etext = .);}
303 ${RELOCATING+PROVIDE (etext = .);}
304
305 /* Adjust the address for the data segment. We want to adjust up to
306 the same address within the page on the next page up. */
307 ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
308 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
309
310 .data ${RELOCATING-0} :
311 {
312 ${RELOCATING+${DATA_START_SYMBOLS}}
313 *(.data)
314 ${RELOCATING+*(.data.*)}
315 ${RELOCATING+*(.gnu.linkonce.d.*)}
316 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
317 }
318 .data1 ${RELOCATING-0} : { *(.data1) }
319 .eh_frame ${RELOCATING-0} :
320 {
321 ${RELOCATING+PROVIDE (__eh_frame_begin = .);}
322 *(.eh_frame)
323 LONG (0);
324 ${RELOCATING+PROVIDE (__eh_frame_end = .);}
325 } ${RELOCATING+}
326 .gcc_except_table : { *(.gcc_except_table) }
327 ${INITIAL_READONLY_SECTIONS}
328 .hash ${RELOCATING-0} : { *(.hash) }
329 .dynsym ${RELOCATING-0} : { *(.dynsym) }
330 .dynstr ${RELOCATING-0} : { *(.dynstr) }
331 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
332 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
333 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
334 ${RODATA}
335 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
336 ${CREATE_SHLIB-${SDATA2}}
337 ${CREATE_SHLIB-${SBSS2}}
338 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
339 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
340 ${TEXT_DYNAMIC-${DYNAMIC}}
341 ${RELOCATING+${CTOR}}
342 ${RELOCATING+${DTOR}}
343 .jcr : { KEEP (*(.jcr)) }
344 ${DATA_PLT+${PLT}}
345 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
346 .got ${RELOCATING-0} : { *(.got.plt) *(.got) }
347 ${RELOCATING+${OTHER_GOT_SECTIONS}}
348 ${CREATE_SHLIB+${SDATA2}}
349 ${CREATE_SHLIB+${SBSS2}}
350 /* We want the small data sections together, so single-instruction offsets
351 can access them all, and initialized data all before uninitialized, so
352 we can shorten the on-disk segment size. */
353 .sdata ${RELOCATING-0} :
354 {
355 ${RELOCATING+${SDATA_START_SYMBOLS}}
356 *(.sdata)
357 ${RELOCATING+*(.sdata.*)}
358 ${RELOCATING+*(.gnu.linkonce.s.*)}
359 }
360 ${RELOCATING+${OTHER_SDATA_SECTIONS}}
361 ${RELOCATING+_edata = .;}
362 ${RELOCATING+PROVIDE (edata = .);}
363 ${RELOCATING+__bss_start = .;}
364 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
365 .sbss ${RELOCATING-0} :
366 {
367 ${RELOCATING+PROVIDE (__sbss_start = .);}
368 ${RELOCATING+PROVIDE (___sbss_start = .);}
369 *(.dynsbss)
370 *(.sbss)
371 ${RELOCATING+*(.sbss.*)}
372 ${RELOCATING+*(.gnu.linkonce.sb.*)}
373 *(.scommon)
374 ${RELOCATING+PROVIDE (__sbss_end = .);}
375 ${RELOCATING+PROVIDE (___sbss_end = .);}
376 }
377 ${BSS_PLT+${PLT}}
378 .bss ${RELOCATING-0} :
379 {
380 *(.dynbss)
381 *(.bss)
382 ${RELOCATING+*(.bss.*)}
383 ${RELOCATING+*(.gnu.linkonce.b.*)}
384 *(COMMON)
385 /* Align here to ensure that the .bss section occupies space up to
386 _end. Align after .bss to ensure correct alignment even if the
387 .bss section disappears because there are no input sections. */
388 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
389 }
827a1c67 390 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
e09a7106 391 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
9f4fb502 392 ${RELOCATING+${OTHER_END_SYMBOLS}}
827a1c67 393 ${RELOCATING+_end = .;}
e09a7106
SC
394 ${RELOCATING+PROVIDE (end = .);}
395
396 /* Stabs debugging sections. */
397 .stab 0 : { *(.stab) }
398 .stabstr 0 : { *(.stabstr) }
399 .stab.excl 0 : { *(.stab.excl) }
400 .stab.exclstr 0 : { *(.stab.exclstr) }
401 .stab.index 0 : { *(.stab.index) }
402 .stab.indexstr 0 : { *(.stab.indexstr) }
403
404 .comment 0 : { *(.comment) }
405
406 /* DWARF debug sections.
407 Symbols in the DWARF debugging sections are relative to the beginning
408 of the section so we begin them at 0. */
409
410 /* DWARF 1 */
411 .debug 0 : { *(.debug) }
412 .line 0 : { *(.line) }
413
414 /* GNU DWARF 1 extensions */
415 .debug_srcinfo 0 : { *(.debug_srcinfo) }
416 .debug_sfnames 0 : { *(.debug_sfnames) }
417
418 /* DWARF 1.1 and DWARF 2 */
419 .debug_aranges 0 : { *(.debug_aranges) }
420 .debug_pubnames 0 : { *(.debug_pubnames) }
421
422 /* DWARF 2 */
423 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
424 .debug_abbrev 0 : { *(.debug_abbrev) }
425 .debug_line 0 : { *(.debug_line) }
426 .debug_frame 0 : { *(.debug_frame) }
427 .debug_str 0 : { *(.debug_str) }
428 .debug_loc 0 : { *(.debug_loc) }
429 .debug_macinfo 0 : { *(.debug_macinfo) }
430
431 /* SGI/MIPS DWARF 2 extensions */
432 .debug_weaknames 0 : { *(.debug_weaknames) }
433 .debug_funcnames 0 : { *(.debug_funcnames) }
434 .debug_typenames 0 : { *(.debug_typenames) }
435 .debug_varnames 0 : { *(.debug_varnames) }
436
437 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
438
439 /* These must appear regardless of ${RELOCATING}. */
440 ${OTHER_SECTIONS}
441}
442EOF
This page took 0.17624 seconds and 4 git commands to generate.