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