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