* emulparams/armelf.sh (OTHER_BSS_END_SYMBOLS): Split out from
[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
99 KEEP (*crtbegin*.o(.ctors))
100
101 /* We don't want to include the .ctor section from
102 from the crtend.o file until after the sorted ctors.
103 The .ctor section from the crtend file contains the
104 end of ctors marker and it must be last */
105
106 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
107 KEEP (*(SORT(.ctors.*)))
108 KEEP (*(.ctors))
109 ${CONSTRUCTING+${CTOR_END}}
110 } :text"
111DTOR=".dtors ALIGN(4) :
112 {
113 ${CONSTRUCTING+${DTOR_START}}
114 KEEP (*crtbegin*.o(.dtors))
115 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
116 KEEP (*(SORT(.dtors.*)))
117 KEEP (*(.dtors))
118 ${CONSTRUCTING+${DTOR_END}}
119 } :text"
120STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
121 {
122 ${RELOCATING+_stack = .;}
123 *(.stack)
124 } :data"
125
126# if this is for an embedded system, don't add SIZEOF_HEADERS.
127if [ -z "$EMBEDDED" ]; then
128 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
129else
130 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
131fi
132
133cat <<EOF
134OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
135 "${LITTLE_OUTPUT_FORMAT}")
136OUTPUT_ARCH(${OUTPUT_ARCH})
137ENTRY(${ENTRY})
138
139${RELOCATING+${LIB_SEARCH_DIRS}}
140${RELOCATING+/* Do we need any of these for elf?
141 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
142${RELOCATING+${EXECUTABLE_SYMBOLS}}
143${RELOCATING+${INPUT_FILES}}
144${RELOCATING- /* For some reason, the Solaris linker makes bad executables
145 if gld -r is used and the intermediate file has sections starting
146 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
147 bug. But for now assigning the zero vmas works. */}
148
149PHDRS
150{
151 headers PT_PHDR PHDRS ;
152 text PT_LOAD ;
153 data PT_LOAD ;
154 dyn PT_LOAD FLAGS (0) ;
155 dynamic PT_DYNAMIC ;
156}
157
158SECTIONS
159{
160 /* Read-only sections, merged into text segment: */
161 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}}
162 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}}
163 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}}
164 ${CREATE_SHLIB-${INTERP}}
165
166 ${INITIAL_READONLY_SECTIONS}
167
168 .init ALIGN(4) :
169 {
170 ${RELOCATING+${INIT_START}}
171 KEEP (*(.init))
172 ${RELOCATING+${INIT_END}}
173 } :text =${NOP-0}
174
175 .text ALIGN(4) :
176 {
177 ${RELOCATING+${TEXT_START_SYMBOLS}}
178 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
179 /* .gnu.warning sections are handled specially by elf32.em. */
180 *(.gnu.warning)
181 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
182 } =${NOP-0}
183
184 ${RELOCATING+${CTOR}}
185 ${RELOCATING+${DTOR}}
186
187 .fini ALIGN(4) :
188 {
189 ${RELOCATING+${FINI_START}}
190 KEEP (*(.fini))
191 ${RELOCATING+${FINI_END}}
192 } =${NOP-0}
193
194 ${RELOCATING+PROVIDE (__etext = .);}
195 ${RELOCATING+PROVIDE (_etext = .);}
196 ${RELOCATING+PROVIDE (etext = .);}
197
198 ${WRITABLE_RODATA-${RODATA}}
199 .rodata1 ALIGN(4) : { *(.rodata1) }
200
201 ExportTable ALIGN(4) : { KEEP (*(ExportTable)) }
202 .eh_frame_hdr ALIGN(4) : { *(.eh_frame_hdr) } :text
203
204 /* Adjust the address for the data segment. We want to adjust up to
205 the same address within the page on the next page up. */
206 . = ALIGN(128) + (. & (128 - 1));
207 /* Ensure the __preinit_array_start label is properly aligned. We
208 could instead move the label definition inside the section, but
209 the linker would then create the section even if it turns out to
210 be empty, which isn't pretty. */
211 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
212 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
213 .preinit_array ${RELOCATING-0} : { *(.preinit_array) }
214 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
215
216 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}}
217 .init_array ${RELOCATING-0} : { *(.init_array) }
218 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
219
220 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
221 .fini_array ${RELOCATING-0} : { *(.fini_array) }
222 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
223
224 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
225 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
226 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
227
228 .data ALIGN(4) :
229 {
230 ${RELOCATING+${DATA_START_SYMBOLS}}
231 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
232 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
233 } :data
234
235 .data1 ALIGN(4) : { *(.data1) } :data
236 .tdata ALIGN(4) : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } :data
237 .tbss ALIGN(4) : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } :data
238 .eh_frame ALIGN(4) : { KEEP (*(.eh_frame)) } :data
239 .gcc_except_table ALIGN(4) : { *(.gcc_except_table) } :data
240 ${WRITABLE_RODATA+${RODATA}}
241 ${OTHER_READWRITE_SECTIONS}
242 ${SDATA}
243 ${OTHER_SDATA_SECTIONS}
244 ${RELOCATING+_edata = .;}
245 ${RELOCATING+PROVIDE (edata = .);}
246 ${RELOCATING+__bss_start = .;}
247 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
248 ${BSS_PLT+${PLT}}
249 .bss ALIGN(4) :
250 {
251 *(.dynbss)
252 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
253 *(COMMON)
254 /* Align here to ensure that the .bss section occupies space up to
255 _end. Align after .bss to ensure correct alignment even if the
256 .bss section disappears because there are no input sections. */
257 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
258 } :data
827a1c67 259 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
85fbca6a 260 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
9f4fb502 261 ${RELOCATING+${OTHER_END_SYMBOLS}}
827a1c67 262 ${RELOCATING+_end = .;}
85fbca6a
NC
263 ${RELOCATING+PROVIDE (end = .);}
264 ${RELOCATING+${DATA_SEGMENT_END}}
265
266 ${TEXT_DYNAMIC-${DYNAMIC}}
267 ${TEXT_DYNAMIC+${DYNAMIC}}
268 .hash ${RELOCATING-0} : { *(.hash) } :dynamic :dyn
269 .dynsym ${RELOCATING-0} : { *(.dynsym) } :dynamic :dyn
270 .dynstr ${RELOCATING-0} : { *(.dynstr) } :dynamic :dyn
271 ${DATA_PLT-${BSS_PLT-${PLT}}}
272 .got.plt : { *(.got.plt) } :dynamic :dyn
273 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
274 .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
275 .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
276EOF
277if [ "x$COMBRELOC" = x ]; then
278 COMBRELOCCAT=cat
279else
280 COMBRELOCCAT="cat > $COMBRELOC"
281fi
282eval $COMBRELOCCAT <<EOF
283 .rel.init ${RELOCATING-0} : { *(.rel.init) }
284 .rela.init ${RELOCATING-0} : { *(.rela.init) }
285 .rel.text ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
286 .rela.text ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
287 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
288 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
289 .rel.rodata ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
290 .rela.rodata ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
291 ${OTHER_READONLY_RELOC_SECTIONS}
292 .rel.data ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
293 .rela.data ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
294 .rel.tdata ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
295 .rela.tdata ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
296 .rel.tbss ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
297 .rela.tbss ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
298 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
299 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
300 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
301 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
302 .rel.got ${RELOCATING-0} : { *(.rel.got) }
303 .rela.got ${RELOCATING-0} : { *(.rela.got) }
304 ${OTHER_GOT_RELOC_SECTIONS}
305 .rel.bss ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
306 .rela.bss ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
307EOF
308if [ -n "$COMBRELOC" ]; then
309cat <<EOF
310 .rel.dyn ${RELOCATING-0} :
311 {
312EOF
313sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC
314cat <<EOF
315 }
316 .rela.dyn ${RELOCATING-0} :
317 {
318EOF
319sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC
320cat <<EOF
321 }
322EOF
323fi
324cat <<EOF
325 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
326 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
327 ${OTHER_PLT_RELOC_SECTIONS}
328
329
330 /* Stabs debugging sections. */
331 .stab 0 : { *(.stab) }
332 .stabstr 0 : { *(.stabstr) }
333 .stab.excl 0 : { *(.stab.excl) }
334 .stab.exclstr 0 : { *(.stab.exclstr) }
335 .stab.index 0 : { *(.stab.index) }
336 .stab.indexstr 0 : { *(.stab.indexstr) }
337
338 .comment 0 : { *(.comment) }
339
340 /* DWARF debug sections.
341 Symbols in the DWARF debugging sections are relative to the beginning
342 of the section so we begin them at 0. */
343
344 /* DWARF 1 */
345 .debug 0 : { *(.debug) }
346 .line 0 : { *(.line) }
347
348 /* GNU DWARF 1 extensions */
349 .debug_srcinfo 0 : { *(.debug_srcinfo) }
350 .debug_sfnames 0 : { *(.debug_sfnames) }
351
352 /* DWARF 1.1 and DWARF 2 */
353 .debug_aranges 0 : { *(.debug_aranges) }
354 .debug_pubnames 0 : { *(.debug_pubnames) }
355
356 /* DWARF 2 */
357 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
358 .debug_abbrev 0 : { *(.debug_abbrev) }
359 .debug_line 0 : { *(.debug_line) }
360 .debug_frame 0 : { *(.debug_frame) }
361 .debug_str 0 : { *(.debug_str) }
362 .debug_loc 0 : { *(.debug_loc) }
363 .debug_macinfo 0 : { *(.debug_macinfo) }
364
365 /* SGI/MIPS DWARF 2 extensions */
366 .debug_weaknames 0 : { *(.debug_weaknames) }
367 .debug_funcnames 0 : { *(.debug_funcnames) }
368 .debug_typenames 0 : { *(.debug_typenames) }
369 .debug_varnames 0 : { *(.debug_varnames) }
370
371 ${STACK_ADDR+${STACK}}
372 ${OTHER_SECTIONS}
827a1c67 373 ${RELOCATING+${OTHER_SYMBOLS}}
85fbca6a
NC
374 ${RELOCATING+${STACKNOTE}}
375}
376EOF
This page took 0.079442 seconds and 4 git commands to generate.