]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/iq2000.sc
* scripttempl/elf32cr16.sc: Emit empty script for ld -r and ld -Ur.
[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=.
df381c72
AM
67INTERP=".interp : { *(.interp) }"
68PLT=".plt : { *(.plt) }"
69DYNAMIC=".dynamic : { *(.dynamic) }"
70RODATA=".rodata : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} }"
71SBSS2=".sbss2 : { *(.sbss2) ${RELOCATING+*(.sbss2.*)} ${RELOCATING+*(.gnu.linkonce.sb2.*)} }"
72SDATA2=".sdata2 : { *(.sdata2) ${RELOCATING+*(.sdata2.*)} ${RELOCATING+*(.gnu.linkonce.s2.*)} }"
73CTOR=".ctors :
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
df381c72 100DTOR=" .dtors :
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}}
e09a7106
SC
129
130SECTIONS
131{
132 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}
133 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
134 ${CREATE_SHLIB-${INTERP}}
135 ${TEXT_DYNAMIC+${DYNAMIC}}
136
137EOF
138if [ "x$COMBRELOC" = x ]; then
139 COMBRELOCCAT=cat
140else
141 COMBRELOCCAT="cat > $COMBRELOC"
142fi
143eval $COMBRELOCCAT <<EOF
df381c72
AM
144 .rel.init : { *(.rel.init) }
145 .rela.init : { *(.rela.init) }
146 .rel.text :
e09a7106
SC
147 {
148 *(.rel.text)
149 ${RELOCATING+*(.rel.text.*)}
150 ${RELOCATING+*(.rel.gnu.linkonce.t.*)}
151 }
df381c72 152 .rela.text :
e09a7106
SC
153 {
154 *(.rela.text)
155 ${RELOCATING+*(.rela.text.*)}
156 ${RELOCATING+*(.rela.gnu.linkonce.t.*)}
157 }
df381c72
AM
158 .rel.fini : { *(.rel.fini) }
159 .rela.fini : { *(.rela.fini) }
160 .rel.rodata :
e09a7106
SC
161 {
162 *(.rel.rodata)
163 ${RELOCATING+*(.rel.rodata.*)}
164 ${RELOCATING+*(.rel.gnu.linkonce.r.*)}
165 }
df381c72 166 .rela.rodata :
e09a7106
SC
167 {
168 *(.rela.rodata)
169 ${RELOCATING+*(.rela.rodata.*)}
170 ${RELOCATING+*(.rela.gnu.linkonce.r.*)}
171 }
172 ${OTHER_READONLY_RELOC_SECTIONS}
df381c72 173 .rel.data :
e09a7106
SC
174 {
175 *(.rel.data)
176 ${RELOCATING+*(.rel.data.*)}
177 ${RELOCATING+*(.rel.gnu.linkonce.d.*)}
178 }
df381c72 179 .rela.data :
e09a7106
SC
180 {
181 *(.rela.data)
182 ${RELOCATING+*(.rela.data.*)}
183 ${RELOCATING+*(.rela.gnu.linkonce.d.*)}
184 }
df381c72
AM
185 .rel.ctors : { *(.rel.ctors) }
186 .rela.ctors : { *(.rela.ctors) }
187 .rel.dtors : { *(.rel.dtors) }
188 .rela.dtors : { *(.rela.dtors) }
189 .rel.got : { *(.rel.got) }
190 .rela.got : { *(.rela.got) }
e09a7106 191 ${OTHER_GOT_RELOC_SECTIONS}
df381c72 192 .rel.sdata :
e09a7106
SC
193 {
194 *(.rel.sdata)
195 ${RELOCATING+*(.rel.sdata.*)}
196 ${RELOCATING+*(.rel.gnu.linkonce.s.*)}
197 }
df381c72 198 .rela.sdata :
e09a7106
SC
199 {
200 *(.rela.sdata)
201 ${RELOCATING+*(.rela.sdata.*)}
202 ${RELOCATING+*(.rela.gnu.linkonce.s.*)}
203 }
df381c72 204 .rel.sbss :
e09a7106
SC
205 {
206 *(.rel.sbss)
207 ${RELOCATING+*(.rel.sbss.*)}
208 ${RELOCATING+*(.rel.gnu.linkonce.sb.*)}
209 }
df381c72 210 .rela.sbss :
e09a7106
SC
211 {
212 *(.rela.sbss)
213 ${RELOCATING+*(.rela.sbss.*)}
214 ${RELOCATING+*(.rela.gnu.linkonce.sb.*)}
215 }
df381c72 216 .rel.sdata2 :
e09a7106
SC
217 {
218 *(.rel.sdata2)
219 ${RELOCATING+*(.rel.sdata2.*)}
220 ${RELOCATING+*(.rel.gnu.linkonce.s2.*)}
221 }
df381c72 222 .rela.sdata2 :
e09a7106
SC
223 {
224 *(.rela.sdata2)
225 ${RELOCATING+*(.rela.sdata2.*)}
226 ${RELOCATING+*(.rela.gnu.linkonce.s2.*)}
227 }
df381c72 228 .rel.sbss2 :
e09a7106
SC
229 {
230 *(.rel.sbss2)
231 ${RELOCATING+*(.rel.sbss2.*)}
232 ${RELOCATING+*(.rel.gnu.linkonce.sb2.*)}
233 }
df381c72 234 .rela.sbss2 :
e09a7106
SC
235 {
236 *(.rela.sbss2)
237 ${RELOCATING+*(.rela.sbss2.*)}
238 ${RELOCATING+*(.rela.gnu.linkonce.sb2.*)}
239 }
df381c72 240 .rel.bss :
e09a7106
SC
241 {
242 *(.rel.bss)
243 ${RELOCATING+*(.rel.bss.*)}
244 ${RELOCATING+*(.rel.gnu.linkonce.b.*)}
245 }
df381c72 246 .rela.bss :
e09a7106
SC
247 {
248 *(.rela.bss)
249 ${RELOCATING+*(.rela.bss.*)}
250 ${RELOCATING+*(.rela.gnu.linkonce.b.*)}
251 }
252EOF
253if [ -n "$COMBRELOC" ]; then
254cat <<EOF
255 .rel.dyn :
256 {
257EOF
258sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC
259cat <<EOF
260 }
261 .rela.dyn :
262 {
263EOF
264sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC
265cat <<EOF
266 }
267EOF
268fi
269cat <<EOF
df381c72
AM
270 .rel.plt : { *(.rel.plt) }
271 .rela.plt : { *(.rela.plt) }
e09a7106
SC
272 ${OTHER_PLT_RELOC_SECTIONS}
273
df381c72 274 .init :
e09a7106
SC
275 {
276 ${RELOCATING+${INIT_START}}
277 KEEP (*(.init))
278 ${RELOCATING+${INIT_END}}
279 } =${NOP-0}
280
281 ${DATA_PLT-${BSS_PLT-${PLT}}}
df381c72 282 .text :
e09a7106
SC
283 {
284 ${RELOCATING+${TEXT_START_SYMBOLS}}
285 *(.text)
286 ${RELOCATING+*(.text.*)}
287 *(.stub)
288 /* .gnu.warning sections are handled specially by elf32.em. */
289 *(.gnu.warning)
290 ${RELOCATING+*(.gnu.linkonce.t.*)}
291 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
292 } =${NOP-0}
df381c72 293 .fini :
e09a7106
SC
294 {
295 ${RELOCATING+${FINI_START}}
296 KEEP (*(.fini))
297 ${RELOCATING+${FINI_END}}
298 } =${NOP-0}
299 ${RELOCATING+PROVIDE (__etext = .);}
300 ${RELOCATING+PROVIDE (_etext = .);}
301 ${RELOCATING+PROVIDE (etext = .);}
302
303 /* Adjust the address for the data segment. We want to adjust up to
304 the same address within the page on the next page up. */
305 ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
306 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
307
df381c72 308 .data :
e09a7106
SC
309 {
310 ${RELOCATING+${DATA_START_SYMBOLS}}
311 *(.data)
312 ${RELOCATING+*(.data.*)}
313 ${RELOCATING+*(.gnu.linkonce.d.*)}
314 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
315 }
df381c72
AM
316 .data1 : { *(.data1) }
317 .eh_frame :
e09a7106
SC
318 {
319 ${RELOCATING+PROVIDE (__eh_frame_begin = .);}
320 *(.eh_frame)
321 LONG (0);
322 ${RELOCATING+PROVIDE (__eh_frame_end = .);}
323 } ${RELOCATING+}
324 .gcc_except_table : { *(.gcc_except_table) }
325 ${INITIAL_READONLY_SECTIONS}
df381c72
AM
326 .hash : { *(.hash) }
327 .dynsym : { *(.dynsym) }
328 .dynstr : { *(.dynstr) }
329 .gnu.version : { *(.gnu.version) }
330 .gnu.version_d : { *(.gnu.version_d) }
331 .gnu.version_r : { *(.gnu.version_r) }
e09a7106 332 ${RODATA}
df381c72 333 .rodata1 : { *(.rodata1) }
e09a7106
SC
334 ${CREATE_SHLIB-${SDATA2}}
335 ${CREATE_SHLIB-${SBSS2}}
336 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
337 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
338 ${TEXT_DYNAMIC-${DYNAMIC}}
339 ${RELOCATING+${CTOR}}
340 ${RELOCATING+${DTOR}}
341 .jcr : { KEEP (*(.jcr)) }
342 ${DATA_PLT+${PLT}}
343 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
df381c72 344 .got : { *(.got.plt) *(.got) }
e09a7106
SC
345 ${RELOCATING+${OTHER_GOT_SECTIONS}}
346 ${CREATE_SHLIB+${SDATA2}}
347 ${CREATE_SHLIB+${SBSS2}}
348 /* We want the small data sections together, so single-instruction offsets
349 can access them all, and initialized data all before uninitialized, so
350 we can shorten the on-disk segment size. */
df381c72 351 .sdata :
e09a7106
SC
352 {
353 ${RELOCATING+${SDATA_START_SYMBOLS}}
354 *(.sdata)
355 ${RELOCATING+*(.sdata.*)}
356 ${RELOCATING+*(.gnu.linkonce.s.*)}
357 }
358 ${RELOCATING+${OTHER_SDATA_SECTIONS}}
359 ${RELOCATING+_edata = .;}
360 ${RELOCATING+PROVIDE (edata = .);}
361 ${RELOCATING+__bss_start = .;}
362 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
df381c72 363 .sbss :
e09a7106
SC
364 {
365 ${RELOCATING+PROVIDE (__sbss_start = .);}
366 ${RELOCATING+PROVIDE (___sbss_start = .);}
367 *(.dynsbss)
368 *(.sbss)
369 ${RELOCATING+*(.sbss.*)}
370 ${RELOCATING+*(.gnu.linkonce.sb.*)}
371 *(.scommon)
372 ${RELOCATING+PROVIDE (__sbss_end = .);}
373 ${RELOCATING+PROVIDE (___sbss_end = .);}
374 }
375 ${BSS_PLT+${PLT}}
df381c72 376 .bss :
e09a7106
SC
377 {
378 *(.dynbss)
379 *(.bss)
380 ${RELOCATING+*(.bss.*)}
381 ${RELOCATING+*(.gnu.linkonce.b.*)}
382 *(COMMON)
383 /* Align here to ensure that the .bss section occupies space up to
384 _end. Align after .bss to ensure correct alignment even if the
385 .bss section disappears because there are no input sections. */
386 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
387 }
827a1c67 388 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
e09a7106 389 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
9f4fb502 390 ${RELOCATING+${OTHER_END_SYMBOLS}}
827a1c67 391 ${RELOCATING+_end = .;}
e09a7106
SC
392 ${RELOCATING+PROVIDE (end = .);}
393
394 /* Stabs debugging sections. */
395 .stab 0 : { *(.stab) }
396 .stabstr 0 : { *(.stabstr) }
397 .stab.excl 0 : { *(.stab.excl) }
398 .stab.exclstr 0 : { *(.stab.exclstr) }
399 .stab.index 0 : { *(.stab.index) }
400 .stab.indexstr 0 : { *(.stab.indexstr) }
401
402 .comment 0 : { *(.comment) }
403
404 /* DWARF debug sections.
405 Symbols in the DWARF debugging sections are relative to the beginning
406 of the section so we begin them at 0. */
407
408 /* DWARF 1 */
409 .debug 0 : { *(.debug) }
410 .line 0 : { *(.line) }
411
412 /* GNU DWARF 1 extensions */
413 .debug_srcinfo 0 : { *(.debug_srcinfo) }
414 .debug_sfnames 0 : { *(.debug_sfnames) }
415
416 /* DWARF 1.1 and DWARF 2 */
417 .debug_aranges 0 : { *(.debug_aranges) }
418 .debug_pubnames 0 : { *(.debug_pubnames) }
419
420 /* DWARF 2 */
421 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
422 .debug_abbrev 0 : { *(.debug_abbrev) }
423 .debug_line 0 : { *(.debug_line) }
424 .debug_frame 0 : { *(.debug_frame) }
425 .debug_str 0 : { *(.debug_str) }
426 .debug_loc 0 : { *(.debug_loc) }
427 .debug_macinfo 0 : { *(.debug_macinfo) }
428
429 /* SGI/MIPS DWARF 2 extensions */
430 .debug_weaknames 0 : { *(.debug_weaknames) }
431 .debug_funcnames 0 : { *(.debug_funcnames) }
432 .debug_typenames 0 : { *(.debug_typenames) }
433 .debug_varnames 0 : { *(.debug_varnames) }
434
435 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
436
437 /* These must appear regardless of ${RELOCATING}. */
438 ${OTHER_SECTIONS}
439}
440EOF