bfd:
[deliverable/binutils-gdb.git] / ld / scripttempl / elf32sh-symbian.sc
CommitLineData
85fbca6a
NC
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 text 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)
104d59d1 11# ATTRS_SECTIONS - at the end
85fbca6a
NC
12# OTHER_SECTIONS - at the end
13# EXECUTABLE_SYMBOLS - symbols that must be defined for an
14# executable (e.g., _DYNAMIC_LINK)
15# TEXT_START_SYMBOLS - symbols that appear at the start of the
16# .text section.
17# DATA_START_SYMBOLS - symbols that appear at the start of the
18# .data section.
19# OTHER_GOT_SYMBOLS - symbols defined just before .got.
20# OTHER_GOT_SECTIONS - sections just after .got.
21# OTHER_SDATA_SECTIONS - sections just after .sdata.
22# OTHER_BSS_SYMBOLS - symbols that appear at the start of the
23# .bss section besides __bss_start.
24# DATA_PLT - .plt should be in data segment, not text segment.
25# BSS_PLT - .plt should be in bss segment
26# TEXT_DYNAMIC - .dynamic in text segment, not data segment.
27# EMBEDDED - whether this is for an embedded system.
28# SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
29# start address of shared library.
30# INPUT_FILES - INPUT command of files to always include
31# WRITABLE_RODATA - if set, the .rodata section should be writable
32# INIT_START, INIT_END - statements just before and just after
33# combination of .init sections.
34# FINI_START, FINI_END - statements just before and just after
35# combination of .fini sections.
36# STACK_ADDR - start of a .stack section.
827a1c67 37# OTHER_SYMBOLS - symbols to place right at the end of the script.
85fbca6a
NC
38#
39# When adding sections, do note that the names of some sections are used
40# when specifying the start address of the next.
41#
42
43# Many sections come in three flavours. There is the 'real' section,
44# like ".data". Then there are the per-procedure or per-variable
45# sections, generated by -ffunction-sections and -fdata-sections in GCC,
46# and useful for --gc-sections, which for a variable "foo" might be
47# ".data.foo". Then there are the linkonce sections, for which the linker
48# eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
49# The exact correspondences are:
50#
51# Section Linkonce section
52# .text .gnu.linkonce.t.foo
53# .rodata .gnu.linkonce.r.foo
54# .data .gnu.linkonce.d.foo
55# .bss .gnu.linkonce.b.foo
56# .sdata .gnu.linkonce.s.foo
57# .sbss .gnu.linkonce.sb.foo
58# .sdata2 .gnu.linkonce.s2.foo
59# .sbss2 .gnu.linkonce.sb2.foo
60# .debug_info .gnu.linkonce.wi.foo
61# .tdata .gnu.linkonce.td.foo
62# .tbss .gnu.linkonce.tb.foo
63#
64# Each of these can also have corresponding .rel.* and .rela.* sections.
65
66test -z "$ENTRY" && ENTRY=_start
67test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
68test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
69if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
70test -z "${ELFSIZE}" && ELFSIZE=32
71test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
72test "$LD_FLAG" = "N" && DATA_ADDR=.
73test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
74test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
104d59d1 75test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
85fbca6a
NC
76DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
77DATA_SEGMENT_END=""
78if test -n "${COMMONPAGESIZE}"; then
79 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
80 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
81fi
82 INTERP=".interp ALIGN(4) : { *(.interp) }"
83 PLT=".plt : { *(.plt) } :dynamic :dyn"
84DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn"
85 RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
86STACKNOTE="/DISCARD/ : { *(.note.GNU-stack) *(.directive) }"
87test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn"
88CTOR=".ctors ALIGN(4) :
89 {
90 ${CONSTRUCTING+${CTOR_START}}
91 /* gcc uses crtbegin.o to find the start of
92 the constructors, so we make sure it is
93 first. Because this is a wildcard, it
94 doesn't matter if the user does not
95 actually link against crtbegin.o; the
96 linker won't look for a file to match a
97 wildcard. The wildcard also means that it
98 doesn't matter which directory crtbegin.o
99 is in. */
100
40cf2291
AM
101 KEEP (*crtbegin.o(.ctors))
102 KEEP (*crtbegin?.o(.ctors))
85fbca6a
NC
103
104 /* We don't want to include the .ctor section from
bd6791bc 105 the crtend.o file until after the sorted ctors.
85fbca6a
NC
106 The .ctor section from the crtend file contains the
107 end of ctors marker and it must be last */
108
40cf2291 109 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
85fbca6a
NC
110 KEEP (*(SORT(.ctors.*)))
111 KEEP (*(.ctors))
112 ${CONSTRUCTING+${CTOR_END}}
113 } :text"
114DTOR=".dtors ALIGN(4) :
115 {
116 ${CONSTRUCTING+${DTOR_START}}
40cf2291
AM
117 KEEP (*crtbegin.o(.dtors))
118 KEEP (*crtbegin?.o(.dtors))
119 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
85fbca6a
NC
120 KEEP (*(SORT(.dtors.*)))
121 KEEP (*(.dtors))
122 ${CONSTRUCTING+${DTOR_END}}
123 } :text"
124STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
125 {
126 ${RELOCATING+_stack = .;}
127 *(.stack)
128 } :data"
129
130# if this is for an embedded system, don't add SIZEOF_HEADERS.
131if [ -z "$EMBEDDED" ]; then
132 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
133else
134 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
135fi
136
137cat <<EOF
138OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
139 "${LITTLE_OUTPUT_FORMAT}")
140OUTPUT_ARCH(${OUTPUT_ARCH})
141ENTRY(${ENTRY})
142
143${RELOCATING+${LIB_SEARCH_DIRS}}
144${RELOCATING+/* Do we need any of these for elf?
145 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
146${RELOCATING+${EXECUTABLE_SYMBOLS}}
147${RELOCATING+${INPUT_FILES}}
148${RELOCATING- /* For some reason, the Solaris linker makes bad executables
149 if gld -r is used and the intermediate file has sections starting
150 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
151 bug. But for now assigning the zero vmas works. */}
152
153PHDRS
154{
155 headers PT_PHDR PHDRS ;
156 text PT_LOAD ;
157 data PT_LOAD ;
158 dyn PT_LOAD FLAGS (0) ;
159 dynamic PT_DYNAMIC ;
160}
161
162SECTIONS
163{
164 /* Read-only sections, merged into text segment: */
165 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}}
166 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}}
167 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}}
168 ${CREATE_SHLIB-${INTERP}}
169
170 ${INITIAL_READONLY_SECTIONS}
171
172 .init ALIGN(4) :
173 {
174 ${RELOCATING+${INIT_START}}
175 KEEP (*(.init))
176 ${RELOCATING+${INIT_END}}
177 } :text =${NOP-0}
178
179 .text ALIGN(4) :
180 {
181 ${RELOCATING+${TEXT_START_SYMBOLS}}
182 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
183 /* .gnu.warning sections are handled specially by elf32.em. */
184 *(.gnu.warning)
185 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
186 } =${NOP-0}
187
188 ${RELOCATING+${CTOR}}
189 ${RELOCATING+${DTOR}}
190
191 .fini ALIGN(4) :
192 {
193 ${RELOCATING+${FINI_START}}
194 KEEP (*(.fini))
195 ${RELOCATING+${FINI_END}}
196 } =${NOP-0}
197
198 ${RELOCATING+PROVIDE (__etext = .);}
199 ${RELOCATING+PROVIDE (_etext = .);}
200 ${RELOCATING+PROVIDE (etext = .);}
201
202 ${WRITABLE_RODATA-${RODATA}}
203 .rodata1 ALIGN(4) : { *(.rodata1) }
204
205 ExportTable ALIGN(4) : { KEEP (*(ExportTable)) }
206 .eh_frame_hdr ALIGN(4) : { *(.eh_frame_hdr) } :text
207
208 /* Adjust the address for the data segment. We want to adjust up to
209 the same address within the page on the next page up. */
210 . = ALIGN(128) + (. & (128 - 1));
6f2942ed
PB
211 .preinit_array ${RELOCATING-0} :
212 {
213 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_start = .);}}
214 KEEP (*(.preinit_array))
215 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_end = .);}}
216 }
217 .init_array ${RELOCATING-0} :
218 {
219 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_start = .);}}
220 KEEP (*(SORT(.init_array.*)))
221 KEEP (*(.init_array))
222 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_end = .);}}
223 }
224 .fini_array ${RELOCATING-0} :
225 {
226 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_start = .);}}
227 KEEP (*(.fini_array))
228 KEEP (*(SORT(.fini_array.*)))
229 ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_end = .);}}
230 }
85fbca6a
NC
231
232 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
233 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
234 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
235
236 .data ALIGN(4) :
237 {
238 ${RELOCATING+${DATA_START_SYMBOLS}}
239 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
240 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
241 } :data
242
243 .data1 ALIGN(4) : { *(.data1) } :data
244 .tdata ALIGN(4) : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } :data
245 .tbss ALIGN(4) : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } :data
246 .eh_frame ALIGN(4) : { KEEP (*(.eh_frame)) } :data
247 .gcc_except_table ALIGN(4) : { *(.gcc_except_table) } :data
248 ${WRITABLE_RODATA+${RODATA}}
249 ${OTHER_READWRITE_SECTIONS}
250 ${SDATA}
251 ${OTHER_SDATA_SECTIONS}
252 ${RELOCATING+_edata = .;}
253 ${RELOCATING+PROVIDE (edata = .);}
254 ${RELOCATING+__bss_start = .;}
255 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
256 ${BSS_PLT+${PLT}}
257 .bss ALIGN(4) :
258 {
259 *(.dynbss)
260 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
261 *(COMMON)
262 /* Align here to ensure that the .bss section occupies space up to
263 _end. Align after .bss to ensure correct alignment even if the
264 .bss section disappears because there are no input sections. */
265 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
266 } :data
827a1c67 267 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
85fbca6a 268 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
9f4fb502 269 ${RELOCATING+${OTHER_END_SYMBOLS}}
827a1c67 270 ${RELOCATING+_end = .;}
85fbca6a
NC
271 ${RELOCATING+PROVIDE (end = .);}
272 ${RELOCATING+${DATA_SEGMENT_END}}
273
274 ${TEXT_DYNAMIC-${DYNAMIC}}
275 ${TEXT_DYNAMIC+${DYNAMIC}}
276 .hash ${RELOCATING-0} : { *(.hash) } :dynamic :dyn
277 .dynsym ${RELOCATING-0} : { *(.dynsym) } :dynamic :dyn
278 .dynstr ${RELOCATING-0} : { *(.dynstr) } :dynamic :dyn
279 ${DATA_PLT-${BSS_PLT-${PLT}}}
280 .got.plt : { *(.got.plt) } :dynamic :dyn
281 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
282 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
283 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
284EOF
285if [ "x$COMBRELOC" = x ]; then
286 COMBRELOCCAT=cat
287else
288 COMBRELOCCAT="cat > $COMBRELOC"
289fi
290eval $COMBRELOCCAT <<EOF
291 .rel.init ${RELOCATING-0} : { *(.rel.init) }
292 .rela.init ${RELOCATING-0} : { *(.rela.init) }
293 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
294 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
295 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
296 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
297 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
298 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
299 ${OTHER_READONLY_RELOC_SECTIONS}
300 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
301 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
302 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
303 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
304 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
305 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
306 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
307 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
308 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
309 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
310 .rel.got ${RELOCATING-0} : { *(.rel.got) }
311 .rela.got ${RELOCATING-0} : { *(.rela.got) }
312 ${OTHER_GOT_RELOC_SECTIONS}
313 .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
314 .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
315EOF
316if [ -n "$COMBRELOC" ]; then
317cat <<EOF
318 .rel.dyn ${RELOCATING-0} :
319 {
320EOF
321sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC
322cat <<EOF
323 }
324 .rela.dyn ${RELOCATING-0} :
325 {
326EOF
327sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC
328cat <<EOF
329 }
330EOF
331fi
332cat <<EOF
333 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
334 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
335 ${OTHER_PLT_RELOC_SECTIONS}
336
337
338 /* Stabs debugging sections. */
339 .stab 0 : { *(.stab) }
340 .stabstr 0 : { *(.stabstr) }
341 .stab.excl 0 : { *(.stab.excl) }
342 .stab.exclstr 0 : { *(.stab.exclstr) }
343 .stab.index 0 : { *(.stab.index) }
344 .stab.indexstr 0 : { *(.stab.indexstr) }
345
346 .comment 0 : { *(.comment) }
347
348 /* DWARF debug sections.
349 Symbols in the DWARF debugging sections are relative to the beginning
350 of the section so we begin them at 0. */
351
352 /* DWARF 1 */
353 .debug 0 : { *(.debug) }
354 .line 0 : { *(.line) }
355
356 /* GNU DWARF 1 extensions */
357 .debug_srcinfo 0 : { *(.debug_srcinfo) }
358 .debug_sfnames 0 : { *(.debug_sfnames) }
359
360 /* DWARF 1.1 and DWARF 2 */
361 .debug_aranges 0 : { *(.debug_aranges) }
362 .debug_pubnames 0 : { *(.debug_pubnames) }
363
364 /* DWARF 2 */
365 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
366 .debug_abbrev 0 : { *(.debug_abbrev) }
367 .debug_line 0 : { *(.debug_line) }
368 .debug_frame 0 : { *(.debug_frame) }
369 .debug_str 0 : { *(.debug_str) }
370 .debug_loc 0 : { *(.debug_loc) }
371 .debug_macinfo 0 : { *(.debug_macinfo) }
372
373 /* SGI/MIPS DWARF 2 extensions */
374 .debug_weaknames 0 : { *(.debug_weaknames) }
375 .debug_funcnames 0 : { *(.debug_funcnames) }
376 .debug_typenames 0 : { *(.debug_typenames) }
377 .debug_varnames 0 : { *(.debug_varnames) }
378
379 ${STACK_ADDR+${STACK}}
104d59d1 380 ${ATTRS_SECTIONS}
85fbca6a 381 ${OTHER_SECTIONS}
827a1c67 382 ${RELOCATING+${OTHER_SYMBOLS}}
85fbca6a
NC
383 ${RELOCATING+${STACKNOTE}}
384}
385EOF
This page took 0.18933 seconds and 4 git commands to generate.